Class: Burner::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/burner/output.rb

Overview

A Pipeline execution can write main output, which is really an outline to whats happening, step-by-step. This is not meant to replace or be true logging, but serve more as a summary for each of the jobs. Each job can decide what it would like to include in this summary and leverage an instance of this class for inclusion of that information.

Constant Summary collapse

RULER_LENGTH =
80

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: SecureRandom.uuid, outs: [$stdout]) ⇒ Output

Returns a new instance of Output.



20
21
22
23
24
# File 'lib/burner/output.rb', line 20

def initialize(id: SecureRandom.uuid, outs: [$stdout])
  @id        = id
  @outs      = Array(outs)
  @job_count = 1
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



18
19
20
# File 'lib/burner/output.rb', line 18

def id
  @id
end

#job_countObject (readonly)

Returns the value of attribute job_count.



18
19
20
# File 'lib/burner/output.rb', line 18

def job_count
  @job_count
end

#outsObject (readonly)

Returns the value of attribute outs.



18
19
20
# File 'lib/burner/output.rb', line 18

def outs
  @outs
end

Instance Method Details

#complete(time_in_seconds) ⇒ Object



52
53
54
55
56
# File 'lib/burner/output.rb', line 52

def complete(time_in_seconds)
  detail("Completed in: #{time_in_seconds.round(3)} second(s)")

  self
end

#detail(message) ⇒ Object



40
41
42
43
44
# File 'lib/burner/output.rb', line 40

def detail(message)
  write("  - #{message}")

  self
end

#rulerObject



26
27
28
29
30
# File 'lib/burner/output.rb', line 26

def ruler
  write('-' * RULER_LENGTH)

  self
end

#title(message) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/burner/output.rb', line 32

def title(message)
  write("[#{job_count}] #{message}")

  @job_count += 1

  self
end

#write(message) ⇒ Object



46
47
48
49
50
# File 'lib/burner/output.rb', line 46

def write(message)
  raw("[#{id} | #{Time.now.utc}] #{message}")

  self
end