Class: PrideIO

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

Overview

Show your testing pride!

Constant Summary collapse

COLORS =

stolen from /System/Library/Perl/5.10.0/Term/ANSIColor.pm

(31..36).to_a
CHARS =
["*"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ PrideIO

Returns a new instance of PrideIO.



13
14
15
16
17
# File 'lib/minitest/pride.rb', line 13

def initialize io
  @io = io
  @colors = COLORS.cycle
  @chars  = CHARS.cycle
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(msg, *args) ⇒ Object



30
31
32
# File 'lib/minitest/pride.rb', line 30

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

Instance Attribute Details

#ioObject (readonly)

Returns the value of attribute io.



7
8
9
# File 'lib/minitest/pride.rb', line 7

def io
  @io
end

Instance Method Details



19
20
21
22
23
24
25
26
27
28
# File 'lib/minitest/pride.rb', line 19

def print o
  case o
  when "." then
    io.print "\e[#{@colors.next}m#{@chars.next}\e[0m"
  when "E", "F" then
    io.print "\e[41m\e[37m#{o}\e[0m"
  else
    io.print o
  end
end