Class: Sufia::Models::Upgrade400Generator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Sufia::Models::Upgrade400Generator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/sufia/models/upgrade400_generator.rb
Class Method Summary collapse
-
.next_migration_number(path) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
Instance Method Summary collapse
-
#add_analytics_config ⇒ Object
Add config file for Google Analytics.
- #banner ⇒ Object
-
#copy_migrations ⇒ Object
Setup the database migrations.
-
#full_text_indexing ⇒ Object
Sets up full-text indexing (Solr config + jars).
-
#inject_analytics_initializer ⇒ Object
Add Google Analytics option to Sufia config.
-
#install_mailboxer ⇒ Object
Upgrade mailboxer.
Class Method Details
.next_migration_number(path) ⇒ Object
Implement the required interface for Rails::Generators::Migration. taken from github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/generators/sufia/models/upgrade400_generator.rb', line 21 def self.next_migration_number(path) if @prev_migration_nr @prev_migration_nr += 1 else if last_migration = Dir[File.join(path, '*.rb')].sort.last @prev_migration_nr = last_migration.sub(File.join(path, '/'), '').to_i + 1 else @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i end end @prev_migration_nr.to_s end |
Instance Method Details
#add_analytics_config ⇒ Object
Add config file for Google Analytics
57 58 59 |
# File 'lib/generators/sufia/models/upgrade400_generator.rb', line 57 def add_analytics_config copy_file 'config/analytics.yml', 'config/analytics.yml' end |
#banner ⇒ Object
34 35 36 |
# File 'lib/generators/sufia/models/upgrade400_generator.rb', line 34 def say_status("warning", "UPGRADING SUFIA MODELS", :yellow) end |
#copy_migrations ⇒ Object
Setup the database migrations
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/generators/sufia/models/upgrade400_generator.rb', line 39 def copy_migrations # Can't get this any more DRY, because we need this order. [ 'create_tinymce_assets.rb', 'create_content_blocks.rb', 'create_featured_works.rb' ].each do |file| better_migration_template file end end |
#full_text_indexing ⇒ Object
Sets up full-text indexing (Solr config + jars)
72 73 74 |
# File 'lib/generators/sufia/models/upgrade400_generator.rb', line 72 def full_text_indexing generate "sufia:models:fulltext" end |
#inject_analytics_initializer ⇒ Object
Add Google Analytics option to Sufia config
62 63 64 65 66 67 68 69 |
# File 'lib/generators/sufia/models/upgrade400_generator.rb', line 62 def inject_analytics_initializer inject_into_file 'config/initializers/sufia.rb', after: /^Sufia\.config do.*$/ do "\n # Enable displaying usage statistics in the UI\n" + " # Defaults to FALSE\n" + " # Requires a Google Analytics id and OAuth2 keyfile. See README for more info\n" + " #config.analytics = false\n" end end |
#install_mailboxer ⇒ Object
Upgrade mailboxer
51 52 53 54 |
# File 'lib/generators/sufia/models/upgrade400_generator.rb', line 51 def install_mailboxer generate "mailboxer:namespacing_compatibility" generate "mailboxer:install -s" end |