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

About application templates and generators

Adding generators in Curate

# 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