views:

56

answers:

1

I'd like to enumerate the paths for all of the plugins in a Rails application. Essentially #{RAILS_ROOT}/vendor/plugins/*, but that does not include plugins provided by gems, or specified explicitly, et cetera.

I've found one solution which I'll provide in an answer so you can vote for it, but it's pretty ugly. (Is that the proper etiquette?)

A: 
# really what we want is a reference to the Initializer used in
# config/boot.rb.  But since we can't monkey patch that file, we'll
# use a fake instead.

class FakeInitializer
  attr_reader :configuration

  def initialize(config = Rails.configuration)
    @configuration = config
  end
end

init = FakeInitializer.new(Rails.configuration)
Rails.configuration.plugin_loader.new(init).plugins.map &:directory
Bryan Larsen