Class: Kronos::Report

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/kronos/report.rb

Constant Summary collapse

STATUSES =
{ success: 0, failure: 1 }.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.failure_from(task_id, exception, timestamp = Time.now) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/kronos/report.rb', line 17

def failure_from(task_id, exception, timestamp = Time.now)
  new(
    task_id: check_task_id(task_id),
    status: Kronos::Report::STATUSES[:failure],
    timestamp: check_timestamp(timestamp),
    exception: check_exception(exception)
  )
end

.success_from(task_id, metadata, timestamp = Time.now) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/kronos/report.rb', line 8

def success_from(task_id, , timestamp = Time.now)
  new(
    task_id: check_task_id(task_id),
    status: Kronos::Report::STATUSES[:success],
    timestamp: check_timestamp(timestamp),
    metadata: ()
  )
end

Instance Method Details

#failure?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/kronos/report.rb', line 85

def failure?
  status == Kronos::Report::STATUSES[:failure]
end

#success?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/kronos/report.rb', line 81

def success?
  status == Kronos::Report::STATUSES[:success]
end