class Minitest::RedGreen::Plugin

Constants

ESC

Attributes

sync[RW]

Public Class Methods

new(io) click to toggle source
# File lib/minitest/red_green/plugin.rb, line 8
def initialize io
  @io = io
end

Public Instance Methods

colorize(str, col_code) click to toggle source
# File lib/minitest/red_green/plugin.rb, line 48
def colorize str, col_code
  "#{ESC}#{col_code}m#{str}#{ESC}0m"
end
external_encoding() click to toggle source
# File lib/minitest/red_green/plugin.rb, line 12
def external_encoding
  @io.external_encoding
end
filter_test_output_chars(str) click to toggle source
# File lib/minitest/red_green/plugin.rb, line 27
def filter_test_output_chars str
  case str
  when '.' then green str
  when 'E', 'F' then red str
  when 'S' then yellow str
  else str
  end
end
green(str) click to toggle source
# File lib/minitest/red_green/plugin.rb, line 36
def green str
  colorize str, 32
end
print(str) click to toggle source
puts(*strings) click to toggle source
# File lib/minitest/red_green/plugin.rb, line 16
def puts *strings
  if not strings.grep(%r{\d+\) (?:Failure|Error)}).empty?
    strings.map! &method(:red)
  end
  @io.puts *strings
end
red(str) click to toggle source
# File lib/minitest/red_green/plugin.rb, line 40
def red str
  colorize str, 31
end
yellow(str) click to toggle source
# File lib/minitest/red_green/plugin.rb, line 44
def yellow str
  colorize str, 33
end