Class: Couch::Generators::Base
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Couch::Generators::Base
- Includes:
- Thor::Actions
- Defined in:
- lib/couch/generators/base.rb
Direct Known Subclasses
Class Method Summary collapse
-
.desc(description = nil) ⇒ Object
Tries to get the description from a USAGE file one folder above the source root otherwise uses a default description.
- .info ⇒ Object
-
.source_root ⇒ Object
Automatically sets the source root based on the class name.
Class Method Details
.desc(description = nil) ⇒ Object
Tries to get the description from a USAGE file one folder above the source root otherwise uses a default description.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/couch/generators/base.rb', line 30 def self.desc(description=nil) return super if description usage = File.(File.join(source_root, "..", "USAGE")) @desc ||= if File.exist?(usage) File.read(usage) else "Description:\n Create files for #{generator_name} generator." end end |
.info ⇒ Object
41 42 43 |
# File 'lib/couch/generators/base.rb', line 41 def self.info desc.split(/\n+/)[1].strip end |
.source_root ⇒ Object
Automatically sets the source root based on the class name.
19 20 21 22 23 24 25 |
# File 'lib/couch/generators/base.rb', line 19 def self.source_root @_couch_source_root ||= begin if generator_name File.(File.join("../generators", generator_name, 'templates'), File.dirname(__FILE__)) end end end |