Class: Lono::Pro::Importer::Erb
- Defined in:
- lib/lono/pro/importer/erb.rb
Instance Method Summary collapse
-
#add_template_definition ⇒ Object
Add template definition to app/definitions/base.rb.
- #run ⇒ Object
Methods inherited from Base
Methods included from Download
#download_template, #json?, #read_source
Constructor Details
This class inherits a constructor from Lono::Pro::Importer::Base
Instance Method Details
#add_template_definition ⇒ Object
Add template definition to app/definitions/base.rb.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lono/pro/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 |
#run ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/lono/pro/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 downloaded to #{pretty_path(template_path)}" create_dot_lono("erb") template_definition_path = add_template_definition puts "Template definition added to #{pretty_path(template_definition_path)}" create_params(template_path) summarize end |