Class: RubiGen::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, GemPathSource, 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.
- #usage_file ⇒ Object
- #visible? ⇒ Boolean
Constructor Details
#initialize(name, path, source) ⇒ Spec
Returns a new instance of Spec.
8 9 10 |
# File 'lib/rubigen/spec.rb', line 8 def initialize(name, path, source) @name, @path, @source, @klass = name, path, source, nil end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/rubigen/spec.rb', line 6 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/rubigen/spec.rb', line 6 def path @path end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
6 7 8 |
# File 'lib/rubigen/spec.rb', line 6 def source @source end |
Instance Method Details
#class_file ⇒ Object
23 24 25 |
# File 'lib/rubigen/spec.rb', line 23 def class_file "#{path}/#{name}_generator.rb" end |
#class_name ⇒ Object
27 28 29 |
# File 'lib/rubigen/spec.rb', line 27 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.
14 15 16 17 18 19 20 21 |
# File 'lib/rubigen/spec.rb', line 14 def klass unless @klass require class_file @klass = lookup_class @klass.spec = self end @klass end |
#usage_file ⇒ Object
31 32 33 |
# File 'lib/rubigen/spec.rb', line 31 def usage_file "#{path}/USAGE" end |
#visible? ⇒ Boolean
35 36 37 |
# File 'lib/rubigen/spec.rb', line 35 def visible? File.exists? usage_file end |