Rails:列出所有插件路径

时间:2009-12-15 17:33:27

标签: ruby-on-rails ruby

我想枚举Rails应用程序中所有插件的路径。基本上#{RAILS_ROOT}/vendor/plugins/*,但不包括gems提供的插件,或明确指定的插件,等等。

我找到了一个解决方案,我将在答案中提供,以便您可以投票,但这非常难看。 (这是正确的礼仪吗?)

1 个答案:

答案 0 :(得分:1)

# 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