class DiceBag::TemplateFile
Public Class Methods
new(name)
click to toggle source
# File lib/dice_bag/template_file.rb, line 16 def initialize(name) @filename = File.basename(name) @file = Project.config_files(name) end
Public Instance Methods
create_file(config_file, params)
click to toggle source
# File lib/dice_bag/template_file.rb, line 21 def create_file(config_file, params) # By passing "<>" we're trimming trailing newlines on lines that are # nothing but ERB blocks (see documentation). This is useful for files # like mauth_key where we want to control newlines carefully. template = ERB.new(File.read(@file), nil, "<>") # 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