Class: Kryo::Generators::Base
- Inherits:
-
Object
- Object
- Kryo::Generators::Base
- Defined in:
- lib/kryo/generators/base.rb
Overview
The base class for all generators to inherit from.
Direct Known Subclasses
Class Method Summary collapse
-
.create(src, destination, options = {}, &block) ⇒ Boolean
Creates a file based off of the template provided.
Class Method Details
.create(src, destination, options = {}, &block) ⇒ Boolean
Creates a file based off of the template provided.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kryo/generators/base.rb', line 17 def self.create src, destination, ={}, &block paths = File.split(src) template_name = paths.last template_path = paths.first path = File.join(File.dirname(__FILE__), template_path, "#{template_name}.erb") yield if block erb = ERB.new(File.read(path)) output = File.join(destination, [:name] || template_name) file = File.open(output, 'w+') file.write(erb.result(binding)) file.close true end |