Class: Fudge::Tasks::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/fudge/tasks/task.rb

Overview

Implementation of base Task

Direct Known Subclasses

CompositeTask, Shell

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Task

Returns a new instance of Task.



17
18
19
20
21
22
23
24
25
26
# File 'lib/fudge/tasks/task.rb', line 17

def initialize(*args)
  @args = args.dup
  @options = @args[-1].kind_of?(Hash) ? @args.delete_at(-1) : {}

  @options.each do |k,v|
    send("#{k}=", v) if respond_to?("#{k}=")
  end

  @args
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



5
6
7
# File 'lib/fudge/tasks/task.rb', line 5

def args
  @args
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/fudge/tasks/task.rb', line 5

def options
  @options
end

Class Method Details

.nameSymbol

Default name derived from class name. Can be overriden by specific tasks.

Returns:

  • (Symbol)


11
12
13
14
15
# File 'lib/fudge/tasks/task.rb', line 11

def self.name
  name = /(\w+::)*(?<class>\w+\z)/.match(super)[:class]
  underscored = name.gsub(/(?<pre>[^_])(?<char>[A-Z])/, "\\k<pre>_\\k<char>")
  underscored.downcase.to_sym
end