Class: TurkeeGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object

Implement the required interface for Rails::Generators::Migration. taken from github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb



9
10
11
# File 'lib/generators/turkee/turkee_generator.rb', line 9

def self.next_migration_number(dirname)
  Time.now.utc.strftime("%Y%m%d%H%M%S")
end

Instance Method Details

#create_initializerObject



17
18
19
# File 'lib/generators/turkee/turkee_generator.rb', line 17

def create_initializer
  template "turkee.rb", "config/initializers/turkee.rb"
end

#create_migrationsObject



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

def create_migrations
  migration_template "turkee_migration.rb.erb", "db/migrate/create_turkee_tasks.rb"
  
  # Need this sleep so that we don't get the same migration timestamp for both migrations
  sleep 1
  
  migration_template "turkee_imported_assignments.rb.erb", "db/migrate/create_turkee_imported_assignments.rb"
end