Class: WagonGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/wagon/wagon_generator.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ WagonGenerator

Returns a new instance of WagonGenerator.



6
7
8
9
10
# File 'lib/generators/wagon/wagon_generator.rb', line 6

def initialize(*args)
  super
  @wagon_name = name
  assign_names!("#{application_name}_#{name}")
end

Instance Attribute Details

#wagon_nameObject (readonly)

Returns the value of attribute wagon_name.



2
3
4
# File 'lib/generators/wagon/wagon_generator.rb', line 2

def wagon_name
  @wagon_name
end

Instance Method Details

#copy_templatesObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/generators/wagon/wagon_generator.rb', line 12

def copy_templates
  self.destination_root = "vendor/wagons/#{wagon_name}"

  # do this whole manual traversal to be able to replace every single file
  # individually in the application.
  all_templates.each do |file|
    if File.basename(file) == '.empty_directory'
      file = File.dirname(file)
      directory(file, File.join(destination_root, file))
    else
      template(file, File.join(destination_root, file.sub(/\.tt$/, '')))
    end
  end
end