Class: Hydra::HeadGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Hydra::HeadGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/hydra/head_generator.rb
Instance Method Summary collapse
-
#create_configuration_files ⇒ Object
Copy all files in templates/config directory to host config.
-
#inject_hydra_routes ⇒ Object
Inject call to HydraHead.add_routes in config/routes.rb.
-
#inject_hydra_user_behavior ⇒ Object
Add Hydra behaviors to the user model.
-
#inject_test_framework ⇒ Object
Config Files & Initializers.
Instance Method Details
#create_configuration_files ⇒ Object
Copy all files in templates/config directory to host config
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/generators/hydra/head_generator.rb', line 42 def create_configuration_files copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb" # Initializers file_path = "config/initializers/hydra_config.rb" copy_file "config/initializers/hydra_config.rb", file_path insert_into_file file_path, :after => '# specify the user model' do "\n config[:user_model] = '#{model_name.classify}'" end copy_file "config/initializers/action_dispatch_http_upload_monkey_patch.rb", "config/initializers/action_dispatch_http_upload_monkey_patch.rb" # Role Mappings copy_file "config/role_map_cucumber.yml", "config/role_map_cucumber.yml" copy_file "config/role_map_development.yml", "config/role_map_development.yml" copy_file "config/role_map_production.yml", "config/role_map_production.yml" copy_file "config/role_map_test.yml", "config/role_map_test.yml" # Fedora & Solr YAML files invoke('active_fedora:config') end |
#inject_hydra_routes ⇒ Object
Inject call to HydraHead.add_routes in config/routes.rb
78 79 80 81 82 83 |
# File 'lib/generators/hydra/head_generator.rb', line 78 def inject_hydra_routes insert_into_file "config/routes.rb", :after => 'Blacklight.add_routes(self)' do "\n # Add Hydra routes. For options, see API docs for HydraHead.routes" "\n HydraHead.add_routes(self)" end end |
#inject_hydra_user_behavior ⇒ Object
Add Hydra behaviors to the user model
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/generators/hydra/head_generator.rb', line 65 def inject_hydra_user_behavior file_path = "app/models/#{model_name.underscore}.rb" if File.exists?(file_path) inject_into_class file_path, model_name.classify do "# Connects this user object to Hydra behaviors. " + "\n include Hydra::User\n" end else puts " \e[31mFailure\e[0m Hydra requires a user object in order to apply access controls. This generators assumes that the model is defined in the file #{file_path}, which does not exist. If you used a different name, please re-run the generator and provide that name as an argument. Such as \b rails -g hydra:head client" end end |
#inject_test_framework ⇒ Object
Config Files & Initializers
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/generators/hydra/head_generator.rb', line 27 def inject_test_framework application("\n" << " config.generators do |g|\n" << " g.test_framework :rspec, :spec => true\n" << " end\n\n" ) gem_group :development, :test do gem "rspec-rails" gem 'jettywrapper' end end |