class Lono::Configset::Generator

Public Class Methods

new(options) click to toggle source
# File lib/lono/configset/generator.rb, line 3
def initialize(options)
  @options = options
  @configset = options[:configset]
  @type = options[:type] || "project"
end

Public Instance Methods

build() click to toggle source
# 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!() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# File lib/lono/configset/generator.rb, line 9
def run
  check_configset_exist!
  structure = build
  puts YAML.dump(structure)
end
strategy() click to toggle source
# File lib/lono/configset/generator.rb, line 37
def strategy
  jadespec = Lono::Jadespec.new(configset_root, "unknown") # abusing Jadespec to get strategy
  jadespec.lono_strategy
end