Class: Simmer::Suite::OutputRouter

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/simmer/suite/output_router.rb

Overview

Routes output either to the console or the PdiOutputWriter. It also provides some methods to help format output.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(console, pdi_out) ⇒ OutputRouter

Returns a new instance of OutputRouter.



16
17
18
19
20
21
# File 'lib/simmer/suite/output_router.rb', line 16

def initialize(console, pdi_out)
  @console = console || raise(ArgumentError, 'console is required')
  @pdi_out = pdi_out || raise(ArgumentError, 'pdi_out is required')

  freeze
end

Instance Attribute Details

#consoleObject (readonly)

Returns the value of attribute console.



10
11
12
# File 'lib/simmer/suite/output_router.rb', line 10

def console
  @console
end

#pdi_outObject (readonly)

Returns the value of attribute pdi_out.



10
11
12
# File 'lib/simmer/suite/output_router.rb', line 10

def pdi_out
  @pdi_out
end

Instance Method Details

#announce_start(id, specification) ⇒ Object



23
24
25
26
27
# File 'lib/simmer/suite/output_router.rb', line 23

def announce_start(id, specification)
  console_puts("Name: #{specification.name}")
  console_puts("Path: #{specification.path}")
  pdi_out.demarcate_spec(id, specification.name)
end

#final_verdict(result) ⇒ Object



33
34
35
36
37
# File 'lib/simmer/suite/output_router.rb', line 33

def final_verdict(result)
  msg = pass_message(result)
  waiting('Done', 'Final verdict')
  console_puts(msg)
end

#result(result) ⇒ Object



29
30
31
# File 'lib/simmer/suite/output_router.rb', line 29

def result(result)
  console_puts(pass_message(result))
end

#spoon_execution_detail_message(spoon_client_result) ⇒ Object



48
49
50
51
52
53
# File 'lib/simmer/suite/output_router.rb', line 48

def spoon_execution_detail_message(spoon_client_result)
  code = spoon_client_result.execution_result.status.code
  detail = "(Exited with code #{code} after #{spoon_client_result.time_in_seconds} seconds)"

  console_puts("#{pass_message(spoon_client_result)} #{detail}")
end

#waiting(stage, msg) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/simmer/suite/output_router.rb', line 39

def waiting(stage, msg)
  # This is not for debugging.
  # rubocop:disable Lint/Debugger
  console.print(
    "  > #{pad_right(stage, 6)} - #{pad_right(msg, WAITING_MAX_WIDTH, WAITING_PADDING_CHAR)}"
  )
  # rubocop:enable Lint/Debugger
end