Class: Wizard::Spells::CompileTemplate

Inherits:
MakeFile show all
Defined in:
lib/wizard/spells/compile_template.rb

Constant Summary

Constants included from Helpers

Helpers::COLORS

Instance Attribute Summary collapse

Attributes inherited from MakeFile

#chmod, #content, #filename

Instance Method Summary collapse

Methods inherited from MakeFile

#create_file!, #identical_content?

Methods inherited from Base

all_forced?, attr_status, #force!, force_all!, #force_all!, #forced?, #status, #status?

Methods included from Helpers

#adjust, #colorize, #console_width, #print, #say, #say!

Constructor Details

#initialize(filename, template, options = {}) ⇒ CompileTemplate

Returns a new instance of CompileTemplate.



10
11
12
13
# File 'lib/wizard/spells/compile_template.rb', line 10

def initialize(filename, template, options={})
  super(filename, nil, options)
  @template = template
end

Instance Attribute Details

#templateObject (readonly)

Returns the value of attribute template.



8
9
10
# File 'lib/wizard/spells/compile_template.rb', line 8

def template
  @template
end

Instance Method Details

#perform_with_template_compilationObject Also known as: perform



15
16
17
18
19
20
# File 'lib/wizard/spells/compile_template.rb', line 15

def perform_with_template_compilation
  @content = ERB.new(File.read(template)).result(binding)
  perform_without_template_compilation
rescue Object
  error!
end