Class: Rails::Generator::GemSource

Inherits:
Source show all
Defined in:
lib/rails_generator/lookup.rb

Overview

GemSource hits the mines to quarry for generators. The latest versions of gems named *_generator are selected.

Instance Attribute Summary

Attributes inherited from Source

#label

Instance Method Summary collapse

Methods inherited from Source

#names

Constructor Details

#initializeGemSource

Returns a new instance of GemSource.



189
190
191
# File 'lib/rails_generator/lookup.rb', line 189

def initialize
  super :RubyGems
end

Instance Method Details

#eachObject

Yield latest versions of generator gems.



194
195
196
197
198
199
200
201
202
# File 'lib/rails_generator/lookup.rb', line 194

def each
  Gem::cache.search(/_generator$/).inject({}) { |latest, gem|
    hem = latest[gem.name]
    latest[gem.name] = gem if hem.nil? or gem.version > hem.version
    latest
  }.values.each { |gem|
    yield Spec.new(gem.name.sub(/_generator$/, ''), gem.full_gem_path, label)
  }
end