Class: Spleen::Generators::InstallGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object

Taken from ActiveRecord’s migration generator



30
31
32
33
34
35
36
# File 'lib/generators/spleen/install_generator.rb', line 30

def self.next_migration_number(dirname) #:nodoc:
  if ActiveRecord::Base.timestamped_migrations
    Time.now.utc.strftime("%Y%m%d%H%M%S")
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

Instance Method Details

#copy_localeObject



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

def copy_locale
  copy_file "locales.en.yml", "config/locales/ratings.en.yml"
end

#copy_modelObject



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

def copy_model
  template "model.rb", "app/models/rating.rb"
end

#copy_rating_migrationObject



21
22
23
# File 'lib/generators/spleen/install_generator.rb', line 21

def copy_rating_migration
  migration_template "migration.rb", "db/migrate/create_ratings"
end

#show_readmeObject



25
26
27
# File 'lib/generators/spleen/install_generator.rb', line 25

def show_readme
  readme "README" if behavior == :invoke
end