Module: Spout::Helpers::Framework
- Included in:
- Commands::ProjectGenerator, Commands::Update
- Defined in:
- lib/spout/helpers/framework.rb
Overview
Helpers to generate and update Spout dictionary framework.
Instance Method Summary collapse
- #copy_file(template_file, file_name = "") ⇒ Object
- #directory(directory_name) ⇒ Object
- #evaluate_file(template_file, file_name) ⇒ Object
Instance Method Details
#copy_file(template_file, file_name = "") ⇒ Object
13 14 15 16 17 18 19 |
# 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) ⇒ Object
32 33 34 35 36 |
# 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) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# 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 |