开发者

Rails: list all plugin paths

开发者 https://www.devze.com 2022-12-14 06:05 出处:网络
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百科 specifi

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
0

精彩评论

暂无评论...
验证码 换一张
取 消