我想枚举Rails应用程序中所有插件的路径。基本上#{RAILS_ROOT}/vendor/plugins/*
,但不包括gems提供的插件,或明确指定的插件,等等。
我找到了一个解决方案,我将在答案中提供,以便您可以投票,但这非常难看。 (这是正确的礼仪吗?)
答案 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