class EasyAb::Generators::InstallGenerator

Public Class Methods

next_migration_number(dirname) click to toggle source

Implement the required interface for Rails::Generators::Migration.

# 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.timestamped_migrations
    [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
  else
    "%.3d" % next_migration_number
  end
end

Public Instance Methods

copy_initializer_file() click to toggle source

def copy_config

template 'easy_ab.yml', 'config/easy_ab.yml'

end

# 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() click to toggle source
# 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() click to toggle source
# 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