Class: Geoblacklight::Install
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Geoblacklight::Install
- Defined in:
- lib/generators/geoblacklight/install_generator.rb
Instance Method Summary collapse
- #add_rsolr_gem ⇒ Object
- #add_spatial_search_behavior ⇒ Object
- #add_unique_key ⇒ Object
- #allow_geoblacklight_params ⇒ Object
- #create_blacklight_catalog ⇒ Object
- #create_downloads_directory ⇒ Object
-
#create_image_assets_directory ⇒ Object
Ensure that assets/images exists.
- #docker_compose ⇒ Object
- #generate_assets ⇒ Object
- #include_geoblacklight_solrdocument ⇒ Object
- #inject_geoblacklight_routes ⇒ Object
- #mount_geoblacklight_engine ⇒ Object
- #rails_config ⇒ Object
- #raise_unpermitted_params ⇒ Object
- #solr_config ⇒ Object
- #update_application_name ⇒ Object
Instance Method Details
#add_rsolr_gem ⇒ Object
66 67 68 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 66 def add_rsolr_gem gem "rsolr", ">= 1.0", "< 3" end |
#add_spatial_search_behavior ⇒ Object
86 87 88 89 90 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 86 def add_spatial_search_behavior inject_into_file "app/models/search_builder.rb", after: "include Blacklight::Solr::SearchBuilderBehavior" do "\n include Geoblacklight::SuppressedRecordsSearchBehavior" end end |
#add_unique_key ⇒ Object
80 81 82 83 84 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 80 def add_unique_key inject_into_file "app/models/solr_document.rb", after: "# self.unique_key = 'id'" do "\n self.unique_key = Settings.FIELDS.UNIQUE_KEY" end end |
#allow_geoblacklight_params ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 12 def allow_geoblacklight_params gbl_params = <<-PARAMS before_action :allow_geoblacklight_params def allow_geoblacklight_params # Blacklight::Parameters will pass these to params.permit blacklight_config.search_state_fields.append(Settings.GBL_PARAMS) end PARAMS inject_into_file "app/controllers/application_controller.rb", gbl_params, before: /^end/ end |
#create_blacklight_catalog ⇒ Object
53 54 55 56 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 53 def create_blacklight_catalog remove_file "app/controllers/catalog_controller.rb" copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb" end |
#create_downloads_directory ⇒ Object
92 93 94 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 92 def create_downloads_directory FileUtils.mkdir_p("tmp/cache/downloads") unless File.directory?("tmp/cache/downloads") end |
#create_image_assets_directory ⇒ Object
Ensure that assets/images exists
101 102 103 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 101 def create_image_assets_directory FileUtils.mkdir_p("app/assets/images") unless File.directory?("app/assets/images") end |
#docker_compose ⇒ Object
70 71 72 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 70 def docker_compose copy_file "../../../../compose.yml", "compose.yml" end |
#generate_assets ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 105 def generate_assets if [:test] generate "geoblacklight:assets", "--test=true" else generate "geoblacklight:assets" end end |
#include_geoblacklight_solrdocument ⇒ Object
74 75 76 77 78 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 74 def include_geoblacklight_solrdocument inject_into_file "app/models/solr_document.rb", after: "include Blacklight::Solr::Document" do "\n include Geoblacklight::SolrDocument" end end |
#inject_geoblacklight_routes ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 33 def inject_geoblacklight_routes routes = <<-ROUTES concern :gbl_exportable, Geoblacklight::Routes::Exportable.new resources :solr_documents, only: [:show], path: '/catalog', controller: 'catalog' do concerns :gbl_exportable end concern :gbl_wms, Geoblacklight::Routes::Wms.new namespace :wms do concerns :gbl_wms end concern :gbl_downloadable, Geoblacklight::Routes::Downloadable.new namespace :download do concerns :gbl_downloadable end resources :download, only: [:show] ROUTES inject_into_file "config/routes.rb", routes, before: /^end/ end |
#mount_geoblacklight_engine ⇒ Object
29 30 31 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 29 def mount_geoblacklight_engine inject_into_file "config/routes.rb", "mount Geoblacklight::Engine => 'geoblacklight'\n", before: /^end/ end |
#rails_config ⇒ Object
58 59 60 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 58 def rails_config copy_file "settings.yml", "config/settings.yml" end |
#raise_unpermitted_params ⇒ Object
25 26 27 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 25 def raise_unpermitted_params inject_into_file "config/environments/test.rb", "config.action_controller.action_on_unpermitted_parameters = :raise\n", before: /^end/ end |
#solr_config ⇒ Object
62 63 64 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 62 def solr_config directory "../../../../solr", "solr" end |
#update_application_name ⇒ Object
96 97 98 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 96 def update_application_name gsub_file("config/locales/blacklight.en.yml", "Blacklight", "GeoBlacklight") end |