Configuration during installation via application template
Stories in sprints often imply that a feature/improvement be configurable as part of what done looks like. These requirements would ideally be met by providing configuration options during installation via the application template.
To keep the application template from becoming too big and full of complicated logic, configuration options should be handled by a generator or rake task that can then be called from the template. This has the added benefit of making it easy to extend/refactor feature-specific configuration code as related stories are being worked on. It would also allow the installer to run generators or tasks at any time to accomplish a specific configuration task.
Application template in Curate
- https://github.com/projecthydra/curate/blob/develop/lib/generators/curate/application_template.rb
- The initial Curate pull request discussion for the application template: https://github.com/projecthydra/curate/pull/209
About application templates and generators
- Methods are provided by Thor and are available to both templates and generators
- http://guides.rubyonrails.org/rails_application_templates.html
- http://guides.rubyonrails.org/generators.html
Adding generators in Curate
- Use curate:work in lib/generators/curate/work as example
- To make a generator available as curate:config_feature :
# lib/generators/curate/configurable_feature/config_feature_generator.rb ... require 'rails/generators' class Curate::ConfigFeatureGenerator < Rails::Generators::Base # methods to do something end
Call generator from Curate application template
- Determine where to insert into template (the template is processed from top to bottom so position according to dependencies)
- Use the 'generator' method in the template, and wrap with appropriate method if questioning the installer:
CONFIG_QUESTION = <<-QUESTION_TO_ASK Would you like to enable an interesting feature in your installation? Doing this will enable something interesting to be sure. QUESTION_TO_ASK if yes_with_banner?(CONFIG_QUESTION) with_git("Configuring an interesting feature") do generate "curate:config_feature" end end