Class: SpreeRedirects::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- SpreeRedirects::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/spree_redirects/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.count ⇒ Object
7 8 9 10 |
# File 'lib/generators/spree_redirects/install_generator.rb', line 7 def self.count @count ||= 0 (@count += 1) * 3 end |
.new_migration_number ⇒ Object
12 13 14 |
# File 'lib/generators/spree_redirects/install_generator.rb', line 12 def self.new_migration_number (Time.new.utc + self.count).strftime("%Y%m%d%H%M%S") end |
.next_migration_number(path) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/generators/spree_redirects/install_generator.rb', line 16 def self.next_migration_number(path) @time ||= Time.new.utc if ActiveRecord::Base. files = Dir.entries(Rails.root.join("db/migrate")) migration = new_migration_number while files.join.include?(migration) migration = new_migration_number end migration else "%.3d" % (current_migration_number(dirname) + 1) end end |
Instance Method Details
#copy_migrations ⇒ Object
33 34 35 |
# File 'lib/generators/spree_redirects/install_generator.rb', line 33 def copy_migrations migration_template "db/migrate/create_redirects.rb", "db/migrate/create_redirects.rb" end |