Class: Lono::Template::Generator

Inherits:
AbstractBase show all
Defined in:
lib/lono/template/generator.rb

Instance Method Summary collapse

Methods inherited from AbstractBase

#initialize, #reinitialize, #template_path

Methods included from Blueprint::Root

#find_blueprint_root, #set_blueprint_root

Constructor Details

This class inherits a constructor from Lono::AbstractBase

Instance Method Details

#inject_configsetsObject



26
27
28
29
# File 'lib/lono/template/generator.rb', line 26

def inject_configsets
  Lono::Configset::Preparer.new(@options).run # register and materialize gems
  ConfigsetInjector.new(@options).run
end

#runObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/lono/template/generator.rb', line 5

def run
  # Examples:
  #   Erb.new(b, options.dup).run
  #   Dsl.new(b, options.dup).run
  generator_class = "Lono::Template::Strategy::#{template_type.camelize}"
  generator_class = Object.const_get(generator_class)
  generator_class.new(@options).run
  # The generator strategy class writes template to disk. The inject_configsets reads it back from disk.
  # Leaving as-is instead of reading all in memory in case there's a reason.
  inject_configsets
end

#template_typeObject



17
18
19
20
21
22
23
24
# File 'lib/lono/template/generator.rb', line 17

def template_type
  if @options[:source]
    "source"
  else
    jadespec = Lono::Jadespec.new(Lono.blueprint_root, "unknown") # abusing Jadespec to get template_type
    jadespec.template_type
  end
end