Class: Lono::Importer::Erb

Inherits:
Base show all
Defined in:
lib/lono/importer/erb.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Download

#download_template, #json?, #read_source

Methods inherited from AbstractBase

#initialize, #reinitialize, #template_path

Methods included from Blueprint::Root

#find_blueprint_root, #set_blueprint_root

Constructor Details

This class inherits a constructor from Lono::Importer::Base

Instance Method Details

#add_template_definitionObject

Add template definition to app/definitions/base.rb.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/lono/importer/erb.rb', line 18

def add_template_definition
  path = "#{Lono.config.definitions_path}/base.rb"
  lines = File.exist?(path) ? IO.readlines(path) : []
  new_template_definition = %Q|template "#{@template}"|
  unless lines.detect { |l| l.include?(new_template_definition) }
    lines << ["\n", new_template_definition]
    result = lines.join('')
    FileUtils.mkdir_p(File.dirname(path))
    IO.write(path, result)
  end
  path
end

#runObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/lono/importer/erb.rb', line 3

def run
  puts "=> Imported CloudFormation template.".color(:green)
  template_path = "#{Lono.config.templates_path}/#{@template}.yml"
  download_template(@source, template_path)
  puts "Template created: #{pretty_path(template_path)}"

  create_dot_lono("erb")
  template_definition_path = add_template_definition
  puts "Template definition added: #{pretty_path(template_definition_path)}"

  create_params(template_path)
  summarize
end