Class: Sufia::Upgrade400Generator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Sufia::Upgrade400Generator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/sufia/upgrade400_generator.rb
Instance Method Summary collapse
- #banner ⇒ Object
- #blacklight_marc ⇒ Object
- #copy_helper ⇒ Object
-
#inject_sufia_controller_behavior ⇒ Object
Add Sufia behaviors to the catalog controller.
- #insert_abilities ⇒ Object
- #install_blacklight_gallery ⇒ Object
- #remove_blacklight_scss ⇒ Object
- #tinymce_config ⇒ Object
-
#update_root_route ⇒ Object
The engine routes have to come after the devise routes so that /users/sign_in will work.
- #upgrade_sufia_models ⇒ Object
Instance Method Details
#banner ⇒ Object
23 24 25 |
# File 'lib/generators/sufia/upgrade400_generator.rb', line 23 def say_status("warning", "UPGRADING SUFIA", :yellow) end |
#blacklight_marc ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/generators/sufia/upgrade400_generator.rb', line 69 def blacklight_marc file_path = 'app/models/solr_document.rb' return unless File.exists?(file_path) && file_contains?('app/models/solr_document.rb', 'Blacklight::Solr::Document::Marc') && !file_contains?('Gemfile', 'blacklight-marc') insert_into_file 'Gemfile', after: /gem 'sufia'.*$/ do "\ngem 'blacklight-marc'" end Bundler.with_clean_env do run 'bundle install' end end |
#copy_helper ⇒ Object
53 54 55 |
# File 'lib/generators/sufia/upgrade400_generator.rb', line 53 def copy_helper copy_file 'sufia_helper.rb', 'app/helpers/sufia_helper.rb' end |
#inject_sufia_controller_behavior ⇒ Object
Add Sufia behaviors to the catalog controller
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/generators/sufia/upgrade400_generator.rb', line 40 def inject_sufia_controller_behavior controller_name = "CatalogController" file_path = "app/controllers/catalog_controller.rb" if File.exists?(file_path) insert_into_file file_path, after: 'include Hydra::Controller::ControllerBehavior' do "\n # Adds Sufia behaviors to the catalog controller\n" + " include Sufia::Catalog\n" end else puts " \e[31mFailure\e[0m Could not find #{file_path}. To add Sufia behaviors to your Controllers, you must include the Sufia::Catalog module in the CatalogController class definition." end end |
#insert_abilities ⇒ Object
33 34 35 36 37 |
# File 'lib/generators/sufia/upgrade400_generator.rb', line 33 def insert_abilities insert_into_file 'app/models/ability.rb', after: /Hydra::Ability/ do "\n include Sufia::Ability\n" end end |
#install_blacklight_gallery ⇒ Object
61 62 63 |
# File 'lib/generators/sufia/upgrade400_generator.rb', line 61 def install_blacklight_gallery generate "blacklight_gallery:install" end |
#remove_blacklight_scss ⇒ Object
57 58 59 |
# File 'lib/generators/sufia/upgrade400_generator.rb', line 57 def remove_blacklight_scss remove_file 'app/assets/stylesheets/blacklight.css.scss' end |
#tinymce_config ⇒ Object
65 66 67 |
# File 'lib/generators/sufia/upgrade400_generator.rb', line 65 def tinymce_config copy_file "config/tinymce.yml", "config/tinymce.yml" end |
#update_root_route ⇒ Object
The engine routes have to come after the devise routes so that /users/sign_in will work
28 29 30 31 |
# File 'lib/generators/sufia/upgrade400_generator.rb', line 28 def update_root_route # Nuke old Sufia-related routes gsub_file 'config/routes.rb', 'root :to => "catalog#index"', "root to: 'homepage#index'" end |
#upgrade_sufia_models ⇒ Object
82 83 84 |
# File 'lib/generators/sufia/upgrade400_generator.rb', line 82 def upgrade_sufia_models generate "sufia:models:upgrade400" end |