Sha256: dc7ffa59ad6a846ab2d5171bf2ad70516e3f45d79c8306cd011eb0502722e4c0

Contents?: true

Size: 1003 Bytes

Versions: 3

Compression:

Stored size: 1003 Bytes

Contents

class Lono::Importer
  class Dsl < Base
    def run
      tmp_template_path = download_template(@source, @tmp_path)
      template = IO.read(tmp_template_path)

      Lono::Blueprint::New.start([@blueprint.name, "--import", "--type", "dsl"])

      translate_to_dsl(template)
      create_params(tmp_template_path)
      # Let's not summarize the template in case the Ruby syntax is invalid with the import coder.
      # Add summarize back in later
      # summarize

      final_message
    end

    def translate_to_dsl(template)
      coder = Service::Coder.new(template, @options)
      result = coder.translate

      path = "#{Lono.config.paths.templates}/#{@template}.rb"
      FileUtils.mkdir_p(File.dirname(path))
      create_file(path, result) # Thor::Action
    end

    def final_message
      logger.info <<~EOL
        #{"="*64}
        Congrats 🎉 You have successfully imported a lono blueprint.

        More info: https://lono.cloud/docs/core/blueprints
      EOL
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lono-8.0.0.pre.rc3 lib/lono/importer/dsl.rb
lono-8.0.0.pre.rc2 lib/lono/importer/dsl.rb
lono-8.0.0.pre.rc1 lib/lono/importer/dsl.rb