Class: Lotus::Generators::Generator

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/lotus/generators/generator.rb

Overview

Since:

  • 0.1.0

Defined Under Namespace

Classes: Processor

Instance Method Summary collapse

Constructor Details

#initialize(template_source_path, target_path) ⇒ Generator

Returns a new instance of Generator.

Since:

  • 0.1.0



16
17
18
19
20
21
22
# File 'lib/lotus/generators/generator.rb', line 16

def initialize(template_source_path, target_path)
  @template_source_path = template_source_path
  @target_path = target_path
  @template_mappings = []
  @processor = Processor.new
  @processor.class.source_root(@template_source_path)
end

Instance Method Details

#add_mapping(source, target) ⇒ Object

Since:

  • 0.1.0



24
25
26
# File 'lib/lotus/generators/generator.rb', line 24

def add_mapping(source, target)
  @template_mappings << [source, target]
end

#process_templates(options = {}) ⇒ Object

Since:

  • 0.1.0



28
29
30
31
32
# File 'lib/lotus/generators/generator.rb', line 28

def process_templates(options = {})
  @template_mappings.each do |src, dst|
    @processor.template(@template_source_path.join(src), @target_path.join(dst), options)
  end
end