Class: PhrasingGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- PhrasingGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/phrasing/phrasing_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_helper_file ⇒ Object
- #create_initializer_file ⇒ Object
- #create_migrations ⇒ Object
- #migration_version ⇒ Object
- #rails_major_version ⇒ Object
Class Method Details
.next_migration_number(path) ⇒ Object
22 23 24 25 |
# File 'lib/generators/phrasing/phrasing_generator.rb', line 22 def self.next_migration_number(path) sleep 1 # migration numbers should differentiate Time.now.utc.strftime("%Y%m%d%H%M%S") end |
Instance Method Details
#create_helper_file ⇒ Object
10 11 12 13 |
# File 'lib/generators/phrasing/phrasing_generator.rb', line 10 def create_helper_file helper_location = "app/helpers/phrasing_helper.rb" copy_file helper_location, helper_location end |
#create_initializer_file ⇒ Object
5 6 7 8 |
# File 'lib/generators/phrasing/phrasing_generator.rb', line 5 def create_initializer_file initializer_location = "config/initializers/phrasing.rb" copy_file initializer_location, initializer_location end |
#create_migrations ⇒ Object
15 16 17 18 19 20 |
# File 'lib/generators/phrasing/phrasing_generator.rb', line 15 def create_migrations phrasing_phrase_migration = "db/migrate/create_phrasing_phrases.rb" migration_template phrasing_phrase_migration, phrasing_phrase_migration phrase_versions_migration = "db/migrate/create_phrasing_phrase_versions.rb" migration_template phrase_versions_migration, phrase_versions_migration end |
#migration_version ⇒ Object
27 28 29 |
# File 'lib/generators/phrasing/phrasing_generator.rb', line 27 def migration_version "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if rails_major_version >= 5 end |
#rails_major_version ⇒ Object
31 32 33 |
# File 'lib/generators/phrasing/phrasing_generator.rb', line 31 def rails_major_version Rails.version.first.to_i end |