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开发者_JAVA百科 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?)
# 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
精彩评论