Class: BlacklightRangeLimit::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- BlacklightRangeLimit::InstallGenerator
- Defined in:
- lib/generators/blacklight_range_limit/install_generator.rb
Instance Method Summary collapse
- #add_range_limit_concern_to_catalog ⇒ Object
- #copy_public_assets ⇒ Object
- #install_catalog_controller_mixin ⇒ Object
- #install_routing_concern ⇒ Object
- #install_search_builder ⇒ Object
-
#install_search_history_controller ⇒ Object
Adds range limit behavior to search history controller.
Instance Method Details
#add_range_limit_concern_to_catalog ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/generators/blacklight_range_limit/install_generator.rb', line 48 def add_range_limit_concern_to_catalog sentinel = /concerns :searchable.*$/ inject_into_file 'config/routes.rb', after: sentinel do "\n concerns :range_searchable\n" end end |
#copy_public_assets ⇒ Object
7 8 9 |
# File 'lib/generators/blacklight_range_limit/install_generator.rb', line 7 def copy_public_assets generate 'blacklight_range_limit:assets' end |
#install_catalog_controller_mixin ⇒ Object
11 12 13 14 15 |
# File 'lib/generators/blacklight_range_limit/install_generator.rb', line 11 def install_catalog_controller_mixin inject_into_class 'app/controllers/catalog_controller.rb', CatalogController do "\n include BlacklightRangeLimit::ControllerOverride\n" end end |
#install_routing_concern ⇒ Object
44 45 46 |
# File 'lib/generators/blacklight_range_limit/install_generator.rb', line 44 def install_routing_concern route('concern :range_searchable, BlacklightRangeLimit::Routes::RangeSearchable.new') end |
#install_search_builder ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/blacklight_range_limit/install_generator.rb', line 17 def install_search_builder path = 'app/models/search_builder.rb' if File.exist? path inject_into_file path, after: /include Blacklight::Solr::SearchBuilderBehavior.*$/ do "\n include BlacklightRangeLimit::RangeLimitBuilder\n" end else say_status("error", "Unable to find #{path}. You must manually add the 'include BlacklightRangeLimit::RangeLimitBuilder' to your SearchBuilder", :red) end end |
#install_search_history_controller ⇒ Object
Adds range limit behavior to search history controller
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/generators/blacklight_range_limit/install_generator.rb', line 29 def install_search_history_controller path = 'app/controllers/search_history_controller.rb' # If local copy of search history controller exists, add range limit helpers if File.exist? path inject_into_file path, after: /include Blacklight::SearchHistory.*$/ do "\n helper BlacklightRangeLimit::ViewHelperOverride"\ "\n helper RangeLimitHelper" end # Otherwise copies search history controller to application else copy_file 'search_history_controller.rb', path end end |