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_frontend ⇒ Object
- #add_i18n_config ⇒ Object
- #add_repository_config ⇒ Object
- #add_stylesheets ⇒ Object
- #assets ⇒ 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
73 74 75 76 77 |
# File 'lib/generators/arclight/install_generator.rb', line 73 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
38 39 40 41 42 43 44 |
# File 'lib/generators/arclight/install_generator.rb', line 38 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
87 88 89 |
# File 'lib/generators/arclight/install_generator.rb', line 87 def add_download_config copy_file 'config/downloads.yml' unless File.exist?('config/downloads.yml') end |
#add_frontend ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/generators/arclight/install_generator.rb', line 46 def add_frontend if ENV['CI'] run "yarn add file:#{Arclight::Engine.root}" elsif [:test] run 'yarn link arclight' # If a branch was specified (e.g. you are running a template.rb build # against a test branch), use the latest version available on npm elsif ENV['BRANCH'] run 'yarn add arclight@latest' # Otherwise, pick the version from npm that matches the Arclight # gem version else run "yarn add arclight@#{arclight_yarn_version}" end end |
#add_i18n_config ⇒ Object
91 92 93 |
# File 'lib/generators/arclight/install_generator.rb', line 91 def add_i18n_config copy_file 'config/locales/arclight.en.yml' end |
#add_repository_config ⇒ Object
83 84 85 |
# File 'lib/generators/arclight/install_generator.rb', line 83 def add_repository_config copy_file 'config/repositories.yml' unless File.exist?('config/repositories.yml') end |
#add_stylesheets ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/generators/arclight/install_generator.rb', line 64 def add_stylesheets copy_file 'arclight.scss', 'app/assets/stylesheets/arclight.scss' append_to_file 'app/assets/stylesheets/application.bootstrap.scss' do <<~CONTENT @import "arclight"; CONTENT end end |
#assets ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'lib/generators/arclight/install_generator.rb', line 99 def assets if using_importmap? pin_javascript_dependencies import_arclight_javascript else install_javascript_dependencies end end |
#create_blacklight_catalog ⇒ Object
13 14 15 16 |
# File 'lib/generators/arclight/install_generator.rb', line 13 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
18 19 20 21 22 |
# File 'lib/generators/arclight/install_generator.rb', line 18 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
108 109 110 111 112 113 114 115 |
# File 'lib/generators/arclight/install_generator.rb', line 108 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
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/arclight/install_generator.rb', line 24 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
95 96 97 |
# File 'lib/generators/arclight/install_generator.rb', line 95 def modify_blacklight_yml gsub_file 'config/locales/blacklight.en.yml', "application_name: 'Blacklight'", "application_name: 'Arclight'" end |
#solr_config ⇒ Object
79 80 81 |
# File 'lib/generators/arclight/install_generator.rb', line 79 def solr_config directory '../../../../solr', 'solr', force: true end |