Class: Rails::Plugin::GemLocator

Inherits:
Locator show all
Defined in:
lib/rails/plugin/locator.rb

Overview

The GemLocator scans all the loaded RubyGems, looking for gems with a rails/init.rb file.

Instance Attribute Summary

Attributes inherited from Locator

#initializer

Instance Method Summary collapse

Methods inherited from Locator

#each, #initialize, #plugin_names

Constructor Details

This class inherits a constructor from Rails::Plugin::Locator

Instance Method Details

#pluginsObject



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/rails/plugin/locator.rb', line 80

def plugins
  gem_index = initializer.configuration.gems.inject({}) { |memo, gem| memo.update gem.specification => gem }
  specs     = gem_index.keys
  specs    += Gem.loaded_specs.values.select do |spec|
    spec.loaded_from && # prune stubs
      File.exist?(File.join(spec.full_gem_path, "rails", "init.rb"))
  end
  specs.compact!

  require "rubygems/dependency_list"

  deps = Gem::DependencyList.new
  deps.add(*specs) unless specs.empty?

  deps.dependency_order.collect do |spec|
    Rails::GemPlugin.new(spec, gem_index[spec])
  end
end