Sha256: f17c6aa8d09aae97a88d9b726f7e4f63d343355e6d5d7cd64ab42493c9c2e922

Contents?: true

Size: 1.03 KB

Versions: 29

Compression:

Stored size: 1.03 KB

Contents

class Lono::Importer
  class Erb < Base
    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

    # Add template definition to app/definitions/base.rb.
    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
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
lono-7.5.2 lib/lono/importer/erb.rb
lono-7.5.1 lib/lono/importer/erb.rb
lono-7.5.0 lib/lono/importer/erb.rb
lono-7.4.11 lib/lono/importer/erb.rb
lono-7.4.10 lib/lono/importer/erb.rb
lono-7.4.9 lib/lono/importer/erb.rb
lono-7.4.8 lib/lono/importer/erb.rb
lono-7.4.7 lib/lono/importer/erb.rb
lono-7.4.6 lib/lono/importer/erb.rb
lono-7.4.5 lib/lono/importer/erb.rb
lono-7.4.4 lib/lono/importer/erb.rb
lono-7.4.3 lib/lono/importer/erb.rb
lono-7.4.2 lib/lono/importer/erb.rb
lono-7.4.1 lib/lono/importer/erb.rb
lono-7.4.0 lib/lono/importer/erb.rb
lono-7.3.2 lib/lono/importer/erb.rb
lono-7.3.1 lib/lono/importer/erb.rb
lono-7.3.0 lib/lono/importer/erb.rb
lono-7.2.3 lib/lono/importer/erb.rb
lono-7.2.2 lib/lono/importer/erb.rb