class Lono::Pro::Importer::Base

Public Class Methods

new(source, options) click to toggle source
# File lib/lono/pro/importer/base.rb, line 7
def initialize(source, options)
  @source, @options = source, options
  @blueprint = @options[:blueprint] || blueprint_name
  @template = @options[:template] || @blueprint
  Lono::ProjectChecker.check
  # Dont use set_blueprint_root because it doesnt exist yet. We're creating it with import
  Lono.blueprint_root = "#{Lono.root}/blueprints/#{@blueprint}"

  @tmp_path = "/tmp/lono/import/template.yml"
  self.destination_root = Dir.pwd # Thor::Actions require destination_root to be set
end

Private Instance Methods

blueprint_name() click to toggle source
# File lib/lono/pro/importer/base.rb, line 57
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
create_dot_lono(type) click to toggle source
# File lib/lono/pro/importer/base.rb, line 46
def create_dot_lono(type)
  dot_lono = "#{Lono.blueprint_root}/.meta"
  FileUtils.mkdir_p(dot_lono)
  config = {
    "blueprint_name" => @blueprint,
    "template_type" => "#{type}",
  }
  text = YAML.dump(config)
  IO.write("#{dot_lono}/config.yml", text)
end
create_params(template_path) click to toggle source
# File lib/lono/pro/importer/base.rb, line 26
def create_params(template_path)
  create_params_file(template_path, "development")
  create_params_file(template_path, "production")
end
create_params_file(template_path, env) click to toggle source
# File lib/lono/pro/importer/base.rb, line 31
def create_params_file(template_path, env)
  params_path = if @blueprint != @template
                  "configs/#{@blueprint}/params/#{env}/#{@template}.txt"
                else
                  "configs/#{@blueprint}/params/#{env}.txt"
                end
  params = Params.new(template_path, params_path)
  params.create
end
pretty_path(path) click to toggle source

removes the ./ at the beginning if it's there in the path

# File lib/lono/pro/importer/base.rb, line 42
def pretty_path(path)
  path.sub("#{Lono.root}/",'')
end
summarize() click to toggle source
# File lib/lono/pro/importer/base.rb, line 20
def summarize
  return unless @options[:summary]
  puts "Template Summary:"
  Lono::Inspector::Summary.new(@blueprint, @template, @options).run
end