Class: Shrew::Generators::InstallGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/generators/shrew/install_generator.rb', line 21

def self.next_migration_number(path)
  unless @prev_migration_nr
    @prev_migration_nr = Time.now.utc.strftime('%Y%m%d%H%M%S').to_i
  else
    @prev_migration_nr += 1
  end
  @prev_migration_nr.to_s
end

Instance Method Details

#add_routesObject



17
18
19
# File 'lib/generators/shrew/install_generator.rb', line 17

def add_routes
  route "mount Shrew::Engine => '/shrew', as: 'shrew'"
end

#copy_initializerObject



9
10
11
# File 'lib/generators/shrew/install_generator.rb', line 9

def copy_initializer
  template 'shrew.rb', 'config/initializers/shrew.rb'
end

#copy_migrationObject



13
14
15
# File 'lib/generators/shrew/install_generator.rb', line 13

def copy_migration
  migration_template 'page_view_migration.rb', 'db/migrate/add_shrew_page_view_table.rb'
end