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
- #generate_assets ⇒ Object
- #install_catalog_controller_mixin ⇒ Object
- #install_routing_concern ⇒ Object
- #install_search_builder ⇒ Object
Instance Method Details
#add_range_limit_concern_to_catalog ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/generators/blacklight_range_limit/install_generator.rb', line 37 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 |
#generate_assets ⇒ Object
10 11 12 13 14 |
# File 'lib/generators/blacklight_range_limit/install_generator.rb', line 10 def generate_assets unless [:'skip-assets'] generate 'blacklight_range_limit:assets' end end |
#install_catalog_controller_mixin ⇒ Object
16 17 18 19 20 |
# File 'lib/generators/blacklight_range_limit/install_generator.rb', line 16 def install_catalog_controller_mixin inject_into_file 'app/controllers/catalog_controller.rb', after: /include Blacklight::Catalog.*$/ do "\n include BlacklightRangeLimit::ControllerOverride\n" end end |
#install_routing_concern ⇒ Object
33 34 35 |
# File 'lib/generators/blacklight_range_limit/install_generator.rb', line 33 def install_routing_concern route('concern :range_searchable, BlacklightRangeLimit::Routes::RangeSearchable.new') end |
#install_search_builder ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/generators/blacklight_range_limit/install_generator.rb', line 22 def install_search_builder path = [:'builder-path'] 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 |