Namespace

Thor::Base

Attributes

options[RW]

Public Class Methods

new(args=[], options={}, config={}) click to toggle source

It receives arguments in an Array and two hashes, one for options and other for configuration.

Notice that it does not check if all required arguments were supplied. It should be done by the parser.

Parameters

args>

An array of objects. The objects are applied to their respective accessors declared with argument.

options<Hash>

An options hash that will be available as self.options. The hash given is converted to a hash with indifferent access, magic predicates (options.skip?) and then frozen.

config<Hash>

Configuration for this Thor class.

# File lib/thor/base.rb, line 40
def initialize(args=[], options={}, config={})
  args = Thor::Arguments.parse(self.class.arguments, args)
  args.each { |key, value| send("#{key}=", value) }

  parse_options = self.class.class_options

  if options.is_a?(Array)
    task_options  = config.delete(:task_options) # hook for start
    parse_options = parse_options.merge(task_options) if task_options
    array_options, hash_options = options, {}
  else
    array_options, hash_options = [], options
  end

  opts = Thor::Options.new(parse_options, hash_options)
  self.options = opts.parse(array_options)
  opts.check_unknown! if self.class.check_unknown_options?(config)
end
shell() click to toggle source

Returns the shell used in all Thor classes. If you are in a Unix platform it will use a colored log, otherwise it will use a basic one without color.

# File lib/thor/shell.rb, line 8
def self.shell
  @shell ||= if ENV['THOR_SHELL'] && ENV['THOR_SHELL'].size > 0
    Thor::Shell.const_get(ENV['THOR_SHELL'])
  elsif RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
    Thor::Shell::Basic
  else
    Thor::Shell::Color
  end
end
shell=(klass) click to toggle source

Sets the shell used in all Thor classes.

# File lib/thor/shell.rb, line 20
def self.shell=(klass)
  @shell = klass
end
subclass_files() click to toggle source

Returns the files where the subclasses are kept.

Returns

Hash[path<String> => Class]

# File lib/thor/base.rb, line 80
def subclass_files
  @subclass_files ||= Hash.new{ |h,k| h[k] = [] }
end
subclasses() click to toggle source

Returns the classes that inherits from Thor or Thor::Group.

Returns

Array

# File lib/thor/base.rb, line 71
def subclasses
  @subclasses ||= []
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.