minitest-colorer 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.rbenv-version +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +16 -0
- data/README.md +2 -0
- data/Rakefile +1 -0
- data/lib/minitest/colorer.rb +93 -0
- data/minitest-colorer.gemspec +13 -0
- metadata +73 -0
data/.rbenv-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3-p194
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module MiniTest
|
2
|
+
class Colorer
|
3
|
+
# Start an escape sequence
|
4
|
+
ESC = "\e["
|
5
|
+
|
6
|
+
# End the escape sequence
|
7
|
+
NND = "#{ESC}0m"
|
8
|
+
|
9
|
+
# The IO we're going to pipe through.
|
10
|
+
attr_reader :io
|
11
|
+
|
12
|
+
def initialize(io) # :nodoc:
|
13
|
+
@io = io
|
14
|
+
end
|
15
|
+
|
16
|
+
##
|
17
|
+
# Wrap print to colorize the output.
|
18
|
+
|
19
|
+
def print(o)
|
20
|
+
case o
|
21
|
+
when "." then
|
22
|
+
io.print success(o)
|
23
|
+
when "E" then
|
24
|
+
io.print error(o)
|
25
|
+
when "F" then
|
26
|
+
io.print failure(o)
|
27
|
+
when "S" then
|
28
|
+
io.print skip(o)
|
29
|
+
else
|
30
|
+
io.print o
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def puts(*o) # :nodoc:
|
35
|
+
o.map! { |s|
|
36
|
+
s.sub(/(\d+\) )(Failure|Error)(.+)/m) {
|
37
|
+
status = ($2 == 'Failure') ? 'failure' : 'error'
|
38
|
+
"#{$1}#{send(status, $2)}#{$3}"
|
39
|
+
}.sub(/(\d+ tests?, \d+ assertions?, (\d+) failures?, (\d+) errors?, (\d+) skips?)/) {
|
40
|
+
if $2.to_i > 0
|
41
|
+
failure($1)
|
42
|
+
elsif $3.to_i > 0
|
43
|
+
error($1)
|
44
|
+
elsif $4.to_i > 0
|
45
|
+
skip($1)
|
46
|
+
else
|
47
|
+
success($1)
|
48
|
+
end
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
super
|
53
|
+
end
|
54
|
+
|
55
|
+
def method_missing(msg, *args) # :nodoc:
|
56
|
+
io.send(msg, *args)
|
57
|
+
end
|
58
|
+
|
59
|
+
COLORS = {
|
60
|
+
:black => 30,
|
61
|
+
:blue => 34,
|
62
|
+
:cyan => 36,
|
63
|
+
:green => 32,
|
64
|
+
:magenta => 35,
|
65
|
+
:red => 31,
|
66
|
+
:white => 37,
|
67
|
+
:yellow => 33
|
68
|
+
}
|
69
|
+
|
70
|
+
COLORS.each do |color_name, color_value|
|
71
|
+
define_method color_name do |string|
|
72
|
+
"#{ESC}#{color_value}m#{string}#{NND}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def success(text)
|
77
|
+
green(text)
|
78
|
+
end
|
79
|
+
|
80
|
+
def error(text)
|
81
|
+
yellow(text)
|
82
|
+
end
|
83
|
+
|
84
|
+
def failure(text)
|
85
|
+
red(text)
|
86
|
+
end
|
87
|
+
|
88
|
+
def skip(text)
|
89
|
+
cyan(text)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
MiniTest::Unit.output = MiniTest::Colorer.new(MiniTest::Unit.output)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{minitest-colorer}
|
3
|
+
s.description = "Colors your MiniTest output"
|
4
|
+
s.summary = s.description
|
5
|
+
s.version = "0.1.1"
|
6
|
+
s.date = %q{2012-06-04}
|
7
|
+
s.authors = ["Chris Moore"]
|
8
|
+
s.homepage = %q{https://github.com/moorecp/minitest-colorer}
|
9
|
+
s.require_paths = ["lib"]
|
10
|
+
s.files = `git ls-files`.split($/)
|
11
|
+
|
12
|
+
s.add_dependency('minitest')
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minitest-colorer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chris Moore
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: minitest
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Colors your MiniTest output
|
31
|
+
email:
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- .rbenv-version
|
37
|
+
- Gemfile
|
38
|
+
- Gemfile.lock
|
39
|
+
- README.md
|
40
|
+
- Rakefile
|
41
|
+
- lib/minitest/colorer.rb
|
42
|
+
- minitest-colorer.gemspec
|
43
|
+
homepage: https://github.com/moorecp/minitest-colorer
|
44
|
+
licenses: []
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
hash: -1688998519614372363
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
hash: -1688998519614372363
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.8.23
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Colors your MiniTest output
|
73
|
+
test_files: []
|