Module: HealthInspector::Color

Included in:
HealthInspector::Checklists::Base, HealthInspector::Checklists::Base::CheckContext
Defined in:
lib/health_inspector/color.rb

Instance Method Summary collapse

Instance Method Details

#color(type, str) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/health_inspector/color.rb', line 3

def color(type, str)
  colors = {
    'pass'          => 90,
    'fail'          => 31,
    'bright pass'   => 92,
    'bright fail'   => 91,
    'bright yellow' => 93,
    'pending'       => 36,
    'suite'         => 0,
    'error title'   => 0,
    'error message' => 31,
    'error stack'   => 90,
    'checkmark'     => 32,
    'fast'          => 90,
    'medium'        => 33,
    'slow'          => 31,
    'green'         => 32,
    'light'         => 90,
    'diff gutter'   => 90,
    'diff added'    => 42,
    'diff removed'  => 41
  }

  if @context.no_color
    str
  else
  "\e[%sm%s\e[0m" % [ colors[type], str ]
  end
end