Class: Runciter::Task

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, name, opts = {}) ⇒ Task

Returns a new instance of Task.



6
7
8
9
10
11
12
# File 'lib/runciter/task.rb', line 6

def initialize(app, name, opts = {})
  @app = app
  @name = name
  @opts = opts

  register!
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/runciter/task.rb', line 4

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/runciter/task.rb', line 3

def name
  @name
end

Instance Method Details

#run!(&block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/runciter/task.rb', line 14

def run!(&block)
  run = Run.new(@app, self, @opts)

  begin
    block.call(run)
    run.finish! # finish! rescues its own exceptions
  rescue
    run.die!($!) # die! rescues its own exceptions
    raise $! # reraise the exception for the user program to handle
  end
end