Class: Bookmarker::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Bookmarker::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/bookmarker/install_generator.rb,
lib/generators/bookmarker/bookmarker_generator.rb
Class Method Summary collapse
- .next_migration_number(dirname) ⇒ Object
- .orm ⇒ Object
- .orm_has_migration? ⇒ Boolean
- .source_root ⇒ Object
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/generators/bookmarker/install_generator.rb', line 21 def self.next_migration_number(dirname) if ActiveRecord::Base. Time.new.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end |
.orm ⇒ Object
13 14 15 |
# File 'lib/generators/bookmarker/install_generator.rb', line 13 def self.orm Rails::Generators.[:rails][:orm] end |
.orm_has_migration? ⇒ Boolean
17 18 19 |
# File 'lib/generators/bookmarker/install_generator.rb', line 17 def self.orm_has_migration? [:active_record].include? orm end |
.source_root ⇒ Object
17 18 19 |
# File 'lib/generators/bookmarker/bookmarker_generator.rb', line 17 def self.source_root File.join(File.dirname(__FILE__), 'templates', (orm.to_s unless orm.class.eql?(String)) ) end |
Instance Method Details
#copy_migration ⇒ Object
29 30 31 |
# File 'lib/generators/bookmarker/install_generator.rb', line 29 def copy_migration migration_template 'migration.rb', 'db/migrate/create_bookmarks_table.rb' end |
#create_migration_file ⇒ Object
33 34 35 |
# File 'lib/generators/bookmarker/bookmarker_generator.rb', line 33 def create_migration_file migration_template 'migration.rb', 'db/migrate/create_bookmarks_table.rb' end |