riel 1.1.17 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/riel/date.rb +12 -4
- data/lib/riel/dir.rb +73 -67
- data/lib/riel/enumerable.rb +30 -51
- data/lib/riel/pathname.rb +1 -1
- data/lib/riel/rcfile.rb +0 -2
- data/lib/riel/regexp.rb +2 -6
- data/lib/riel/setdiff.rb +0 -2
- data/lib/riel/string.rb +75 -80
- data/lib/riel/timer.rb +7 -9
- data/lib/riel.rb +1 -1
- data/test/riel/date_test.rb +4 -0
- data/test/riel/dir_test.rb +4 -0
- data/test/riel/enumerable_test.rb +86 -11
- data/test/riel/regexp_test.rb +6 -0
- data/test/riel/size_converter_test.rb +4 -4
- data/test/riel/string_test.rb +4 -4
- metadata +9 -32
- data/lib/riel/array.rb +0 -19
- data/lib/riel/log/log.rb +0 -244
- data/lib/riel/log/loggable.rb +0 -101
- data/lib/riel/log/logger.rb +0 -266
- data/lib/riel/log/severity.rb +0 -22
- data/lib/riel/log.rb +0 -21
- data/lib/riel/optproc.rb +0 -296
- data/test/riel/array_test.rb +0 -22
- data/test/riel/log/format_test.rb +0 -48
- data/test/riel/optproc_test.rb +0 -202
- data/test/riel/testlog/log_stack_test.rb +0 -98
- data/test/riel/testlog/log_test.rb +0 -254
- data/test/riel/testlog/loggable_test.rb +0 -31
data/test/riel/optproc_test.rb
DELETED
@@ -1,202 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'pathname'
|
5
|
-
require 'tempfile'
|
6
|
-
require 'test/unit'
|
7
|
-
require 'riel/optproc'
|
8
|
-
|
9
|
-
class OptProcTestCase < Test::Unit::TestCase
|
10
|
-
def setup
|
11
|
-
# ignore what they have in ENV[HOME]
|
12
|
-
ENV['HOME'] = '/this/should/not/exist'
|
13
|
-
end
|
14
|
-
|
15
|
-
def run_match_tag_test opt, exp, tag
|
16
|
-
m = opt.match [ tag ]
|
17
|
-
match = nil
|
18
|
-
if exp.respond_to? :include?
|
19
|
-
match = exp.include? m
|
20
|
-
else
|
21
|
-
match = exp == m
|
22
|
-
end
|
23
|
-
assert match, "match_tag(#{tag}): expected: #{exp.inspect}; actual: #{m.inspect}"
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_match_tag
|
27
|
-
@after = "nothing"
|
28
|
-
opt = OptProc::Option.new :tags => %w{ --after-context -A }, :arg => [ :integer ]
|
29
|
-
|
30
|
-
%w{ --after-context --after-context=3 -A }.each do |tag|
|
31
|
-
run_match_tag_test opt, 1.0, tag
|
32
|
-
end
|
33
|
-
|
34
|
-
run_match_tag_test opt, nil, '-b'
|
35
|
-
|
36
|
-
# we don't support case insensitivity (which is insensitive of us):
|
37
|
-
%w{ --After-Context --AFTER-CONTEXT=3 -a }.each do |tag|
|
38
|
-
run_match_tag_test opt, nil, tag
|
39
|
-
end
|
40
|
-
|
41
|
-
%w{ --after --after=3 }.each do |tag|
|
42
|
-
run_match_tag_test opt, 0.07, tag
|
43
|
-
end
|
44
|
-
|
45
|
-
%w{ --after-cont --after-cont=3 }.each do |tag|
|
46
|
-
run_match_tag_test opt, 0.12, tag
|
47
|
-
end
|
48
|
-
|
49
|
-
%w{ --aft --aft=3 }.each do |tag|
|
50
|
-
run_match_tag_test opt, 0.05, tag
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def run_match_value_test opt, exp, val
|
55
|
-
m = opt.match_value val
|
56
|
-
assert !!m == !!exp, "match value #{val}; expected: #{exp.inspect}; actual: #{m.inspect}"
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_value_none
|
60
|
-
opt = OptProc::Option.new(:arg => [ :none ])
|
61
|
-
|
62
|
-
{
|
63
|
-
'34' => nil,
|
64
|
-
'43' => nil,
|
65
|
-
'34.12' => nil
|
66
|
-
}.each do |val, exp|
|
67
|
-
run_match_value_test opt, exp, val
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_value_integer
|
72
|
-
opt = OptProc::Option.new(:arg => [ :integer ])
|
73
|
-
|
74
|
-
{
|
75
|
-
'34' => true,
|
76
|
-
'43' => true,
|
77
|
-
'34.12' => nil,
|
78
|
-
'-34' => true,
|
79
|
-
'+34' => true,
|
80
|
-
}.each do |val, exp|
|
81
|
-
run_match_value_test opt, exp, val
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_value_float
|
86
|
-
opt = OptProc::Option.new(:arg => [ :float ])
|
87
|
-
|
88
|
-
{
|
89
|
-
'34' => true,
|
90
|
-
'43' => true,
|
91
|
-
'34.12' => true,
|
92
|
-
'.12' => true,
|
93
|
-
'.' => false,
|
94
|
-
'12.' => false,
|
95
|
-
}.each do |val, exp|
|
96
|
-
run_match_value_test opt, exp, val
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_value_string
|
101
|
-
opt = OptProc::Option.new(:arg => [ :string ])
|
102
|
-
|
103
|
-
{
|
104
|
-
'34' => true,
|
105
|
-
'43' => true,
|
106
|
-
'34.12' => true,
|
107
|
-
'.12' => true,
|
108
|
-
'.' => true,
|
109
|
-
'12.' => true,
|
110
|
-
'hello' => true,
|
111
|
-
'a b c' => true,
|
112
|
-
'' => true,
|
113
|
-
}.each do |val, exp|
|
114
|
-
[
|
115
|
-
'"' + val + '"',
|
116
|
-
"'" + val + "'",
|
117
|
-
val,
|
118
|
-
].each do |qval|
|
119
|
-
run_match_value_test opt, exp, qval
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_after_context_float
|
125
|
-
@after = nil
|
126
|
-
opt = OptProc::Option.new(:tags => %w{ --after-context -A },
|
127
|
-
:arg => [ :required, :float ],
|
128
|
-
:set => Proc.new { |val| @after = val })
|
129
|
-
[
|
130
|
-
%w{ --after-context 3 },
|
131
|
-
%w{ --after-context=3 },
|
132
|
-
%w{ -A 3 },
|
133
|
-
].each do |args|
|
134
|
-
@after = nil
|
135
|
-
|
136
|
-
m = opt.match args
|
137
|
-
assert_equal 1.0, m, "args: #{args.inspect}"
|
138
|
-
# curr = args.shift
|
139
|
-
opt.set_value args
|
140
|
-
assert_equal 3.0, @after
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_regexp_option
|
145
|
-
@after = nil
|
146
|
-
opt = OptProc::Option.new(:res => %r{ ^ - ([1-9]\d*) $ }x,
|
147
|
-
:tags => %w{ --context -C },
|
148
|
-
:arg => [ :optional, :integer ],
|
149
|
-
:set => Proc.new { |val| @ctx = val })
|
150
|
-
[
|
151
|
-
%w{ --context 3 },
|
152
|
-
%w{ --context=3 },
|
153
|
-
%w{ -C 3 },
|
154
|
-
].each do |args|
|
155
|
-
@ctx = nil
|
156
|
-
|
157
|
-
m = opt.match args
|
158
|
-
assert_equal 1.0, m, "args: #{args.inspect}"
|
159
|
-
opt.set_value args
|
160
|
-
assert_equal 3, @ctx
|
161
|
-
end
|
162
|
-
|
163
|
-
vals = (1 .. 10).to_a | (1 .. 16).collect { |x| 2 ** x }
|
164
|
-
# vals = [ 4 ]
|
165
|
-
vals.each do |val|
|
166
|
-
args = [ '-' + val.to_s, 'foo' ]
|
167
|
-
|
168
|
-
@ctx = nil
|
169
|
-
|
170
|
-
m = opt.match args
|
171
|
-
assert_equal 1.0, m, "args: #{args.inspect}"
|
172
|
-
opt.set_value args
|
173
|
-
assert_equal val, @ctx
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
def test_value_regexp
|
178
|
-
@range_start = nil
|
179
|
-
opt = OptProc::Option.new(:tags => %w{ --after },
|
180
|
-
:arg => [ :required, :regexp, %r{ ^ (\d+%?) $ }x ],
|
181
|
-
:set => Proc.new { |md| @range_start = md[1] })
|
182
|
-
|
183
|
-
%w{ 5 5% 10 90% }.each do |rg|
|
184
|
-
[
|
185
|
-
[ '--after', rg ],
|
186
|
-
[ '--after=' + rg ]
|
187
|
-
].each do |args|
|
188
|
-
@range_start = nil
|
189
|
-
|
190
|
-
m = opt.match args
|
191
|
-
assert_equal 1.0, m, "args: #{args.inspect}"
|
192
|
-
opt.set_value args
|
193
|
-
assert_equal rg, @range_start
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
end
|
199
|
-
|
200
|
-
if __FILE__ == $0
|
201
|
-
Log.level = Log::DEBUG
|
202
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'pathname'
|
5
|
-
require 'test/unit'
|
6
|
-
require 'stringio'
|
7
|
-
require 'riel/log'
|
8
|
-
|
9
|
-
class LogAbyss
|
10
|
-
include Loggable
|
11
|
-
|
12
|
-
def squeal
|
13
|
-
log "hello from the abyss"
|
14
|
-
stack "turtles all the way down"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class LogDepths
|
19
|
-
include Loggable
|
20
|
-
|
21
|
-
def speak
|
22
|
-
log "hello from the depths"
|
23
|
-
la = LogAbyss.new
|
24
|
-
la.squeal
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class LogInner
|
29
|
-
include Loggable
|
30
|
-
|
31
|
-
def screech
|
32
|
-
ldi = LogDepths.new
|
33
|
-
log "hello from the innerds"
|
34
|
-
ldi.speak
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class LogStackTestCase < Test::Unit::TestCase
|
39
|
-
include Loggable
|
40
|
-
|
41
|
-
def test_stack
|
42
|
-
Log.set_widths(-15, 4, -40)
|
43
|
-
|
44
|
-
log = Proc.new {
|
45
|
-
li = LogInner.new
|
46
|
-
li.screech
|
47
|
-
}
|
48
|
-
|
49
|
-
expected_output = [
|
50
|
-
"[ ...: 33] {LogInner#screech } hello from the innerds",
|
51
|
-
"[ ...: 22] {LogDepths#speak } hello from the depths",
|
52
|
-
"[ ...: 13] {LogAbyss#squeal } hello from the abyss",
|
53
|
-
"[ ...: 14] {LogAbyss#squeal } turtles all the way down",
|
54
|
-
"[ ...: 24] {speak } ",
|
55
|
-
"[ ...: 34] {screech } ",
|
56
|
-
]
|
57
|
-
|
58
|
-
run_test @verbose_setup, log, *expected_output
|
59
|
-
end
|
60
|
-
|
61
|
-
# the ctor is down here so the lines above are less likely to change.
|
62
|
-
def initialize test, name = nil
|
63
|
-
@nonverbose_setup = Proc.new {
|
64
|
-
Log.verbose = false
|
65
|
-
Log.output = StringIO.new
|
66
|
-
}
|
67
|
-
|
68
|
-
@verbose_setup = Proc.new {
|
69
|
-
Log.verbose = true
|
70
|
-
Log.output = StringIO.new
|
71
|
-
}
|
72
|
-
|
73
|
-
super test
|
74
|
-
end
|
75
|
-
|
76
|
-
def run_test setup, log, *expected
|
77
|
-
io = setup.call
|
78
|
-
puts "io: #{io}"
|
79
|
-
|
80
|
-
log.call
|
81
|
-
|
82
|
-
assert_not_nil io
|
83
|
-
str = io.string
|
84
|
-
assert_not_nil str
|
85
|
-
|
86
|
-
lines = str.split "\n"
|
87
|
-
|
88
|
-
puts lines
|
89
|
-
|
90
|
-
(0 ... expected.size).each do |idx|
|
91
|
-
if expected[idx]
|
92
|
-
assert_equal expected[idx], lines[idx], "index: #{idx}"
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
Log.output = io
|
97
|
-
end
|
98
|
-
end
|
@@ -1,254 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'pathname'
|
5
|
-
require 'test/unit'
|
6
|
-
require 'stringio'
|
7
|
-
require 'riel/log'
|
8
|
-
require 'riel/testlog/logtestee'
|
9
|
-
|
10
|
-
class LogTestCase < Test::Unit::TestCase
|
11
|
-
include Loggable
|
12
|
-
|
13
|
-
def test_no_output
|
14
|
-
# I could make this an instance variable, but I want to check the method
|
15
|
-
# names in the output string.
|
16
|
-
|
17
|
-
log = Proc.new {
|
18
|
-
Log.log "hello, world?"
|
19
|
-
Log.debug "hello, world?"
|
20
|
-
Log.info "hello, world?"
|
21
|
-
Log.warn "EXPECTED OUTPUT TO STDERR: hello, world." # will go to stderr
|
22
|
-
Log.error "EXPECTED OUTPUT TO STDERR: hello, world." # will go to stderr
|
23
|
-
Log.stack "hello, world?"
|
24
|
-
}
|
25
|
-
|
26
|
-
run_test @nonverbose_setup, log
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_output_arg
|
30
|
-
log = Proc.new {
|
31
|
-
Log.log "hello, world?"
|
32
|
-
Log.debug "hello, world?"
|
33
|
-
Log.info "hello, world?"
|
34
|
-
Log.warn "hello, world?"
|
35
|
-
Log.error "hello, world?"
|
36
|
-
Log.stack "hello, world?"
|
37
|
-
}
|
38
|
-
|
39
|
-
methname = if RUBY_VERSION == "1.8.7" then "test_output_arg" else "block in test_output_arg" end
|
40
|
-
|
41
|
-
expected = Array.new
|
42
|
-
(1 .. 6).each do |lnum|
|
43
|
-
expected << sprintf("[ ...testlog/log_test.rb: %2d] {%-20s} hello, world?", 30 + lnum, methname[0 .. 19])
|
44
|
-
end
|
45
|
-
expected << "[ ...testlog/log_test.rb: 234] {call } "
|
46
|
-
expected << "[ ...testlog/log_test.rb: 234] {run_test } "
|
47
|
-
expected << "[ ...testlog/log_test.rb: 49] {test_output_arg } "
|
48
|
-
|
49
|
-
run_test @verbose_setup, log, *expected
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_output_block
|
53
|
-
log = Proc.new {
|
54
|
-
Log.log { "output block" }
|
55
|
-
}
|
56
|
-
|
57
|
-
Log.set_default_widths
|
58
|
-
# run_test @verbose_setup, log, "[ ...test/riel/log_test.rb: 73] {test_output_block } output block"
|
59
|
-
|
60
|
-
info_setup = Proc.new {
|
61
|
-
Log.level = Log::INFO
|
62
|
-
Log.output = StringIO.new
|
63
|
-
}
|
64
|
-
|
65
|
-
evaluated = false
|
66
|
-
log = Proc.new {
|
67
|
-
Log.debug { evaluated = true; "hello, world?" }
|
68
|
-
}
|
69
|
-
|
70
|
-
# run_test info_setup, log
|
71
|
-
|
72
|
-
assert_equal false, evaluated
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_instance_log
|
76
|
-
log = Proc.new {
|
77
|
-
log "hello, world?"
|
78
|
-
}
|
79
|
-
|
80
|
-
Log.set_widths(-15, 4, -40)
|
81
|
-
# the class name is different in 1.8 and 1.9, so we won't test it.
|
82
|
-
# run_test(@verbose_setup, log, "[ ...log_test.rb: 96] {LogTestCase#test_instance_log } hello, world?")
|
83
|
-
run_test @verbose_setup, log, nil
|
84
|
-
|
85
|
-
Log.set_default_widths
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_colors
|
89
|
-
log = Proc.new {
|
90
|
-
white "white wedding"
|
91
|
-
blue "blue iris"
|
92
|
-
on_cyan "red"
|
93
|
-
}
|
94
|
-
|
95
|
-
# test_col has become 'block in test colors' in 1.9
|
96
|
-
# run_test(@verbose_setup, log,
|
97
|
-
# "[ ...test/riel/log_test.rb: 107] {LogTestCase#test_col} \e[37mwhite wedding\e[0m",
|
98
|
-
# "[ ...test/riel/log_test.rb: 108] {LogTestCase#test_col} \e[34mblue iris\e[0m",
|
99
|
-
# "[ ...test/riel/log_test.rb: 109] {LogTestCase#test_col} \e[46mred\e[0m")
|
100
|
-
|
101
|
-
Log.set_default_widths
|
102
|
-
end
|
103
|
-
|
104
|
-
def run_format_test(expected, &blk)
|
105
|
-
Log.verbose = true
|
106
|
-
io = StringIO.new
|
107
|
-
Log.output = io
|
108
|
-
Log.set_default_widths
|
109
|
-
|
110
|
-
blk.call
|
111
|
-
|
112
|
-
lt = LogTestee.new
|
113
|
-
lt.format_test
|
114
|
-
|
115
|
-
puts io.string
|
116
|
-
|
117
|
-
assert_equal expected.join(''), io.string
|
118
|
-
|
119
|
-
Log.set_default_widths
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_format_default
|
123
|
-
puts "test_format_default"
|
124
|
-
|
125
|
-
expected = Array.new
|
126
|
-
expected << "[ ...testlog/logtestee.rb: 10] {format_test } tamrof\n"
|
127
|
-
|
128
|
-
run_format_test expected do
|
129
|
-
Log.set_default_widths
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_format_flush_filename_left
|
134
|
-
puts "test_format_flush_filename_left"
|
135
|
-
|
136
|
-
expected = Array.new
|
137
|
-
expected << "[ ...test/riel/testlog/logtestee.rb: 10] {format_test } tamrof\n"
|
138
|
-
|
139
|
-
run_format_test expected do
|
140
|
-
Log.set_widths(-35, Log::DEFAULT_LINENUM_WIDTH, Log::DEFAULT_FUNCTION_WIDTH)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_format_flush_linenum_left
|
145
|
-
puts "test_format_flush_linenum_left"
|
146
|
-
|
147
|
-
expected = Array.new
|
148
|
-
expected << "[ ...testlog/logtestee.rb:10 ] {format_test } tamrof\n"
|
149
|
-
|
150
|
-
run_format_test expected do
|
151
|
-
Log.set_widths(Log::DEFAULT_FILENAME_WIDTH, -10, Log::DEFAULT_FUNCTION_WIDTH)
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
def test_format_flush_function_right
|
156
|
-
puts "test_format_flush_function_right"
|
157
|
-
|
158
|
-
expected = Array.new
|
159
|
-
expected << "[ ...testlog/logtestee.rb: 10] { format_test} tamrof\n"
|
160
|
-
|
161
|
-
run_format_test expected do
|
162
|
-
Log.set_widths(Log::DEFAULT_FILENAME_WIDTH, Log::DEFAULT_LINENUM_WIDTH, 35)
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
def test_format_pad_linenum_zeros
|
167
|
-
puts "test_format_pad_linenum_zeros"
|
168
|
-
|
169
|
-
expected = Array.new
|
170
|
-
expected << "[ ...testlog/logtestee.rb:00000010] {format_test } tamrof\n"
|
171
|
-
|
172
|
-
run_format_test expected do
|
173
|
-
Log.set_widths(Log::DEFAULT_FILENAME_WIDTH, "08", Log::DEFAULT_FUNCTION_WIDTH)
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
def test_color
|
178
|
-
Log.verbose = true
|
179
|
-
io = StringIO.new
|
180
|
-
Log.output = io
|
181
|
-
Log.set_default_widths
|
182
|
-
|
183
|
-
expected = Array.new
|
184
|
-
expected << "[ ...testlog/logtestee.rb: 6] {color_test } [34mazul[0m\n"
|
185
|
-
|
186
|
-
lt = LogTestee.new
|
187
|
-
lt.color_test
|
188
|
-
|
189
|
-
puts io.string
|
190
|
-
|
191
|
-
assert_equal expected.join(''), io.string
|
192
|
-
end
|
193
|
-
|
194
|
-
# the ctor is down here so the lines above are less likely to change.
|
195
|
-
def initialize test, name = nil
|
196
|
-
@nonverbose_setup = Proc.new {
|
197
|
-
Log.verbose = false
|
198
|
-
Log.output = StringIO.new
|
199
|
-
}
|
200
|
-
|
201
|
-
@verbose_setup = Proc.new {
|
202
|
-
Log.verbose = true
|
203
|
-
Log.output = StringIO.new
|
204
|
-
}
|
205
|
-
|
206
|
-
super test
|
207
|
-
end
|
208
|
-
|
209
|
-
def exec_test setup, log, expected = Array.new
|
210
|
-
io = setup.call
|
211
|
-
|
212
|
-
log.call
|
213
|
-
|
214
|
-
assert_not_nil io
|
215
|
-
str = io.string
|
216
|
-
assert_not_nil str
|
217
|
-
|
218
|
-
lines = str.split "\n"
|
219
|
-
|
220
|
-
unless expected.empty?
|
221
|
-
(0 ... expected.size).each do |idx|
|
222
|
-
if expected[idx]
|
223
|
-
assert_equal expected[idx], lines[idx], "index: #{idx}"
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
Log.output = io
|
229
|
-
end
|
230
|
-
|
231
|
-
def run_test setup, log, *expected
|
232
|
-
io = setup.call
|
233
|
-
|
234
|
-
log.call
|
235
|
-
|
236
|
-
assert_not_nil io
|
237
|
-
str = io.string
|
238
|
-
assert_not_nil str
|
239
|
-
|
240
|
-
lines = str.split "\n"
|
241
|
-
|
242
|
-
(0 ... expected.size).each do |idx|
|
243
|
-
if expected[idx]
|
244
|
-
assert_equal expected[idx], lines[idx], "index: #{idx}"
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
Log.output = io
|
249
|
-
end
|
250
|
-
|
251
|
-
def test_respond_to_color
|
252
|
-
assert Log.respond_to? :blue
|
253
|
-
end
|
254
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'pathname'
|
5
|
-
require 'test/unit'
|
6
|
-
require 'stringio'
|
7
|
-
require 'riel/log/log'
|
8
|
-
require 'riel/log/loggable'
|
9
|
-
require 'riel/testlog/lgbl_testee'
|
10
|
-
|
11
|
-
class LoggableTestCase < Test::Unit::TestCase
|
12
|
-
include RIEL::Loggable
|
13
|
-
|
14
|
-
def test_instance_colors
|
15
|
-
RIEL::Log.verbose = true
|
16
|
-
io = StringIO.new
|
17
|
-
RIEL::Log.output = io
|
18
|
-
|
19
|
-
expected = Array.new
|
20
|
-
expected << "[...testlog/lgbl_testee.rb: 11] {LgblTestee#crystal } hello!\n"
|
21
|
-
expected << "[...testlog/lgbl_testee.rb: 12] {LgblTestee#crystal } [34mazul ... [0m\n"
|
22
|
-
expected << "[...testlog/lgbl_testee.rb: 13] {LgblTestee#crystal } [31mrojo?[0m\n"
|
23
|
-
|
24
|
-
te = LgblTestee.new
|
25
|
-
te.crystal
|
26
|
-
|
27
|
-
# puts io.string
|
28
|
-
|
29
|
-
assert_equal expected.join(''), io.string
|
30
|
-
end
|
31
|
-
end
|