Class: Minitest::RG
- Inherits:
-
Object
show all
- Defined in:
- lib/minitest/rg_plugin.rb
Constant Summary
collapse
- VERSION =
"5.3.0"
- COLORS =
{
"." => "\e[32m.\e[0m",
"E" => "\e[33mE\e[0m",
"F" => "\e[31mF\e[0m",
"S" => "\e[36mS\e[0m"
}.freeze
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.
40
41
42
43
|
# File 'lib/minitest/rg_plugin.rb', line 40
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
63
64
65
66
67
|
# File 'lib/minitest/rg_plugin.rb', line 63
def method_missing msg, *args
return io.send(msg, *args) if io.respond_to? msg
super
end
|
Instance Attribute Details
#colors ⇒ Object
Returns the value of attribute colors.
30
31
32
|
# File 'lib/minitest/rg_plugin.rb', line 30
def colors
@colors
end
|
#io ⇒ Object
Returns the value of attribute io.
30
31
32
|
# File 'lib/minitest/rg_plugin.rb', line 30
def io
@io
end
|
Class Method Details
.rg!(color: true) ⇒ Object
32
33
34
|
# File 'lib/minitest/rg_plugin.rb', line 32
def self.rg! color: true
@rg = color
end
|
.rg? ⇒ Boolean
36
37
38
|
# File 'lib/minitest/rg_plugin.rb', line 36
def self.rg?
@rg ||= false
end
|
Instance Method Details
#print(output) ⇒ Object
45
46
47
|
# File 'lib/minitest/rg_plugin.rb', line 45
def print output
io.print(colors[output] || output)
end
|
#puts(output = nil) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/minitest/rg_plugin.rb', line 49
def puts output = nil
return io.puts if output.nil?
if output =~ /(\d+) failures, (\d+) errors/
if Regexp.last_match[1] != "0" || Regexp.last_match[2] != "0"
io.puts "\e[31m#{output}\e[0m"
else
io.puts "\e[32m#{output}\e[0m"
end
else
io.puts output
end
end
|
#respond_to_missing?(method_name, include_all = false) ⇒ Boolean
69
70
71
72
73
|
# File 'lib/minitest/rg_plugin.rb', line 69
def respond_to_missing? method_name, include_all = false
return true if io.respond_to? method_name, include_all
super
end
|