Class: StepperMotor::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- StepperMotor::InstallGenerator
- Includes:
- ActiveRecord::Generators::Migration
- Defined in:
- lib/generators/install_generator.rb
Overview
The generator is used to install StepperMotor. It adds an example Journey, a configing
initializer and the migration that creates tables.
Run it with bin/rails g stepper_motor:install
in your console.
Instance Method Summary collapse
-
#create_migration_file ⇒ Object
Generates monolithic migration file that contains all database changes.
Instance Method Details
#create_migration_file ⇒ Object
Generates monolithic migration file that contains all database changes.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/install_generator.rb', line 17 def create_migration_file # Migration files are named "...migration_001.rb" etc. This allows them to be emitted # as they get added, and the order of the migrations can be controlled using predictable sorting. # Adding a new migration to the gem is then just adding a file. migration_file_paths_in_order = Dir.glob(__dir__ + "/*_migration_*.rb.erb").sort migration_file_paths_in_order.each do |migration_template_path| untemplated_migration_filename = File.basename(migration_template_path).gsub(/\.erb$/, "") migration_template(migration_template_path, File.join(db_migrate_path, untemplated_migration_filename)) end end |