Module: Appjam::Generators::Actions::ClassMethods

Defined in:
lib/appjam/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)



176
177
178
# File 'lib/appjam/generators/actions.rb', line 176

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]



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

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



171
172
173
# File 'lib/appjam/generators/actions.rb', line 171

def component_types
  @component_types
end

#require_arguments!Object

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



161
162
163
# File 'lib/appjam/generators/actions.rb', line 161

def require_arguments!
  @require_arguments = true
end

#require_arguments?Boolean

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

Returns:

  • (Boolean)


166
167
168
# File 'lib/appjam/generators/actions.rb', line 166

def require_arguments?
  @require_arguments
end