Sha256: 4cc875cb20b4add23e5479ca6a5cc8adae7234b9d26bf0c03356db1f8bdd6948

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

class Lono::Importer
  class Base < Lono::CLI::Base
    include Download
    include Thor::Actions
    include Thor::Base

    def initialize(options)
      reinitialize(options)
      @source = options[:source]
      @tmp_path = "/tmp/lono/import/template.yml"
      self.destination_root = Dir.pwd # Thor::Actions require destination_root to be set
    end

  private
    def summarize
      return unless @options[:summary]
      logger.info "Template Summary:"
      Lono::Inspector::Summary.new(@options).run
    end

    def create_params(template_path)
      create_params_file(template_path, "development")
      create_params_file(template_path, "production")
    end

    def create_params_file(template_path, env)
      params_path = if @blueprint.name != @template
                      "config/#{@blueprint.name}/params/#{env}/#{@template}.txt"
                    else
                      "config/#{@blueprint.name}/params/#{env}.txt"
                    end
      params = Params.new(template_path, params_path)
      params.create
    end

    # removes the ./ at the beginning if it's there in the path
    def pretty_path(path)
      path.sub("#{Lono.root}/",'')
    end

    def blueprint_name
      return @options[:name] if @options[:name]
      # Else infer name from the original source.
      name = File.basename(@source, ".*")
      @options[:casing] == "camelcase" ? name.camelize : name.underscore.dasherize
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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