Class: DiceBag::TemplateFile

Inherits:
Object
  • Object
show all
Includes:
DiceBagFile, TemplateHelpers
Defined in:
lib/dice_bag/template_file.rb

Instance Attribute Summary

Attributes included from DiceBagFile

#destination, #file, #filename

Instance Method Summary collapse

Methods included from TemplateHelpers

#default_root_ca, #ensure_is_509_certificate, #ensure_is_private_key, #generate_509_certificate, #generate_private_key, #generate_root_ca

Methods included from DiceBagFile

#assert_existence, #should_write?, #write

Constructor Details

#initialize(name) ⇒ TemplateFile

Returns a new instance of TemplateFile.



16
17
18
19
# File 'lib/dice_bag/template_file.rb', line 16

def initialize(name)
  @filename = File.basename(name)
  @file = Project.config_files(name)
end

Instance Method Details

#create_file(config_file, params) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dice_bag/template_file.rb', line 21

def create_file(config_file, params)
  # templates expect a configured object
  configured = Configuration.new
  warning = Warning.new(@filename)
  contents = template.result(binding)

  return unless params[:deploy] || config_file.should_write?(contents)

  config_file.write(contents)
  puts "File '#{config_file.file}' created"
end