Class: USA::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/generators/usa/install/install_generator.rb

Overview

Everything installing this gem writes into a host: the migrations that make its tables and fill them. Not an initializer, because there is nothing here to configure.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_paths ⇒ Array<String>

Returns where a file being copied is looked for.

Returns:

  • (Array<String>) —

    where a file being copied is looked for.



15
# File 'lib/generators/usa/install/install_generator.rb', line 15

def self.source_paths = [ USA::Engine.root.join('db/migrate').to_s ]

Instance Method Details

#copy_migrations ⇒ void

This method returns an undefined value.

Copied rather than read off the gem, so the host owns the files and their timestamps.



19
20
21
22
23
# File 'lib/generators/usa/install/install_generator.rb', line 19

def copy_migrations
  Dir.children(USA::Engine.root.join('db/migrate')).sort.each do |name|
    migration_template name, "db/migrate/#{name.split('_', 2).last}"
  end
end