Class: Minitest::Subjective::Formatter::Colors

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/subjective/formatter/colors.rb

Overview

:nodoc:

Constant Summary collapse

CSI =
"\033["
FINAL_BYTE =
'm'
CODES =
{
  clear: 0,
  gray: 90,
  white: 37,
  green: 32,
  red: 31,
  underline: 4,
  strikethrough: 9,
  framed: 51,
  encircled: 52
}.freeze
SEPARATOR =
';'

Instance Method Summary collapse

Constructor Details

#initializeColors

Returns a new instance of Colors.



22
23
24
# File 'lib/minitest/subjective/formatter/colors.rb', line 22

def initialize
  @stack = []
end

Instance Method Details

#clearObject



48
# File 'lib/minitest/subjective/formatter/colors.rb', line 48

def clear = pop && (current || sequence(:clear))

#clear_allObject



49
# File 'lib/minitest/subjective/formatter/colors.rb', line 49

def clear_all = stash && sequence(:clear)

#color_for_hits(count) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/minitest/subjective/formatter/colors.rb', line 30

def color_for_hits(count)
  unstash

  case count
  when nil then :gray
  when 0 then :red
  when (1..) then :green
  end
end

#encircledObject



44
# File 'lib/minitest/subjective/formatter/colors.rb', line 44

def encircled = push :encircled

#format(color = nil, hits: false) ⇒ Object



26
27
28
# File 'lib/minitest/subjective/formatter/colors.rb', line 26

def format(color = nil, hits: false)
  [public_send(color_for_hits(hits) || color || :transparent), yield, clear].join
end

#framedObject



43
# File 'lib/minitest/subjective/formatter/colors.rb', line 43

def framed = push :framed

#grayObject



40
# File 'lib/minitest/subjective/formatter/colors.rb', line 40

def gray = push :gray

#greenObject



41
# File 'lib/minitest/subjective/formatter/colors.rb', line 41

def green = push :green

#redObject



42
# File 'lib/minitest/subjective/formatter/colors.rb', line 42

def red = push :red

#transparentObject



46
# File 'lib/minitest/subjective/formatter/colors.rb', line 46

def transparent = push :clear

#whiteObject



45
# File 'lib/minitest/subjective/formatter/colors.rb', line 45

def white = push :white