Sha256: da76596d6901a11616365e67e575aa21538aeacda182099c4701bab28977c274
Contents?: true
Size: 1.31 KB
Versions: 4
Compression:
Stored size: 1.31 KB
Contents
# frozen_string_literal: true require "colorize" require "date" require "erb" require "fileutils" TEMPLATES_DIRECTORY = File.expand_path("../../templates", __FILE__) module Spout module Helpers # Helpers to generate and update Spout dictionary framework. module Framework 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".colorize(:green) + " #{file_name}" FileUtils.copy(template_file_path, file_path) end 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".colorize(:green) + " #{file_name}" ensure file_out.close if file_out end def directory(directory_name) directory_path = File.join(@full_path, directory_name) puts " create".colorize(:green) + " #{directory_name}" FileUtils.mkpath(directory_path) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems