Module: Nezu::Generators
- Included in:
- Application::AppGenerator
- Defined in:
- lib/nezu/generators.rb,
lib/nezu/generators/application/app_generator.rb
Defined Under Namespace
Modules: Application
Instance Method Summary collapse
Instance Method Details
#template_to(filename) ⇒ Object
e.g. “config/amqp.yml”
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/nezu/generators.rb', line 11 def template_to(filename) # e.g. "config/amqp.yml" dirname = File.join(Nezu::Config.destination_root, File.dirname(filename)) source_file = find_template(filename) if source_file FileUtils.mkdir_p(dirname) if Nezu::Config.file_suffixes.include?(source_file.split('.')[-1]) e = ERB.new(File.read(source_file)) File.open(File.join(Nezu::Config.destination_root, filename.sub(/\.tt$/,'')), File::CREAT|File::TRUNC|File::WRONLY) do |f| f.write(e.result(Nezu::Config.binding)) end else FileUtils.cp(source_file, dirname) end end end |