Module: Luban::Deployment::Helpers::Generator::Utils
- Included in:
- Base
- Defined in:
- lib/luban/deployment/helpers/generator.rb
Instance Method Summary collapse
- #copy_file(src_path, dst_path) ⇒ Object
- #mkdir(path) ⇒ Object
- #render_file(template_path, output_path, context: binding) ⇒ Object
Instance Method Details
#copy_file(src_path, dst_path) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/luban/deployment/helpers/generator.rb', line 19 def copy_file(src_path, dst_path) if dst_path.file? puts " [skipped]" else FileUtils.cp(src_path, dst_path) puts " [created]" end end |
#mkdir(path) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/luban/deployment/helpers/generator.rb', line 10 def mkdir(path) if path.directory? puts " [skipped]" else FileUtils.mkdir(path) puts " [created]" end end |
#render_file(template_path, output_path, context: binding) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/luban/deployment/helpers/generator.rb', line 28 def render_file(template_path, output_path, context: binding) if output_path.file? puts " [skipped]" else require 'erb' File.open(output_path, 'w') do |f| f.write ERB.new(File.read(template_path), nil, '<>').result(context) end puts " [created]" end end |