Class: RubygemsHerald::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- RubygemsHerald::InstallGenerator
- Includes:
- Rails::Generators::Migration, Generators::Utils
- Defined in:
- lib/generators/rubygems_herald/install/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#add_initializer ⇒ Object
all public methods in here will be run in order.
- #add_migrations ⇒ Object
- #hello ⇒ Object
Methods included from Generators::Utils
Class Method Details
.next_migration_number(dirname) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/rubygems_herald/install/install_generator.rb', line 25 def self.next_migration_number(dirname) if ActiveRecord::Base. 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 else "%.3d" % (current_migration_number(dirname) + 1) end end |
Instance Method Details
#add_initializer ⇒ Object
all public methods in here will be run in order
14 15 16 17 |
# File 'lib/generators/rubygems_herald/install/install_generator.rb', line 14 def add_initializer output "To start with, you'll need an initializer. This is where you put your configuration options.", :magenta template "initializer.rb", "config/initializers/rubygems_herald.rb" end |
#add_migrations ⇒ Object
19 20 21 22 23 |
# File 'lib/generators/rubygems_herald/install/install_generator.rb', line 19 def add_migrations unless ActiveRecord::Base.connection.table_exists? 'gems' migration_template 'migrate/create_gem_displays_table.rb', 'db/migrate/create_gem_displays_table.rb' rescue output $!. end end |
#hello ⇒ Object
8 9 10 |
# File 'lib/generators/rubygems_herald/install/install_generator.rb', line 8 def hello output "Rubygems Herald is ready to announce your gems in style.", :magenta end |