Class: Rdm::CLI::TemplateGenerator
- Inherits:
-
Object
- Object
- Rdm::CLI::TemplateGenerator
- Defined in:
- lib/rdm/cli/template_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(template_name:, current_path:, local_path:, locals:) ⇒ TemplateGenerator
constructor
A new instance of TemplateGenerator.
- #run ⇒ Object
Constructor Details
#initialize(template_name:, current_path:, local_path:, locals:) ⇒ TemplateGenerator
Returns a new instance of TemplateGenerator.
15 16 17 18 19 20 |
# File 'lib/rdm/cli/template_generator.rb', line 15 def initialize(template_name:, current_path:, local_path:, locals:) @template_name = template_name @current_path = current_path @local_path = local_path @locals = locals end |
Class Method Details
.run(template_name:, current_path:, local_path:, locals:) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/rdm/cli/template_generator.rb', line 5 def run(template_name:, current_path:, local_path:, locals:) TemplateGenerator.new( template_name: template_name, current_path: current_path, local_path: local_path, locals: locals ).run end |
Instance Method Details
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rdm/cli/template_generator.rb', line 22 def run Rdm::Handlers::TemplateHandler.generate( template_name: @template_name, current_path: @current_path, local_path: @local_path, locals: @locals ) rescue Rdm::Errors::TemplateDoesNotExist puts "Template '#{@template_name}' does not exist. Create new at #{File.join(@current_path, '.rdm/templates/', @template_name)} folder" rescue Rdm::Errors::SourceFileDoesNotExist => e puts e. rescue Rdm::Errors::TemplateFileExists => e puts "File #{e.} already exists. Try to user another variable name" end |