Class: Minitest::Subjective::Formatter::Colors
- Inherits:
-
Object
- Object
- Minitest::Subjective::Formatter::Colors
- 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
- #clear ⇒ Object
- #clear_all ⇒ Object
- #color_for_hits(count) ⇒ Object
- #encircled ⇒ Object
- #format(color = nil, hits: false) ⇒ Object
- #framed ⇒ Object
- #gray ⇒ Object
- #green ⇒ Object
-
#initialize ⇒ Colors
constructor
A new instance of Colors.
- #red ⇒ Object
- #transparent ⇒ Object
- #white ⇒ Object
Constructor Details
#initialize ⇒ Colors
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
#clear ⇒ Object
48 |
# File 'lib/minitest/subjective/formatter/colors.rb', line 48 def clear = pop && (current || sequence(:clear)) |
#clear_all ⇒ Object
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 |
#encircled ⇒ Object
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 |
#framed ⇒ Object
43 |
# File 'lib/minitest/subjective/formatter/colors.rb', line 43 def framed = push :framed |
#gray ⇒ Object
40 |
# File 'lib/minitest/subjective/formatter/colors.rb', line 40 def gray = push :gray |
#green ⇒ Object
41 |
# File 'lib/minitest/subjective/formatter/colors.rb', line 41 def green = push :green |
#red ⇒ Object
42 |
# File 'lib/minitest/subjective/formatter/colors.rb', line 42 def red = push :red |
#transparent ⇒ Object
46 |
# File 'lib/minitest/subjective/formatter/colors.rb', line 46 def transparent = push :clear |
#white ⇒ Object
45 |
# File 'lib/minitest/subjective/formatter/colors.rb', line 45 def white = push :white |