Class: Ella::Template
- Inherits:
-
Object
- Object
- Ella::Template
- Defined in:
- lib/ella/template.rb
Overview
Class to handle naming, copying, and processing the various templates that the Ella generators use.
Constant Summary collapse
- TEMPLATE_DIRECTORY =
File.('../../templates', __dir__)
Instance Method Summary collapse
-
#initialize(filename, generic_template: nil, template_vars: nil) ⇒ Template
constructor
If generic_template is nil, this class will look for a specific template based on the filename.
- #write ⇒ Object
Constructor Details
#initialize(filename, generic_template: nil, template_vars: nil) ⇒ Template
If generic_template is nil, this class will look for a specific template based on the filename.
12 13 14 15 16 17 |
# File 'lib/ella/template.rb', line 12 def initialize(filename, generic_template: nil, template_vars: nil) @filename = filename @destination = File.join(Dir.pwd, @filename) @generic_template = generic_template @template_vars = template_vars end |
Instance Method Details
#write ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/ella/template.rb', line 19 def write Log.create(@filename) if file_exists? Log.error('File already exists. Skipping.') else File.open(@destination, 'w') { |f| f.write(data) } end end |