Class: Arclight::Install
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Arclight::Install
- Defined in:
- lib/generators/arclight/install_generator.rb
Overview
Arclight install generator
Direct Known Subclasses
Instance Method Summary collapse
- #add_arclight_search_behavior ⇒ Object
- #add_custom_routes ⇒ Object
- #add_download_config ⇒ Object
- #add_i18n_config ⇒ Object
- #add_repository_config ⇒ Object
- #assets ⇒ Object
- #copy_styles ⇒ Object
- #create_blacklight_catalog ⇒ Object
- #include_arclight_solrdocument ⇒ Object
- #inject_arclight_routes ⇒ Object
- #install_blacklight_locale_picker ⇒ Object
- #modify_blacklight_yml ⇒ Object
- #solr_config ⇒ Object
Instance Method Details
#add_arclight_search_behavior ⇒ Object
49 50 51 52 53 |
# File 'lib/generators/arclight/install_generator.rb', line 49 def add_arclight_search_behavior inject_into_file 'app/models/search_builder.rb', after: 'include Blacklight::Solr::SearchBuilderBehavior' do "\n include Arclight::SearchBehavior" end end |
#add_custom_routes ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/generators/arclight/install_generator.rb', line 36 def add_custom_routes inject_into_file 'config/routes.rb', after: "mount Blacklight::Engine => '/'" do "\n mount Arclight::Engine => '/'\n" end gsub_file 'config/routes.rb', 'root to: "catalog#index"', 'root to: "arclight/repositories#index"' end |
#add_download_config ⇒ Object
63 64 65 |
# File 'lib/generators/arclight/install_generator.rb', line 63 def add_download_config copy_file 'config/downloads.yml' unless File.exist?('config/downloads.yml') end |
#add_i18n_config ⇒ Object
67 68 69 |
# File 'lib/generators/arclight/install_generator.rb', line 67 def add_i18n_config copy_file 'config/locales/arclight.en.yml' end |
#add_repository_config ⇒ Object
59 60 61 |
# File 'lib/generators/arclight/install_generator.rb', line 59 def add_repository_config copy_file 'config/repositories.yml' unless File.exist?('config/repositories.yml') end |
#assets ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/generators/arclight/install_generator.rb', line 75 def assets if using_importmap? pin_javascript_dependencies import_arclight_javascript else install_javascript_dependencies end end |
#copy_styles ⇒ Object
44 45 46 47 |
# File 'lib/generators/arclight/install_generator.rb', line 44 def copy_styles copy_file 'arclight.scss', 'app/assets/stylesheets/arclight.scss' remove_file 'app/assets/stylesheets/blacklight.scss' # Avoid two copies of bootstrap end |
#create_blacklight_catalog ⇒ Object
11 12 13 14 |
# File 'lib/generators/arclight/install_generator.rb', line 11 def create_blacklight_catalog remove_file 'app/controllers/catalog_controller.rb' copy_file 'catalog_controller.rb', 'app/controllers/catalog_controller.rb' end |
#include_arclight_solrdocument ⇒ Object
16 17 18 19 20 |
# File 'lib/generators/arclight/install_generator.rb', line 16 def include_arclight_solrdocument inject_into_file 'app/models/solr_document.rb', after: 'include Blacklight::Solr::Document' do "\n include Arclight::SolrDocument" end end |
#inject_arclight_routes ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/generators/arclight/install_generator.rb', line 84 def inject_arclight_routes inject_into_file 'config/routes.rb', " concern :hierarchy, Arclight::Routes::Hierarchy.new\n", after: /concern :exportable.*\n/ inject_into_file 'config/routes.rb', " concerns :hierarchy\n", after: /resources :solr_documents.*\n/ end |
#install_blacklight_locale_picker ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/generators/arclight/install_generator.rb', line 22 def install_blacklight_locale_picker gem 'blacklight-locale_picker' Bundler.with_unbundled_env do run 'bundle install' end generate 'blacklight:locale_picker:install' inject_into_file 'app/helpers/application_helper.rb', after: 'include Blacklight::LocalePicker::LocaleHelper' do "\n\n def additional_locale_routing_scopes\n [blacklight, arclight_engine]\n end" end end |
#modify_blacklight_yml ⇒ Object
71 72 73 |
# File 'lib/generators/arclight/install_generator.rb', line 71 def modify_blacklight_yml gsub_file 'config/locales/blacklight.en.yml', "application_name: 'Blacklight'", "application_name: 'Arclight'" end |
#solr_config ⇒ Object
55 56 57 |
# File 'lib/generators/arclight/install_generator.rb', line 55 def solr_config directory '../../../../solr', 'solr', force: true end |