Class: Minitest::UntzIO

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/untz_plugin.rb

Direct Known Subclasses

UntzLOL

Constant Summary collapse

ESC =

Start an escape sequence

"\e["
NND =

End the escape sequence

"#{ESC}0m"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ UntzIO

:nodoc:



39
40
41
42
43
44
45
46
47
# File 'lib/minitest/untz_plugin.rb', line 39

def initialize(io) # :nodoc:
  @io = io
  # stolen from minitest/pride, which in turn was
  # 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
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(msg, *args) ⇒ Object

:nodoc:



86
87
88
# File 'lib/minitest/untz_plugin.rb', line 86

def method_missing(msg, *args) # :nodoc:
  io.send(msg, *args)
end

Instance Attribute Details

#ioObject (readonly)

Returns the value of attribute io.



37
38
39
# File 'lib/minitest/untz_plugin.rb', line 37

def io
  @io
end

Class Method Details

.untz!Object



23
24
25
# File 'lib/minitest/untz_plugin.rb', line 23

def self.untz!
  @untz = true
end

.untz?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/minitest/untz_plugin.rb', line 27

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

Instance Method Details



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/minitest/untz_plugin.rb', line 49

def print(o)
  case o
  when '.', 'S'
    io.print "#{untz(o)} "
  when 'E'
    io.print "#{ESC}41m#{ESC}37m#{o}#{NND} "
  when 'F'
    io.print "#{ESC}41m#{ESC}37mSKREE#{NND} "
  else
    io.print "#{o} "
  end
end

#puts(*o) ⇒ Object

:nodoc:



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/minitest/untz_plugin.rb', line 62

def puts(*o) # :nodoc:
  o.map! { |s|
    s.to_s.sub(/Finished/) {
      @index = 0
      'Ravin\' run'.split(//).map { |c|
        untz(c)
      }.join
    }
  }

  io.puts(*o)
end

#untz(string) ⇒ Object



75
76
77
78
79
80
81
82
83
84
# File 'lib/minitest/untz_plugin.rb', line 75

def untz(string)
  string = case string
           when '.' then 'untz'
           when 'S' then 'wub'
           else string
           end
  c = @colors[@index % @size]
  @index += 1
  "#{ESC}#{c}m#{string}#{NND}"
end