Module: Puer::Generators::Actions::ClassMethods

Defined in:
lib/puer/generators/actions.rb

Instance Method Summary collapse

Instance Method Details

#available_choices_for(component) ⇒ Object

Returns the list of available choices for the given component (including none)



177
178
179
# File 'lib/puer/generators/actions.rb', line 177

def available_choices_for(component)
  @available_choices[component] + [:none]
end

#component_option(name, caption, options = {}) ⇒ Object

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 component_option :test, “Testing framework”, :aliases => ‘-t’, :choices => [:bacon, :shoulda]



154
155
156
157
158
159
# File 'lib/puer/generators/actions.rb', line 154

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

#component_typesObject

Returns the compiled list of component types which can be specified



172
173
174
# File 'lib/puer/generators/actions.rb', line 172

def component_types
  @component_types
end

#require_arguments!Object

Tell to Puer that for this Thor::Group is necessary a task to run



162
163
164
# File 'lib/puer/generators/actions.rb', line 162

def require_arguments!
  @require_arguments = true
end

#require_arguments?Boolean

Return true if we need an arguments for our Thor::Group

Returns:

  • (Boolean)


167
168
169
# File 'lib/puer/generators/actions.rb', line 167

def require_arguments?
  @require_arguments
end