Class: Spotlight::Install
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Spotlight::Install
- Defined in:
- lib/generators/spotlight/install_generator.rb
Instance Method Summary collapse
- #add_controller_mixin ⇒ Object
- #add_helper ⇒ Object
- #add_model_mixin ⇒ Object
- #add_roles_to_user ⇒ Object
- #assets ⇒ Object
- #inject_spotlight_routes ⇒ Object
Instance Method Details
#add_controller_mixin ⇒ Object
26 27 28 29 30 |
# File 'lib/generators/spotlight/install_generator.rb', line 26 def add_controller_mixin inject_into_file 'app/controllers/application_controller.rb', after: "include Blacklight::Controller" do "\n include Spotlight::Controller\n" end end |
#add_helper ⇒ Object
32 33 34 35 |
# File 'lib/generators/spotlight/install_generator.rb', line 32 def add_helper copy_file "spotlight_helper.rb", "app/helpers/spotlight_helper.rb" inject_into_class 'app/helpers/application_helper.rb', ApplicationHelper, " include SpotlightHelper" end |
#add_model_mixin ⇒ Object
37 38 39 40 41 |
# File 'lib/generators/spotlight/install_generator.rb', line 37 def add_model_mixin inject_into_file 'app/models/solr_document.rb', after: "include Blacklight::Solr::Document" do "\n include Spotlight::SolrDocument\n include Spotlight::SolrDocument::AtomicUpdates\n" end end |
#add_roles_to_user ⇒ Object
22 23 24 |
# File 'lib/generators/spotlight/install_generator.rb', line 22 def add_roles_to_user inject_into_class 'app/models/user.rb', User, " include Spotlight::User" end |
#assets ⇒ Object
17 18 19 20 |
# File 'lib/generators/spotlight/install_generator.rb', line 17 def assets copy_file "spotlight.css.scss", "app/assets/stylesheets/spotlight.css.scss" copy_file "spotlight.js", "app/assets/javascripts/spotlight.js" end |
#inject_spotlight_routes ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/generators/spotlight/install_generator.rb', line 8 def inject_spotlight_routes route "mount Spotlight::Engine, at: 'spotlight'" gsub_file 'config/routes.rb', /^\s*root.*/ do |match| "#" + match + " # replaced by spotlight_root" end route "spotlight_root" end |