Module: ConsoleReporter

Defined in:
lib/almirah/console_reporter.rb

Overview

Reporter prints concise, aligned progress lines for the processing pipeline:

parsing specifications ..... 4 ok
parsing test protocols ..... 2 ok
parsing decisions .......... 14 ok
traceability matrices ...... 4 ok
coverage matrices .......... 1 ok
implementation matrices .... 1 ok
decision links ............. 5 ok
rendering HTML ............. ./build/index.html

ANSI colour is applied only when writing to an interactive terminal, so piped or captured output stays clean.

Constant Summary collapse

COLUMN =

label is dot-padded out to this column, then the value follows

28

Class Method Summary collapse

Class Method Details

.colorize(text, color_code) ⇒ Object



43
44
45
# File 'lib/almirah/console_reporter.rb', line 43

def colorize(text, color_code)
  $stdout.tty? ? "\e[#{color_code}m#{text}\e[0m" : text
end

.count(label, number) ⇒ Object



21
22
23
# File 'lib/almirah/console_reporter.rb', line 21

def count(label, number)
  emit(label, "#{number} ok", 92) # green highlight
end

.emit(label, value, color_code) ⇒ Object



38
39
40
41
# File 'lib/almirah/console_reporter.rb', line 38

def emit(label, value, color_code)
  dotted = "#{label} ".ljust(COLUMN, '.')
  puts "#{dotted} #{colorize(value, color_code)}"
end

.result(label, value) ⇒ Object



25
26
27
# File 'lib/almirah/console_reporter.rb', line 25

def result(label, value)
  emit(label, value, 96) # cyan highlight
end

.warn(label, value) ⇒ Object



29
30
31
# File 'lib/almirah/console_reporter.rb', line 29

def warn(label, value)
  emit(label, value.to_s, 91) # red highlight
end

.warn_detail(text) ⇒ Object

Colourises a detail line with the same red as warn (TTY-gated).



34
35
36
# File 'lib/almirah/console_reporter.rb', line 34

def warn_detail(text)
  colorize(text, 91)
end