Class: PrideIO
Overview
Show your testing pride!
Direct Known Subclasses
Constant Summary collapse
- ESC =
"\e["
- NND =
"#{ESC}0m"
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Instance Method Summary collapse
-
#initialize(io) ⇒ PrideIO
constructor
A new instance of PrideIO.
- #method_missing(msg, *args) ⇒ Object
- #pride(string) ⇒ Object
- #print(o) ⇒ Object
- #puts(*o) ⇒ Object
Constructor Details
#initialize(io) ⇒ PrideIO
Returns a new instance of PrideIO.
18 19 20 21 22 23 24 25 26 |
# File 'lib/minitest/pride.rb', line 18 def initialize io @io = io # stolen from /System/Library/Perl/5.10.0/Term/ANSIColor.pm # also reference http://en.wikipedia.org/wiki/ANSI_escape_code @colors ||= (31..36).to_a @size = @colors.size @index = 0 # io.sync = true end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(msg, *args) ⇒ Object
59 60 61 |
# File 'lib/minitest/pride.rb', line 59 def method_missing msg, *args io.send(msg, *args) end |
Instance Attribute Details
#io ⇒ Object (readonly)
Returns the value of attribute io
16 17 18 |
# File 'lib/minitest/pride.rb', line 16 def io @io end |
Instance Method Details
#pride(string) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/minitest/pride.rb', line 52 def pride string string = "*" if string == "." c = @colors[@index % @size] @index += 1 "#{ESC}#{c}m#{string}#{NND}" end |
#print(o) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/minitest/pride.rb', line 28 def print o case o when "." then io.print pride o when "E", "F" then io.print "#{ESC}41m#{ESC}37m#{o}#{NND}" else io.print o end end |
#puts(*o) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/minitest/pride.rb', line 39 def puts(*o) o.map! { |s| s.sub(/Finished tests/) { @index = 0 'Fabulous tests'.split(//).map { |c| pride(c) }.join } } super end |