Class: EasyAb::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- EasyAb::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/easy_ab/install_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
Instance Method Summary collapse
-
#copy_initializer_file ⇒ Object
def copy_config template ‘easy_ab.yml’, ‘config/easy_ab.yml’ end.
- #copy_migration ⇒ Object
- #migration_version ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
8 9 10 11 12 13 14 15 |
# File 'lib/generators/easy_ab/install_generator.rb', line 8 def self.next_migration_number(dirname) next_migration_number = current_migration_number(dirname) + 1 if ::ActiveRecord::Base. [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max else "%.3d" % next_migration_number end end |
Instance Method Details
#copy_initializer_file ⇒ Object
def copy_config
template 'easy_ab.yml', 'config/easy_ab.yml'
end
31 32 33 |
# File 'lib/generators/easy_ab/install_generator.rb', line 31 def copy_initializer_file copy_file 'easy_ab.rb', 'config/initializers/easy_ab.rb' end |
#copy_migration ⇒ Object
23 24 25 |
# File 'lib/generators/easy_ab/install_generator.rb', line 23 def copy_migration migration_template 'grouping.rb', 'db/migrate/create_easy_ab_groupings.rb', migration_version: migration_version end |
#migration_version ⇒ Object
17 18 19 20 21 |
# File 'lib/generators/easy_ab/install_generator.rb', line 17 def migration_version if ActiveRecord::VERSION::MAJOR >= 5 "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" end end |