Class: Origen::CodeGenerators::Base
- Includes:
- Actions, Thor::Actions
- Defined in:
- lib/origen/code_generators/base.rb
Class Method Summary collapse
- .banner ⇒ Object
-
.inherited(base) ⇒ Object
Cache source root and add lib/generators/base/generator/templates to source paths.
-
.name ⇒ Object
Sets the base_name taking into account the current class namespace.
-
.namespace(name = nil) ⇒ Object
Convenience method to get the top-level namespace from the class name.
Methods included from Actions
#add_config, #add_source, #comment_config, #config, #environment, #gem, #gem_group, #generate, #git, #initialize, #lib, #rake, #rakefile, #readme
Class Method Details
.banner ⇒ Object
52 53 54 |
# File 'lib/origen/code_generators/base.rb', line 52 def self. "origen add #{namespace == 'origen' ? '' : namespace + ':'}#{name} [options]" end |
.inherited(base) ⇒ Object
Cache source root and add lib/generators/base/generator/templates to source paths.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/origen/code_generators/base.rb', line 36 def self.inherited(base) #:nodoc: super if base.name && base.name !~ /Base$/ if base.namespace == 'origen' Origen::CodeGenerators.origen_generators[base.name] = base else Origen::CodeGenerators.plugin_generators[base.namespace] ||= {} Origen::CodeGenerators.plugin_generators[base.namespace][base.name] = base end end # Give all generators access to Origen core files in their source path, # with their own app as highest priority base.source_paths << Origen.root if Origen.app_loaded? base.source_paths << Origen.top end |
.name ⇒ Object
Sets the base_name taking into account the current class namespace.
28 29 30 31 32 |
# File 'lib/origen/code_generators/base.rb', line 28 def self.name @name ||= begin to_s.split('::').last.sub(/(CodeGenerator|Generator)$/, '').underscore end end |
.namespace(name = nil) ⇒ Object
Convenience method to get the top-level namespace from the class name. It is returned as a lower cased and underscored string.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/origen/code_generators/base.rb', line 16 def self.namespace(name = nil) @namespace ||= begin names = super.split(':') if names.size == 1 nil else names.first.sub(/^r_gen/, 'origen') end end end |