riel 1.1.16 → 1.1.17
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -37
- data/lib/riel/log/log.rb +17 -24
- data/lib/riel/log/loggable.rb +13 -15
- data/lib/riel/log/logger.rb +34 -66
- data/lib/riel/log.rb +0 -63
- data/lib/riel/optproc.rb +0 -3
- data/lib/riel/string.rb +0 -2
- data/lib/riel.rb +1 -1
- data/test/riel/log/format_test.rb +48 -0
- data/test/riel/optproc_test.rb +1 -30
- data/test/riel/{log_stack_test.rb → testlog/log_stack_test.rb} +0 -0
- data/test/riel/testlog/log_test.rb +254 -0
- data/test/riel/testlog/loggable_test.rb +31 -0
- metadata +89 -133
- data/lib/riel/ansicolor.rb +0 -91
- data/lib/riel/asciitable/cell.rb +0 -82
- data/lib/riel/asciitable/column.rb +0 -26
- data/lib/riel/asciitable/row.rb +0 -105
- data/lib/riel/asciitable/table.rb +0 -295
- data/lib/riel/text/ansi/ansi_color.rb +0 -31
- data/lib/riel/text/ansi/ansi_colors.rb +0 -16
- data/lib/riel/text/ansi/ansi_highlight.rb +0 -69
- data/lib/riel/text/ansi/ansi_list.rb +0 -17
- data/lib/riel/text/ansi/ansi_palette.rb +0 -48
- data/lib/riel/text/ansi/attributes.rb +0 -21
- data/lib/riel/text/ansi/backgrounds.rb +0 -13
- data/lib/riel/text/ansi/color.rb +0 -62
- data/lib/riel/text/ansi/foregrounds.rb +0 -12
- data/lib/riel/text/ansi/grey.rb +0 -30
- data/lib/riel/text/ansi/grey_palette.rb +0 -36
- data/lib/riel/text/ansi/palette.rb +0 -18
- data/lib/riel/text/ansi/rgb_color.rb +0 -28
- data/lib/riel/text/ansi/rgb_highlighter.rb +0 -73
- data/lib/riel/text/ansi/rgb_palette.rb +0 -49
- data/lib/riel/text/highlight.rb +0 -130
- data/lib/riel/text/highlightable.rb +0 -85
- data/lib/riel/text/html_highlight.rb +0 -98
- data/lib/riel/text/non_highlight.rb +0 -17
- data/lib/riel/text/string.rb +0 -10
- data/lib/riel/text.rb +0 -4
- data/test/riel/asciitable/table_test.rb +0 -77
- data/test/riel/log_test.rb +0 -164
- data/test/riel/text/ansi/ansi_highlight_test.rb +0 -116
- data/test/riel/text/ansi/ansi_palette_test.rb +0 -65
- data/test/riel/text/ansi/grey_palette_test.rb +0 -39
- data/test/riel/text/ansi/rgb_highlighter_test.rb +0 -99
- data/test/riel/text/ansi/rgb_palette_test.rb +0 -122
- data/test/riel/text/highlightable_test.rb +0 -24
- data/test/riel/text/string_test.rb +0 -47
- data/test/riel/text_test.rb +0 -62
@@ -0,0 +1,254 @@
|
|
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
|
@@ -0,0 +1,31 @@
|
|
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
|
metadata
CHANGED
@@ -1,184 +1,140 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: riel
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.17
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
- 16
|
10
|
-
version: 1.1.16
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jeff Pace
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
date: 2013-03-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rainbow
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.1.4
|
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: 1.1.4
|
22
30
|
description: This library extends the core Ruby libraries.
|
23
31
|
email: jeugenepace@gmail.com
|
24
32
|
executables: []
|
25
|
-
|
26
33
|
extensions: []
|
27
|
-
|
28
|
-
extra_rdoc_files:
|
34
|
+
extra_rdoc_files:
|
29
35
|
- README.md
|
30
|
-
files:
|
36
|
+
files:
|
37
|
+
- lib/riel.rb
|
31
38
|
- lib/riel/array.rb
|
32
|
-
- lib/riel/
|
39
|
+
- lib/riel/command.rb
|
40
|
+
- lib/riel/date.rb
|
41
|
+
- lib/riel/dir.rb
|
33
42
|
- lib/riel/enumerable.rb
|
34
|
-
- lib/riel/
|
35
|
-
- lib/riel/hash.rb
|
43
|
+
- lib/riel/env.rb
|
36
44
|
- lib/riel/fdprocessor.rb
|
37
|
-
- lib/riel/dir.rb
|
38
|
-
- lib/riel/matchdata.rb
|
39
|
-
- lib/riel/regexp.rb
|
40
|
-
- lib/riel/text.rb
|
41
|
-
- lib/riel/setdiff.rb
|
42
|
-
- lib/riel/asciitable/column.rb
|
43
|
-
- lib/riel/asciitable/cell.rb
|
44
|
-
- lib/riel/asciitable/table.rb
|
45
|
-
- lib/riel/asciitable/row.rb
|
46
|
-
- lib/riel/io.rb
|
47
|
-
- lib/riel/tempfile.rb
|
48
|
-
- lib/riel/string.rb
|
49
|
-
- lib/riel/command.rb
|
50
|
-
- lib/riel/text/non_highlight.rb
|
51
|
-
- lib/riel/text/html_highlight.rb
|
52
|
-
- lib/riel/text/string.rb
|
53
|
-
- lib/riel/text/highlightable.rb
|
54
|
-
- lib/riel/text/highlight.rb
|
55
|
-
- lib/riel/text/ansi/backgrounds.rb
|
56
|
-
- lib/riel/text/ansi/color.rb
|
57
|
-
- lib/riel/text/ansi/ansi_color.rb
|
58
|
-
- lib/riel/text/ansi/rgb_color.rb
|
59
|
-
- lib/riel/text/ansi/attributes.rb
|
60
|
-
- lib/riel/text/ansi/rgb_highlighter.rb
|
61
|
-
- lib/riel/text/ansi/ansi_highlight.rb
|
62
|
-
- lib/riel/text/ansi/grey_palette.rb
|
63
|
-
- lib/riel/text/ansi/ansi_palette.rb
|
64
|
-
- lib/riel/text/ansi/rgb_palette.rb
|
65
|
-
- lib/riel/text/ansi/foregrounds.rb
|
66
|
-
- lib/riel/text/ansi/ansi_colors.rb
|
67
|
-
- lib/riel/text/ansi/palette.rb
|
68
|
-
- lib/riel/text/ansi/grey.rb
|
69
|
-
- lib/riel/text/ansi/ansi_list.rb
|
70
|
-
- lib/riel/pathname.rb
|
71
45
|
- lib/riel/file.rb
|
46
|
+
- lib/riel/filetype.rb
|
47
|
+
- lib/riel/hash.rb
|
72
48
|
- lib/riel/integer.rb
|
73
|
-
- lib/riel/
|
74
|
-
- lib/riel/
|
49
|
+
- lib/riel/io.rb
|
50
|
+
- lib/riel/log.rb
|
51
|
+
- lib/riel/log/log.rb
|
75
52
|
- lib/riel/log/loggable.rb
|
76
|
-
- lib/riel/log/severity.rb
|
77
53
|
- lib/riel/log/logger.rb
|
78
|
-
- lib/riel/log/
|
79
|
-
- lib/riel/
|
80
|
-
- lib/riel/
|
54
|
+
- lib/riel/log/severity.rb
|
55
|
+
- lib/riel/matchdata.rb
|
56
|
+
- lib/riel/optproc.rb
|
57
|
+
- lib/riel/pathname.rb
|
81
58
|
- lib/riel/rcfile.rb
|
82
|
-
- lib/riel/
|
83
|
-
- lib/riel/
|
84
|
-
- lib/riel.rb
|
85
|
-
-
|
86
|
-
-
|
87
|
-
-
|
59
|
+
- lib/riel/regexp.rb
|
60
|
+
- lib/riel/setdiff.rb
|
61
|
+
- lib/riel/size_converter.rb
|
62
|
+
- lib/riel/string.rb
|
63
|
+
- lib/riel/tempfile.rb
|
64
|
+
- lib/riel/timer.rb
|
88
65
|
- test/riel/array_test.rb
|
89
|
-
- test/riel/
|
90
|
-
- test/riel/
|
66
|
+
- test/riel/command_test.rb
|
67
|
+
- test/riel/date_test.rb
|
91
68
|
- test/riel/dir_test.rb
|
92
|
-
- test/riel/file_test.rb
|
93
|
-
- test/riel/regexp_test.rb
|
94
69
|
- test/riel/enumerable_test.rb
|
95
|
-
- test/riel/
|
96
|
-
- test/riel/
|
97
|
-
- test/riel/optproc_test.rb
|
98
|
-
- test/riel/io_test.rb
|
99
|
-
- test/riel/tempfile_test.rb
|
70
|
+
- test/riel/env_test.rb
|
71
|
+
- test/riel/file_test.rb
|
100
72
|
- test/riel/filetype_test.rb
|
101
|
-
- test/riel/
|
102
|
-
- test/riel/text/ansi/ansi_palette_test.rb
|
103
|
-
- test/riel/text/ansi/rgb_palette_test.rb
|
104
|
-
- test/riel/text/ansi/grey_palette_test.rb
|
105
|
-
- test/riel/text/ansi/ansi_highlight_test.rb
|
106
|
-
- test/riel/text/ansi/rgb_highlighter_test.rb
|
107
|
-
- test/riel/text/string_test.rb
|
108
|
-
- test/riel/text/highlightable_test.rb
|
73
|
+
- test/riel/hash_test.rb
|
109
74
|
- test/riel/integer_test.rb
|
75
|
+
- test/riel/io_test.rb
|
76
|
+
- test/riel/log/format_test.rb
|
77
|
+
- test/riel/matchdata_test.rb
|
78
|
+
- test/riel/optproc_test.rb
|
79
|
+
- test/riel/pathname_test.rb
|
110
80
|
- test/riel/rcfile_test.rb
|
111
|
-
- test/riel/
|
112
|
-
- test/riel/hash_test.rb
|
81
|
+
- test/riel/regexp_test.rb
|
113
82
|
- test/riel/setdiff_test.rb
|
83
|
+
- test/riel/size_converter_test.rb
|
114
84
|
- test/riel/string_test.rb
|
115
|
-
- test/riel/
|
85
|
+
- test/riel/tempfile_test.rb
|
86
|
+
- test/riel/testlog/log_stack_test.rb
|
87
|
+
- test/riel/testlog/log_test.rb
|
88
|
+
- test/riel/testlog/loggable_test.rb
|
116
89
|
- test/riel/timer_test.rb
|
117
90
|
- README.md
|
118
|
-
has_rdoc: true
|
119
91
|
homepage: http://www.incava.org/projects/riel
|
120
92
|
licenses: []
|
121
|
-
|
122
93
|
post_install_message:
|
123
94
|
rdoc_options: []
|
124
|
-
|
125
|
-
require_paths:
|
95
|
+
require_paths:
|
126
96
|
- lib
|
127
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
98
|
none: false
|
129
|
-
requirements:
|
130
|
-
- -
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
|
133
|
-
|
134
|
-
- 0
|
135
|
-
version: "0"
|
136
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
104
|
none: false
|
138
|
-
requirements:
|
139
|
-
- -
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
|
142
|
-
segments:
|
143
|
-
- 0
|
144
|
-
version: "0"
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
145
109
|
requirements: []
|
146
|
-
|
147
110
|
rubyforge_project:
|
148
|
-
rubygems_version: 1.
|
111
|
+
rubygems_version: 1.8.23
|
149
112
|
signing_key:
|
150
113
|
specification_version: 3
|
151
114
|
summary: Extensions to core Ruby code.
|
152
|
-
test_files:
|
153
|
-
- test/riel/date_test.rb
|
154
|
-
- test/riel/size_converter_test.rb
|
155
|
-
- test/riel/env_test.rb
|
115
|
+
test_files:
|
156
116
|
- test/riel/array_test.rb
|
157
|
-
- test/riel/
|
158
|
-
- test/riel/
|
117
|
+
- test/riel/command_test.rb
|
118
|
+
- test/riel/date_test.rb
|
159
119
|
- test/riel/dir_test.rb
|
160
|
-
- test/riel/file_test.rb
|
161
|
-
- test/riel/regexp_test.rb
|
162
120
|
- test/riel/enumerable_test.rb
|
163
|
-
- test/riel/
|
164
|
-
- test/riel/
|
165
|
-
- test/riel/optproc_test.rb
|
166
|
-
- test/riel/io_test.rb
|
167
|
-
- test/riel/tempfile_test.rb
|
121
|
+
- test/riel/env_test.rb
|
122
|
+
- test/riel/file_test.rb
|
168
123
|
- test/riel/filetype_test.rb
|
169
|
-
- test/riel/
|
170
|
-
- test/riel/text/ansi/ansi_palette_test.rb
|
171
|
-
- test/riel/text/ansi/rgb_palette_test.rb
|
172
|
-
- test/riel/text/ansi/grey_palette_test.rb
|
173
|
-
- test/riel/text/ansi/ansi_highlight_test.rb
|
174
|
-
- test/riel/text/ansi/rgb_highlighter_test.rb
|
175
|
-
- test/riel/text/string_test.rb
|
176
|
-
- test/riel/text/highlightable_test.rb
|
124
|
+
- test/riel/hash_test.rb
|
177
125
|
- test/riel/integer_test.rb
|
126
|
+
- test/riel/io_test.rb
|
127
|
+
- test/riel/log/format_test.rb
|
128
|
+
- test/riel/matchdata_test.rb
|
129
|
+
- test/riel/optproc_test.rb
|
130
|
+
- test/riel/pathname_test.rb
|
178
131
|
- test/riel/rcfile_test.rb
|
179
|
-
- test/riel/
|
180
|
-
- test/riel/hash_test.rb
|
132
|
+
- test/riel/regexp_test.rb
|
181
133
|
- test/riel/setdiff_test.rb
|
134
|
+
- test/riel/size_converter_test.rb
|
182
135
|
- test/riel/string_test.rb
|
183
|
-
- test/riel/
|
136
|
+
- test/riel/tempfile_test.rb
|
137
|
+
- test/riel/testlog/log_stack_test.rb
|
138
|
+
- test/riel/testlog/log_test.rb
|
139
|
+
- test/riel/testlog/loggable_test.rb
|
184
140
|
- test/riel/timer_test.rb
|
data/lib/riel/ansicolor.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
# Attribute codes:
|
5
|
-
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
|
6
|
-
# Text color codes:
|
7
|
-
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
|
8
|
-
# Background color codes:
|
9
|
-
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
|
10
|
-
|
11
|
-
module ANSIColor
|
12
|
-
ATTRIBUTES = Hash[
|
13
|
-
'none' => '0',
|
14
|
-
'reset' => '0',
|
15
|
-
'bold' => '1',
|
16
|
-
'underscore' => '4',
|
17
|
-
'underline' => '4',
|
18
|
-
'blink' => '5',
|
19
|
-
'reverse' => '7',
|
20
|
-
'concealed' => '8',
|
21
|
-
'black' => '30',
|
22
|
-
'red' => '31',
|
23
|
-
'green' => '32',
|
24
|
-
'yellow' => '33',
|
25
|
-
'blue' => '34',
|
26
|
-
'magenta' => '35',
|
27
|
-
'cyan' => '36',
|
28
|
-
'white' => '37',
|
29
|
-
'on_black' => '40',
|
30
|
-
'on_red' => '41',
|
31
|
-
'on_green' => '42',
|
32
|
-
'on_yellow' => '43',
|
33
|
-
'on_blue' => '44',
|
34
|
-
'on_magenta' => '45',
|
35
|
-
'on_cyan' => '46',
|
36
|
-
'on_white' => '47',
|
37
|
-
]
|
38
|
-
|
39
|
-
ATTRIBUTES.each do |name, val|
|
40
|
-
eval <<-EODEF
|
41
|
-
def ANSIColor.#{name}
|
42
|
-
"\\e[#{val}m"
|
43
|
-
end
|
44
|
-
EODEF
|
45
|
-
end
|
46
|
-
|
47
|
-
def ANSIColor.attributes
|
48
|
-
ATTRIBUTES.collect { |name, val| name }
|
49
|
-
end
|
50
|
-
|
51
|
-
# returns the code for the given color string, which is in the format:
|
52
|
-
# [foreground] on [background]. Note that the foreground and background sections
|
53
|
-
# can have modifiers (attributes). Examples:
|
54
|
-
# black
|
55
|
-
# blue on white
|
56
|
-
# bold green on yellow
|
57
|
-
# underscore bold magenta on cyan
|
58
|
-
# underscore red on bold cyan
|
59
|
-
|
60
|
-
def ANSIColor.code str
|
61
|
-
fg, bg = str.split(/\s*\bon_?\s*/)
|
62
|
-
(fg ? foreground(fg) : "") + (bg ? background(bg) : "")
|
63
|
-
end
|
64
|
-
|
65
|
-
# returns the code for the given background color(s)
|
66
|
-
def ANSIColor.background bgcolor
|
67
|
-
make_code "on_" + bgcolor
|
68
|
-
end
|
69
|
-
|
70
|
-
# returns the code for the given foreground color(s)
|
71
|
-
def ANSIColor.foreground fgcolor
|
72
|
-
make_code fgcolor
|
73
|
-
end
|
74
|
-
|
75
|
-
protected
|
76
|
-
|
77
|
-
def ANSIColor.make_code str
|
78
|
-
if str
|
79
|
-
str.split.collect do |s|
|
80
|
-
if attr = ATTRIBUTES[s]
|
81
|
-
"\e[#{attr}m"
|
82
|
-
else
|
83
|
-
$stderr.puts "WARNING: ANSIColor::make_code(" + str + "): unknown color: " + s
|
84
|
-
return ""
|
85
|
-
end
|
86
|
-
end.join ""
|
87
|
-
else
|
88
|
-
""
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|