Class: Slickr::Actions::Generate
- Inherits:
-
Object
- Object
- Slickr::Actions::Generate
- Defined in:
- lib/slickr/actions/generate.rb
Overview
Adapter for calling the different types of Generators.
This class takes the name of the generator, in any form, and the name the user wants to give to the new piece of code. It will normalize both to follow Slickr conventions.
Naming Conventions
Slickr follows the same sort of conventions as Rails. Classes are appended with their type. Eg. a “spatiality” behavior will become SpatialityBehavior, a “hero” renderer will become HeroRenderer, etc.
Instance Method Summary collapse
- #basename ⇒ Object
- #generator_class ⇒ Object
-
#initialize(type, name) ⇒ Generate
constructor
A new instance of Generate.
- #name ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(type, name) ⇒ Generate
Returns a new instance of Generate.
29 30 31 32 |
# File 'lib/slickr/actions/generate.rb', line 29 def initialize(type, name) @type = type @name = name end |
Instance Method Details
#basename ⇒ Object
46 47 48 |
# File 'lib/slickr/actions/generate.rb', line 46 def basename @name.gsub(/#{@type}/i, "").downcase end |
#generator_class ⇒ Object
38 39 40 |
# File 'lib/slickr/actions/generate.rb', line 38 def generator_class Slickr::Generators.const_get(:"#{@type.capitalize}") end |
#name ⇒ Object
42 43 44 |
# File 'lib/slickr/actions/generate.rb', line 42 def name "#{basename}_#{@type}".squeeze("_") end |
#start ⇒ Object
34 35 36 |
# File 'lib/slickr/actions/generate.rb', line 34 def start generator_class.new(name).start end |