Class: Lono::Template::Generator

Inherits:
Object
  • Object
show all
Includes:
Blueprint::Root
Defined in:
lib/lono/template/generator.rb

Instance Method Summary collapse

Methods included from Blueprint::Root

#bundler_groups, #find_blueprint_root, #require_bundle_gems, #set_blueprint_root

Constructor Details

#initialize(blueprint, options = {}) ⇒ Generator

Returns a new instance of Generator.



7
8
9
10
11
12
# File 'lib/lono/template/generator.rb', line 7

def initialize(blueprint, options={})
  @blueprint, @options = blueprint, options
  @template = @options[:template] || @blueprint
  Lono::ProjectChecker.check
  set_blueprint_root(@blueprint)
end

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
# File 'lib/lono/template/generator.rb', line 14

def run
  # Examples:
  #   Erb.new(b, options.clone).run
  #   Dsl.new(b, options.clone).run
  generator_class = "Lono::Template::#{template_type.classify}"
  generator_class = Object.const_get(generator_class)
  generator_class.new(@blueprint, @options.clone).run
end

#template_typeObject



23
24
25
26
27
# File 'lib/lono/template/generator.rb', line 23

def template_type
  meta_config = "#{Lono.blueprint_root}/.meta/config.yml"
  data = YAML.load_file(meta_config)
  data["template_type"] || "dsl"
end