Class: Lono::Configset::Generator
- Inherits:
-
Object
- Object
- Lono::Configset::Generator
- Defined in:
- lib/lono/configset/generator.rb
Instance Method Summary collapse
- #build ⇒ Object
- #check_configset_exist! ⇒ Object
- #configset_root ⇒ Object
- #finder_class ⇒ Object
-
#initialize(options) ⇒ Generator
constructor
A new instance of Generator.
- #run ⇒ Object
- #strategy ⇒ Object
Constructor Details
#initialize(options) ⇒ Generator
Returns a new instance of Generator.
3 4 5 6 7 |
# File 'lib/lono/configset/generator.rb', line 3 def initialize() @options = @configset = [:configset] @type = [:type] || "project" end |
Instance Method Details
#build ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/lono/configset/generator.rb', line 23 def build # Examples: # Erb.new(options).build # Dsl.new(options).build generator_class = "Lono::Configset::Strategy::#{strategy.camelize}" generator_class = Object.const_get(generator_class) generator_class.new(@options.merge(root: configset_root)).build end |
#check_configset_exist! ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/lono/configset/generator.rb', line 15 def check_configset_exist! exist = !!Lono::Finder::Configset.find(@configset) unless exist puts "configset #{@configset.color(:green)} not found." exit 1 end end |
#configset_root ⇒ Object
37 38 39 40 41 |
# File 'lib/lono/configset/generator.rb', line 37 def configset_root finder = finder_class.new found = finder.find(@configset, local_only: false) found.root if found end |
#finder_class ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/lono/configset/generator.rb', line 43 def finder_class case @type when "project" Lono::Finder::Configset when "blueprint" Lono::Finder::Blueprint::Configset end end |
#run ⇒ Object
9 10 11 12 13 |
# File 'lib/lono/configset/generator.rb', line 9 def run check_configset_exist! structure = build puts YAML.dump(structure) end |