Class: Rails::Generator::Spec
Overview
A spec knows where a generator was found and how to instantiate it. Metadata include the generator’s name, its base path, and the source which yielded it (PathSource, GemSource, etc.)
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #class_file ⇒ Object
- #class_name ⇒ Object
-
#initialize(name, path, source) ⇒ Spec
constructor
A new instance of Spec.
-
#klass ⇒ Object
Look up the generator class.
Constructor Details
#initialize(name, path, source) ⇒ Spec
Returns a new instance of Spec.
9 10 11 |
# File 'lib/rails_generator/spec.rb', line 9 def initialize(name, path, source) @name, @path, @source = name, path, source end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/rails_generator/spec.rb', line 7 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/rails_generator/spec.rb', line 7 def path @path end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/rails_generator/spec.rb', line 7 def source @source end |
Instance Method Details
#class_file ⇒ Object
24 25 26 |
# File 'lib/rails_generator/spec.rb', line 24 def class_file "#{path}/#{name}_generator.rb" end |
#class_name ⇒ Object
28 29 30 |
# File 'lib/rails_generator/spec.rb', line 28 def class_name "#{name.camelize}Generator" end |
#klass ⇒ Object
Look up the generator class. Require its class file, find the class in ObjectSpace, tag it with this spec, and return.
15 16 17 18 19 20 21 22 |
# File 'lib/rails_generator/spec.rb', line 15 def klass unless @klass require class_file @klass = lookup_class @klass.spec = self end @klass end |