module Spout::Helpers::Framework

Helpers to generate and update Spout dictionary framework.

Public Instance Methods

copy_file(template_file, file_name = "") click to toggle source
# File lib/spout/helpers/framework.rb, line 13
def copy_file(template_file, file_name = "")
  file_name = template_file if file_name == ""
  file_path = File.join(@full_path, file_name)
  template_file_path = File.join(TEMPLATES_DIRECTORY, template_file)
  puts "      create".green + "  #{file_name}"
  FileUtils.copy(template_file_path, file_path)
end
directory(directory_name) click to toggle source
# File lib/spout/helpers/framework.rb, line 32
def directory(directory_name)
  directory_path = File.join(@full_path, directory_name)
  puts "      create".green + "  #{directory_name}"
  FileUtils.mkpath(directory_path)
end
evaluate_file(template_file, file_name) click to toggle source
# File lib/spout/helpers/framework.rb, line 21
def evaluate_file(template_file, file_name)
  template_file_path = File.join(TEMPLATES_DIRECTORY, template_file)
  template = ERB.new(File.read(template_file_path))
  file_path = File.join(@full_path, file_name)
  file_out = File.new(file_path, "w")
  file_out.syswrite(template.result(binding))
  puts "      create".green + "  #{file_name}"
ensure
  file_out.close if file_out
end