Class: Vessel::Templator

Inherits:
Object
  • Object
show all
Defined in:
lib/vessel/templator.rb

Constant Summary collapse

TEMPLATES =
"templates/*.erb"

Instance Method Summary collapse

Constructor Details

#initialize(domain, options) ⇒ Templator

Returns a new instance of Templator.



7
8
9
10
11
# File 'lib/vessel/templator.rb', line 7

def initialize(domain, options)
  @domain = domain
  @options = options
  @class_name = @domain.gsub("-", ".dash.").split(".").map(&:capitalize).join
end

Instance Method Details

#buildObject



13
14
15
16
17
18
19
20
# File 'lib/vessel/templator.rb', line 13

def build
  abort "Template #{template_path} not found" unless File.file?(template_path)

  file = File.read(template_path)
  evaluated = ERB.new(file).result(binding)
  Logger.debug("Templator: creating file #{store_path}")
  File.write(store_path, evaluated)
end