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_solr_wrapper ⇒ Object
- #add_spatial_search_behavior ⇒ Object
- #add_unique_key ⇒ Object
- #assets ⇒ Object
- #bundle_install ⇒ Object
- #create_blacklight_catalog ⇒ Object
- #create_downloads_directory ⇒ Object
- #disable_turbolinks ⇒ Object
- #include_geoblacklight_solrdocument ⇒ Object
- #inject_geoblacklight_routes ⇒ Object
-
#inject_sprockets ⇒ Object
Necessary for bootstrap-sass 3.2.
- #mount_geoblacklight_engine ⇒ Object
- #rails_config ⇒ Object
- #solr_config ⇒ Object
Instance Method Details
#add_solr_wrapper ⇒ Object
9 10 11 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 9 def add_solr_wrapper generate 'blacklight:solr5' end |
#add_spatial_search_behavior ⇒ Object
68 69 70 71 72 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 68 def add_spatial_search_behavior inject_into_file 'app/models/search_builder.rb', after: 'include Blacklight::Solr::SearchBuilderBehavior' do "\n include Geoblacklight::SpatialSearchBehavior" end end |
#add_unique_key ⇒ Object
62 63 64 65 66 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 62 def add_unique_key inject_into_file 'app/models/solr_document.rb', after: "# self.unique_key = 'id'" do "\n self.unique_key = 'layer_slug_s'" end end |
#assets ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 35 def assets copy_file 'geoblacklight.scss', 'app/assets/stylesheets/geoblacklight.scss' copy_file 'geoblacklight.js', 'app/assets/javascripts/geoblacklight.js' append_to_file 'config/initializers/assets.rb', "\nRails.application.config.assets.precompile += %w( favicon.ico )\n" end |
#bundle_install ⇒ Object
94 95 96 97 98 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 94 def bundle_install Bundler.with_clean_env do run 'bundle install' end end |
#create_blacklight_catalog ⇒ Object
43 44 45 46 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 43 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
74 75 76 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 74 def create_downloads_directory FileUtils.mkdir_p('tmp/cache/downloads') unless File.directory?('tmp/cache/downloads') end |
#disable_turbolinks ⇒ Object
90 91 92 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 90 def disable_turbolinks gsub_file('app/assets/javascripts/application.js', %r{\/\/= require turbolinks}, '') end |
#include_geoblacklight_solrdocument ⇒ Object
56 57 58 59 60 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 56 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
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 17 def inject_geoblacklight_routes route <<-EOF.strip_heredoc 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] EOF end |
#inject_sprockets ⇒ Object
Necessary for bootstrap-sass 3.2
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 79 def inject_sprockets blacklight_css = Dir['app/assets/stylesheets/blacklight.scss'].first if blacklight_css insert_into_file blacklight_css, before: "@import 'bootstrap';" do "@import 'bootstrap-sprockets';\n" end else say_status 'warning', 'Can not find blacklight.scss, did not insert our require', :red end end |
#mount_geoblacklight_engine ⇒ Object
13 14 15 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 13 def mount_geoblacklight_engine route "mount Geoblacklight::Engine => 'geoblacklight'" end |
#rails_config ⇒ Object
48 49 50 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 48 def rails_config copy_file 'settings.yml', 'config/settings.yml' end |
#solr_config ⇒ Object
52 53 54 |
# File 'lib/generators/geoblacklight/install_generator.rb', line 52 def solr_config directory '../../../../solr', 'solr' end |