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 31 32 33 34 35 |
# 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) full = generator_class.new(@options.merge(root: configset_root)).build if @options[:cli] full["Metadata"] # contains AWS::CloudFormation::Init and optional AWS::CloudFormation::Authentication else full # Combiner uses full metadata structure end 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
42 43 44 45 46 |
# File 'lib/lono/configset/generator.rb', line 42 def configset_root finder = finder_class.new found = finder.find(@configset, local_only: false) found.root if found end |
#finder_class ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/lono/configset/generator.rb', line 48 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 |