Class: Rails::Generator::Source

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rails_generator/lookup.rb

Overview

Sources enumerate (yield from #each) generator specs which describe where to find and how to create generators. Enumerable is mixed in so, for example, source.collect will retrieve every generator. Sources may be assigned a label to distinguish them.

Direct Known Subclasses

AbstractGemSource, PathSource

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label) ⇒ Source

Returns a new instance of Source.



164
165
166
# File 'lib/rails_generator/lookup.rb', line 164

def initialize(label)
  @label = label
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



163
164
165
# File 'lib/rails_generator/lookup.rb', line 163

def label
  @label
end

Instance Method Details

#eachObject

The each method must be implemented in subclasses. The base implementation raises an error.

Raises:

  • (NotImplementedError)


170
171
172
# File 'lib/rails_generator/lookup.rb', line 170

def each
  raise NotImplementedError
end

#namesObject

Return a convenient sorted list of all generator names.



175
176
177
# File 'lib/rails_generator/lookup.rb', line 175

def names
  map { |spec| spec.name }.sort
end