Class: MagicLocales::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- MagicLocales::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/magic_locales/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #copy_country_seeds ⇒ Object
- #copy_mgca_initialitzer ⇒ Object
- #copy_mgca_routes ⇒ Object
- #copy_migrations ⇒ Object
- #create_seeds_folder ⇒ Object
Class Method Details
.next_migration_number(path) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/generators/magic_locales/install_generator.rb', line 11 def self.next_migration_number(path) unless @prev_migration_nr @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i else @prev_migration_nr += 1 end @prev_migration_nr.to_s end |
Instance Method Details
#copy_country_seeds ⇒ Object
29 30 31 |
# File 'lib/generators/magic_locales/install_generator.rb', line 29 def copy_country_seeds copy_file( "locale_seeds.rb", "db/seeds/locales.rb" ) end |
#copy_mgca_initialitzer ⇒ Object
34 35 36 |
# File 'lib/generators/magic_locales/install_generator.rb', line 34 def copy_mgca_initialitzer copy_file( "magic_initializer.rb", "config/initializers/magic_logales.rb" ) end |
#copy_mgca_routes ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/generators/magic_locales/install_generator.rb', line 39 def copy_mgca_routes route "\n scope :mgclang, module: :magic_locales do\n resources :locales do\nget \"trigger/:state\", action: :trigger, on: :member, as: :trigger\n end\n get \"/\" => \"locales#index\"\n end\n get \"/change-locale/:locale\", controller: \"magic_locales/locales\", action: :change_locale, as: :change_locale\n\n ROUTE\nend\n" |
#copy_migrations ⇒ Object
20 21 22 |
# File 'lib/generators/magic_locales/install_generator.rb', line 20 def copy_migrations migration_template( "magic_logales_migration.rb", "db/migrate/add_magic_locales.rb" ) end |
#create_seeds_folder ⇒ Object
24 25 26 |
# File 'lib/generators/magic_locales/install_generator.rb', line 24 def create_seeds_folder empty_directory( "db/seeds" ) end |