Sha256: 22734c75dc0f8fd8b0bd46963f8070d02fff8846bed47f3df33f21f659257214

Contents?: true

Size: 955 Bytes

Versions: 1

Compression:

Stored size: 955 Bytes

Contents

##
#  Functions almost exactly like the standard Rails::Plugin::GemLocator,
#  but will not return gems that conform to Kajam extensions.
#  See kajam/extension_locator for the plugin locator that handles extensions.

module Kajam
  class GemLocator < Rails::Plugin::GemLocator
    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!
      specs.reject! { |s| s.name =~ /^kajam-.*-extension$/ }

      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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kajam-1.0.3.rc2 lib/kajam/gem_locator.rb