Class methods for Thor generators to support the generators and component choices.
Returns the list of available choices for the given component (including none)
@param [Symbol] component
The type of the component module
@return [Array<Symbol>] Array of component choices
@example
available_choices_for :test => [:shoulda, :bacon, :riot, :minitest]
@api semipublic
# File lib/padrino-gen/generators/actions.rb, line 497 def available_choices_for(component) @available_choices[component] + [:none] end
Defines a class option to allow a component to be chosen and add to component type list Also builds the available_choices hash of which component choices are supported
@param [Symbol] name
Name of component
@param [String] caption
Description of the component
@param [Hash] options
Additional parameters for component choice
@example
component_option :test, "Testing framework", :aliases => '-t', :choices => [:bacon, :shoulda]
@api private
# File lib/padrino-gen/generators/actions.rb, line 457 def component_option(name, caption, options = {}) (@component_types ||= []) << name # TODO use ordered hash and combine with choices below (@available_choices ||= Hash.new)[name] = options[:choices] description = "The #{caption} component (#{options[:choices].join(', ')}, none)" class_option name, :default => options[:default] || options[:choices].first, :aliases => options[:aliases], :desc => description end
Returns the compiled list of component types which can be specified
@api private
# File lib/padrino-gen/generators/actions.rb, line 481 def component_types @component_types end
Generated with the Darkfish Rdoc Generator 2.