Class: Angarium::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Angarium::Generators::InstallGenerator
- Defined in:
- lib/generators/angarium/install/install_generator.rb
Instance Method Summary collapse
- #copy_initializer ⇒ Object
-
#install_migrations ⇒ Object
The single migration path: delegate to the migrations generator, which installs into db/NAME_migrate (multi-db) or db/migrate (primary).
- #print_next_steps ⇒ Object
-
#set_database_config ⇒ Object
With --database, record config.database in the initializer so a later
angarium:migrationsrun (e.g. after a gem upgrade) still targets the right place without the flag.
Instance Method Details
#copy_initializer ⇒ Object
15 16 17 |
# File 'lib/generators/angarium/install/install_generator.rb', line 15 def copy_initializer template "initializer.rb", "config/initializers/angarium.rb" end |
#install_migrations ⇒ Object
The single migration path: delegate to the migrations generator, which installs into db/NAME_migrate (multi-db) or db/migrate (primary).
31 32 33 |
# File 'lib/generators/angarium/install/install_generator.rb', line 31 def install_migrations invoke "angarium:migrations", [], database: database end |
#print_next_steps ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/generators/angarium/install/install_generator.rb', line 35 def print_next_steps if database say <<~MSG Add the '#{database}' database to config/database.yml (per environment), e.g.: #{database}: <<: *default database: myapp_#{database} migrations_paths: db/#{database}_migrate then run: bin/rails db:migrate:#{database} MSG else say "\nNext: run bin/rails db:migrate" end end |
#set_database_config ⇒ Object
With --database, record config.database in the initializer so a later
angarium:migrations run (e.g. after a gem upgrade) still targets the
right place without the flag.
22 23 24 25 26 27 |
# File 'lib/generators/angarium/install/install_generator.rb', line 22 def set_database_config return unless database gsub_file "config/initializers/angarium.rb", /^\s*#?\s*config\.database\s*=.*$/, %( config.database = :#{database}) end |