Class: MiniTest::RG

Inherits:
Object
  • Object
show all
Defined in:
lib/maxitest/vendor/rg.rb

Constant Summary collapse

VERSION =
"5.2.0"
COLORS =
{
  '.' => "\e[32m.\e[0m",
  'E' => "\e[33mE\e[0m",
  'F' => "\e[31mF\e[0m",
  'S' => "\e[36mS\e[0m",
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, colors = COLORS) ⇒ RG

Returns a new instance of RG.



67
68
69
70
# File 'lib/maxitest/vendor/rg.rb', line 67

def initialize io, colors = COLORS
  @io     = io
  @colors = colors
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(msg, *args) ⇒ Object



89
90
91
92
# File 'lib/maxitest/vendor/rg.rb', line 89

def method_missing msg, *args
  return super unless io.respond_to? msg
  io.send(msg, *args)
end

Instance Attribute Details

#colorsObject (readonly)

Returns the value of attribute colors.



57
58
59
# File 'lib/maxitest/vendor/rg.rb', line 57

def colors
  @colors
end

#ioObject (readonly)

Returns the value of attribute io.



57
58
59
# File 'lib/maxitest/vendor/rg.rb', line 57

def io
  @io
end

Class Method Details

.rg!Object



59
60
61
# File 'lib/maxitest/vendor/rg.rb', line 59

def self.rg!
  @rg = true
end

.rg?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/maxitest/vendor/rg.rb', line 63

def self.rg?
  @rg ||= false
end

Instance Method Details



72
73
74
# File 'lib/maxitest/vendor/rg.rb', line 72

def print o
  io.print(colors[o] || o)
end

#puts(o = nil) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/maxitest/vendor/rg.rb', line 76

def puts o=nil
  return io.puts if o.nil?
  if o =~ /(\d+) failures, (\d+) errors/
    if $1 != '0' || $2 != '0'
      io.puts "\e[31m#{o}\e[0m"
    else
      io.puts "\e[32m#{o}\e[0m"
    end
  else
    io.puts o
  end
end