ruhoh / ruhoh.rb

http://ruhoh.com
616 stars 69 forks source link

[question] plugins via bundler #232

Closed nicolaracco closed 10 years ago

nicolaracco commented 10 years ago

I would to know if it could be acceptable to start supporting plugins via bundler also. I checked the code and I imagined something like the following:

class Ruhoh
  class << self
    def add_plugin &block
      @plugins ||= []
      @plugins << block
    end
  end

  def setup_plugins
    ensure_paths
    ... # plugins loaded from plugins/ directory
    self.class.plugins.each(&:call)
  end
end

This way I could write a gem (let's say 'plugin1') whose code could be:

require 'plugin1/foo'

Ruhoh.add_plugin do
  Ruhoh.collection('pages').send :include, Plugin1::Foo
end

If you want I can fork the repo and try to achieve this, but I would to know if it's acceptable for you first :)

plusjade commented 10 years ago

@nicolaracco yes this would be a great addition. Keep in mind the plugins would have to run in the context of the ruhoh instance. I guess not all plugins will need the instance but those are just my thoughts looking over the initial code. I'll play with it myself when I get some time, but yes if you can get it working I will merge it in!

nicolaracco commented 10 years ago

I created a pull request. Let me know if it's ok

plusjade commented 10 years ago

@nicolaracco thanks for your help! Sorry I took so long. The day job gets a hold of me lately. I've merged your PR so am closing this issue. :thumbsup: