Class: CurationConcerns::Install
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- CurationConcerns::Install
- Defined in:
- lib/generators/curation_concerns/install_generator.rb
Instance Method Summary collapse
- #add_helper ⇒ Object
- #assets ⇒ Object
- #catalog_controller ⇒ Object
- #inject_ability ⇒ Object
- #inject_application_controller_behavior ⇒ Object
-
#inject_routes ⇒ Object
END Blacklight stuff.
-
#inject_solr_document_behavior ⇒ Object
Add behaviors to the SolrDocument model.
-
#remove_blacklight_scss ⇒ Object
def insert_builder insert_into_file ‘app/models/search_builder.rb’, after: /include Blacklight::Solr::SearchBuilderBehavior/ do # First line should be generated by Hydra.
- #replace_blacklight_layout ⇒ Object
- #rights_config ⇒ Object
- #run_required_generators ⇒ Object
Instance Method Details
#add_helper ⇒ Object
99 100 101 |
# File 'lib/generators/curation_concerns/install_generator.rb', line 99 def add_helper copy_file 'curation_concerns_helper.rb', 'app/helpers/curation_concerns_helper.rb' end |
#assets ⇒ Object
94 95 96 97 |
# File 'lib/generators/curation_concerns/install_generator.rb', line 94 def assets copy_file 'curation_concerns.scss', 'app/assets/stylesheets/curation_concerns.scss' copy_file 'curation_concerns.js', 'app/assets/javascripts/curation_concerns.js' end |
#catalog_controller ⇒ Object
77 78 79 |
# File 'lib/generators/curation_concerns/install_generator.rb', line 77 def catalog_controller copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb" end |
#inject_ability ⇒ Object
70 71 72 73 74 75 |
# File 'lib/generators/curation_concerns/install_generator.rb', line 70 def inject_ability inject_into_file 'app/models/ability.rb', after: /Hydra::Ability\s*\n/ do " include CurationConcerns::Ability\n"\ " self.ability_logic += [:everyone_can_create_curation_concerns]\n\n" end end |
#inject_application_controller_behavior ⇒ Object
29 30 31 32 33 34 |
# File 'lib/generators/curation_concerns/install_generator.rb', line 29 def inject_application_controller_behavior inject_into_file 'app/controllers/application_controller.rb', after: /Hydra::Controller::ControllerBehavior\s*\n/ do "\n # Adds CurationConcerns behaviors to the application controller.\n" \ " include CurationConcerns::ApplicationControllerBehavior\n" end end |
#inject_routes ⇒ Object
END Blacklight stuff
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/generators/curation_concerns/install_generator.rb', line 55 def inject_routes # Remove root route that was added by blacklight generator gsub_file 'config/routes.rb', /root (:to =>|to:) "catalog#index"/, '' inject_into_file 'config/routes.rb', after: /devise_for :users\s*\n/ do " mount Hydra::Collections::Engine => '/'\n"\ " mount CurationConcerns::Engine, at: '/'\n"\ " resources :welcome, only: 'index'\n"\ " root 'welcome#index'\n"\ " curation_concerns_collections\n"\ " curation_concerns_basic_routes\n"\ " curation_concerns_embargo_management\n"\ end end |
#inject_solr_document_behavior ⇒ Object
Add behaviors to the SolrDocument model
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/generators/curation_concerns/install_generator.rb', line 82 def inject_solr_document_behavior file_path = 'app/models/solr_document.rb' if File.exist?(file_path) inject_into_file file_path, after: /include Blacklight::Solr::Document.*$/ do "\n # Adds CurationConcerns behaviors to the SolrDocument.\n" \ " include CurationConcerns::SolrDocumentBehavior\n" end else puts " \e[31mFailure\e[0m CurationConcerns requires a SolrDocument object. This generators assumes that the model is defined in the file #{file_path}, which does not exist." end end |
#remove_blacklight_scss ⇒ Object
def insert_builder
insert_into_file 'app/models/search_builder.rb', after: /include Blacklight::Solr::SearchBuilderBehavior/ do
# First line should be generated by Hydra. projecthydra/hydra-head#255
"\n include Hydra::AccessControlsEnforcement" +
"\n include CurationConcerns::SearchBuilder\n"
end
end
49 50 51 |
# File 'lib/generators/curation_concerns/install_generator.rb', line 49 def remove_blacklight_scss remove_file 'app/assets/stylesheets/blacklight.css.scss' end |
#replace_blacklight_layout ⇒ Object
36 37 38 39 |
# File 'lib/generators/curation_concerns/install_generator.rb', line 36 def replace_blacklight_layout gsub_file 'app/controllers/application_controller.rb', /layout 'blacklight'/, "include CurationConcerns::ThemedLayoutController\n with_themed_layout '1_column'\n" end |
#rights_config ⇒ Object
103 104 105 |
# File 'lib/generators/curation_concerns/install_generator.rb', line 103 def rights_config copy_file "config/authorities/rights.yml", "config/authorities/rights.yml" end |
#run_required_generators ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/generators/curation_concerns/install_generator.rb', line 20 def run_required_generators say_status('warning', '[CurationConcerns] GENERATING BLACKLIGHT', :yellow) generate 'blacklight:install --devise' say_status('warning', '[CurationConcerns] GENERATING HYDRA-HEAD', :yellow) generate 'hydra:head -f' say_status('warning', '[CurationConcerns] GENERATING CURATION_CONCERNS MODELS', :yellow) generate "curation_concerns:models:install#{options[:force] ? ' -f' : ''}" end |