Class: Duty::Tasks::Base

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

Defined Under Namespace

Classes: Command, Ruby, Shell

Constant Summary collapse

ExecutionError =
Class.new(RuntimeError)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arguments, view) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
# File 'lib/duty/tasks.rb', line 6

def initialize(arguments, view)
  @arguments = arguments
  @view = view
  @parallel = []
end

Class Method Details

.descriptionObject



29
30
31
# File 'lib/duty/tasks.rb', line 29

def self.description
  "TODO: Describe your task by overwriting `self.description`"
end

.nameObject



25
26
27
# File 'lib/duty/tasks.rb', line 25

def self.name
  self.to_s.split('::').last
end

.usageObject



33
34
35
# File 'lib/duty/tasks.rb', line 33

def self.usage
  "TODO: Explain your task by overwriting `self.usage`"
end

Instance Method Details

#executeObject



37
38
39
40
41
# File 'lib/duty/tasks.rb', line 37

def execute
  ruby('Describe your task') {}
  ruby('Explain your task') {}
  ruby('TODO: Implement your task by overwriting `execute`') { raise ExecutionError.new }
end

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/duty/tasks.rb', line 12

def run
  if !valid?
    task_explain
  else
    begin
      execute_in_thread
      task_success
    rescue ExecutionError
      task_failure
    end
  end
end