class PrideIO

def initialize io # :nodoc:

:nodoc:
def initialize io # :nodoc:
  @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

def method_missing msg, *args # :nodoc:

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

def pride string

def pride string
  string = "*" if string == "."
  c = @colors[@index % @size]
  @index += 1
  "#{ESC}#{c}m#{string}#{NND}"
end

def print o

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

def puts(*o) # :nodoc:

:nodoc:
def puts(*o) # :nodoc:
  o.map! { |s|
    s.to_s.sub(/Finished tests/) {
      @index = 0
      'Fabulous tests'.split(//).map { |c|
        pride(c)
      }.join
    }
  }
  super
end