tb 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/README +62 -50
  2. data/bin/tb +22 -18
  3. data/lib/tb.rb +35 -19
  4. data/lib/tb/basic.rb +85 -86
  5. data/lib/tb/catreader.rb +33 -116
  6. data/lib/tb/cmd_cat.rb +31 -27
  7. data/lib/tb/cmd_consecutive.rb +45 -35
  8. data/lib/tb/cmd_crop.rb +86 -52
  9. data/lib/tb/cmd_cross.rb +113 -71
  10. data/lib/tb/cmd_cut.rb +49 -44
  11. data/lib/tb/cmd_git_log.rb +193 -0
  12. data/lib/tb/cmd_grep.rb +43 -32
  13. data/lib/tb/cmd_group.rb +63 -39
  14. data/lib/tb/cmd_gsub.rb +53 -43
  15. data/lib/tb/cmd_help.rb +51 -24
  16. data/lib/tb/cmd_join.rb +32 -35
  17. data/lib/tb/cmd_ls.rb +233 -205
  18. data/lib/tb/cmd_mheader.rb +47 -37
  19. data/lib/tb/cmd_nest.rb +94 -0
  20. data/lib/tb/cmd_newfield.rb +29 -33
  21. data/lib/tb/cmd_rename.rb +40 -32
  22. data/lib/tb/cmd_shape.rb +31 -24
  23. data/lib/tb/cmd_sort.rb +46 -25
  24. data/lib/tb/cmd_svn_log.rb +47 -28
  25. data/lib/tb/cmd_tar_tvf.rb +447 -0
  26. data/lib/tb/cmd_to_csv.rb +60 -0
  27. data/lib/tb/cmd_to_json.rb +60 -0
  28. data/lib/tb/cmd_to_pnm.rb +48 -0
  29. data/lib/tb/cmd_to_pp.rb +71 -0
  30. data/lib/tb/cmd_to_tsv.rb +48 -0
  31. data/lib/tb/cmd_to_yaml.rb +52 -0
  32. data/lib/tb/cmd_unnest.rb +118 -0
  33. data/lib/tb/cmdmain.rb +24 -20
  34. data/lib/tb/cmdtop.rb +33 -25
  35. data/lib/tb/cmdutil.rb +26 -66
  36. data/lib/tb/csv.rb +46 -34
  37. data/lib/tb/enum.rb +294 -0
  38. data/lib/tb/enumerable.rb +198 -7
  39. data/lib/tb/enumerator.rb +73 -0
  40. data/lib/tb/fieldset.rb +27 -19
  41. data/lib/tb/fileenumerator.rb +365 -0
  42. data/lib/tb/json.rb +50 -0
  43. data/lib/tb/pager.rb +6 -6
  44. data/lib/tb/pairs.rb +227 -0
  45. data/lib/tb/pnm.rb +23 -22
  46. data/lib/tb/reader.rb +52 -49
  47. data/lib/tb/record.rb +48 -19
  48. data/lib/tb/revcmp.rb +38 -0
  49. data/lib/tb/ropen.rb +74 -57
  50. data/lib/tb/search.rb +25 -21
  51. data/lib/tb/tsv.rb +31 -34
  52. data/sample/excel2csv +24 -20
  53. data/sample/poi-xls2csv.rb +24 -20
  54. data/sample/poi-xls2csv.sh +22 -18
  55. data/sample/tbplot +185 -127
  56. data/test-all-cov.rb +3 -3
  57. data/test-all.rb +1 -1
  58. data/test/test_basic.rb +26 -10
  59. data/test/test_catreader.rb +7 -6
  60. data/test/test_cmd_cat.rb +32 -0
  61. data/test/test_cmd_consecutive.rb +10 -0
  62. data/test/test_cmd_crop.rb +4 -4
  63. data/test/test_cmd_cross.rb +16 -4
  64. data/test/test_cmd_git_log.rb +46 -0
  65. data/test/test_cmd_help.rb +17 -12
  66. data/test/test_cmd_join.rb +21 -1
  67. data/test/test_cmd_ls.rb +3 -4
  68. data/test/test_cmd_mheader.rb +17 -11
  69. data/test/test_cmd_nest.rb +49 -0
  70. data/test/test_cmd_sort.rb +15 -0
  71. data/test/test_cmd_tar_tvf.rb +281 -0
  72. data/test/{test_cmd_csv.rb → test_cmd_to_csv.rb} +35 -21
  73. data/test/{test_cmd_json.rb → test_cmd_to_json.rb} +31 -3
  74. data/test/{test_cmd_pnm.rb → test_cmd_to_pnm.rb} +2 -2
  75. data/test/{test_cmd_pp.rb → test_cmd_to_pp.rb} +4 -4
  76. data/test/{test_cmd_tsv.rb → test_cmd_to_tsv.rb} +4 -4
  77. data/test/{test_cmd_yaml.rb → test_cmd_to_yaml.rb} +3 -3
  78. data/test/test_cmd_unnest.rb +89 -0
  79. data/test/test_cmdtty.rb +19 -13
  80. data/test/test_enumerable.rb +83 -1
  81. data/test/test_fileenumerator.rb +265 -0
  82. data/test/test_json.rb +15 -0
  83. data/test/test_pager.rb +3 -4
  84. data/test/test_pairs.rb +122 -0
  85. data/test/test_pnm.rb +24 -24
  86. data/test/test_reader.rb +35 -13
  87. data/test/test_revcmp.rb +10 -0
  88. data/test/test_tbenum.rb +173 -0
  89. metadata +51 -23
  90. data/lib/tb/cmd_csv.rb +0 -42
  91. data/lib/tb/cmd_json.rb +0 -60
  92. data/lib/tb/cmd_pnm.rb +0 -43
  93. data/lib/tb/cmd_pp.rb +0 -70
  94. data/lib/tb/cmd_tsv.rb +0 -43
  95. data/lib/tb/cmd_yaml.rb +0 -47
@@ -0,0 +1,265 @@
1
+ require 'tb'
2
+ require 'test/unit'
3
+
4
+ class TestTbFileEnumerator < Test::Unit::TestCase
5
+ def test_basic
6
+ en = Tb::FileEnumerator.new_tempfile {|gen|
7
+ gen.call 1
8
+ gen.call 2
9
+ gen.call 3
10
+ }
11
+ ary = []
12
+ en.each {|v|
13
+ ary << v
14
+ }
15
+ assert_equal([1, 2, 3], ary)
16
+ end
17
+
18
+ def test_removed_after_simple_use
19
+ en = Tb::FileEnumerator.new_tempfile {|gen|
20
+ }
21
+ assert_nothing_raised { en.each {|v| } }
22
+ assert_raise(ArgumentError) { en.each {|v| } }
23
+ end
24
+
25
+ def test_removed_after_wrapped_use
26
+ en = Tb::FileEnumerator.new_tempfile {|gen|
27
+ }
28
+ en.use {
29
+ assert_nothing_raised { en.each {|v| } }
30
+ assert_nothing_raised { en.each {|v| } }
31
+ }
32
+ assert_raise(ArgumentError) { en.each {|v| } }
33
+ end
34
+
35
+ def test_to_fileenumerator
36
+ obj = [1,2,3]
37
+ en = obj.to_fileenumerator
38
+ assert_kind_of(Tb::FileEnumerator, en)
39
+ assert_not_kind_of(Tb::FileHeaderEnumerator, en)
40
+ ary = []
41
+ en.each {|v|
42
+ ary << v
43
+ }
44
+ assert_equal([1, 2, 3], ary)
45
+ end
46
+
47
+ def test_to_fileheaderenumerator
48
+ er = Tb::Enumerator.new {|y|
49
+ y.set_header %w[a b]
50
+ y.yield({"a"=>1, "b"=>2})
51
+ y.yield({"a"=>3})
52
+ }
53
+ en = er.to_fileenumerator
54
+ assert_kind_of(Tb::FileEnumerator, en)
55
+ assert_kind_of(Tb::FileHeaderEnumerator, en)
56
+ ary = []
57
+ en.each {|v|
58
+ ary << v
59
+ }
60
+ assert_equal([{"a"=>1, "b"=>2}, {"a"=>3}], ary)
61
+ end
62
+
63
+ def test_reader_basic
64
+ ary = [1,2,3]
65
+ fe = ary.to_fileenumerator
66
+ iter = fe.each
67
+ assert_respond_to(iter, :next)
68
+ assert_respond_to(iter, :peek)
69
+ assert_equal(1, iter.peek)
70
+ assert_equal(1, iter.peek)
71
+ assert_equal(1, iter.next)
72
+ assert_equal(2, iter.peek)
73
+ assert_equal(2, iter.next)
74
+ assert_equal(3, iter.next)
75
+ assert(!iter.closed?)
76
+ assert_raise(StopIteration) { iter.peek }
77
+ assert(iter.closed?)
78
+ assert_raise(StopIteration) { iter.next }
79
+ assert(iter.closed?)
80
+ end
81
+
82
+ def test_reader_values
83
+ o = Object.new
84
+ def o.each
85
+ yield
86
+ yield 1
87
+ yield 1, 2
88
+ end
89
+ o.extend Enumerable
90
+ fe = o.to_fileenumerator
91
+ iter = fe.each
92
+ assert_respond_to(iter, :next_values)
93
+ assert_respond_to(iter, :peek_values)
94
+ assert_equal([], iter.peek_values)
95
+ assert_equal([], iter.peek_values)
96
+ assert_equal([], iter.next_values)
97
+ assert_equal([1], iter.peek_values)
98
+ assert_equal([1], iter.next_values)
99
+ assert_equal([1,2], iter.next_values)
100
+ assert(!iter.closed?)
101
+ assert_raise(StopIteration) { iter.peek_values }
102
+ assert(iter.closed?)
103
+ assert_raise(StopIteration) { iter.next_values }
104
+ assert(iter.closed?)
105
+ end
106
+
107
+ def test_reader_rewind
108
+ ary = [1,2,3]
109
+ fe = ary.to_fileenumerator
110
+ iter = fe.each
111
+ assert_equal(1, iter.next)
112
+ assert_equal(2, iter.next)
113
+ iter.rewind
114
+ assert_equal(1, iter.next)
115
+ assert_equal(2, iter.next)
116
+ assert_equal(3, iter.next)
117
+ assert(!iter.closed?)
118
+ assert_raise(StopIteration) { iter.next }
119
+ assert(iter.closed?)
120
+ assert_raise(ArgumentError) { iter.rewind }
121
+ assert(iter.closed?)
122
+ end
123
+
124
+ def test_reader_pos
125
+ ary = [1,2,3]
126
+ fe = ary.to_fileenumerator
127
+ iter = fe.each
128
+ assert_respond_to(iter, :next)
129
+ assert_respond_to(iter, :peek)
130
+ pos1 = iter.pos
131
+ assert_equal(1, iter.peek)
132
+ assert_equal(pos1, iter.pos)
133
+ assert_equal(1, iter.peek)
134
+ assert_equal(pos1, iter.pos)
135
+ assert_equal(1, iter.next)
136
+ pos2 = iter.pos
137
+ assert_not_equal(pos1, pos2)
138
+ assert_equal(2, iter.peek)
139
+ assert_equal(pos2, iter.pos)
140
+ assert_equal(2, iter.next)
141
+ assert_equal(3, iter.next)
142
+ posEnd = iter.pos
143
+ iter.pos = pos2
144
+ assert_equal(2, iter.next)
145
+ iter.pos = pos1
146
+ assert_equal(1, iter.next)
147
+ iter.pos = posEnd
148
+ assert(!iter.closed?)
149
+ assert_raise(StopIteration) { iter.next }
150
+ assert(iter.closed?)
151
+ end
152
+
153
+ def test_reader_use
154
+ ary = [1,2]
155
+ fe = ary.to_fileenumerator
156
+ iter = fe.each
157
+ iter.use {
158
+ assert_equal(1, iter.next)
159
+ pos2 = iter.pos
160
+ assert_equal(2, iter.next)
161
+ assert_raise(StopIteration) { iter.next }
162
+ iter.pos = pos2
163
+ assert_equal(2, iter.next)
164
+ assert_raise(StopIteration) { iter.next }
165
+ assert(!iter.closed?)
166
+ }
167
+ assert(iter.closed?)
168
+ end
169
+
170
+ def test_open_reader
171
+ ary = [1,2]
172
+ fe = ary.to_fileenumerator
173
+ iter0 = nil
174
+ fe.open_reader {|iter|
175
+ iter0 = iter
176
+ assert_equal(1, iter.next)
177
+ pos2 = iter.pos
178
+ assert_equal(2, iter.next)
179
+ assert_raise(StopIteration) { iter.next }
180
+ iter.pos = pos2
181
+ assert_equal(2, iter.next)
182
+ assert_raise(StopIteration) { iter.next }
183
+ assert(!iter.closed?)
184
+ }
185
+ assert(iter0.closed?)
186
+ end
187
+
188
+ def test_open_reader2
189
+ ary = [1,2]
190
+ fe = ary.to_fileenumerator
191
+ iter0 = nil
192
+ fe.open_reader {|iter|
193
+ iter0 = iter
194
+ assert_equal(1, iter.next)
195
+ pos2 = iter.pos
196
+ assert_equal(2, iter.next)
197
+ assert_raise(StopIteration) { iter.next }
198
+ iter.pos = pos2
199
+ assert_equal(2, iter.next)
200
+ assert_raise(StopIteration) { iter.next }
201
+ assert(!iter.closed?)
202
+ }
203
+ assert(iter0.closed?)
204
+ end
205
+
206
+ def test_to_fileheaderenumerator_reader
207
+ tb = Tb.new %w[a b], [1, 2], [3, 4]
208
+ fe = tb.to_fileenumerator
209
+ iter = fe.each
210
+ assert_respond_to(iter, :next)
211
+ assert_respond_to(iter, :peek)
212
+ assert_equal([["a", 1], ["b", 2]], iter.peek.to_a)
213
+ assert_equal([["a", 1], ["b", 2]], iter.peek.to_a)
214
+ assert_equal([["a", 1], ["b", 2]], iter.next.to_a)
215
+ assert_equal([["a", 3], ["b", 4]], iter.peek.to_a)
216
+ assert_equal([["a", 3], ["b", 4]], iter.next.to_a)
217
+ assert(!iter.closed?)
218
+ assert_raise(StopIteration) { iter.peek }
219
+ assert(iter.closed?)
220
+ assert_raise(StopIteration) { iter.next }
221
+ assert(iter.closed?)
222
+ end
223
+
224
+ def test_to_fileheaderenumerator_with_header_reader
225
+ tb = Tb.new %w[a b], [1, 2], [3, 4]
226
+ header = nil
227
+ fe = tb.with_header {|h0|
228
+ header = h0
229
+ }.to_fileenumerator
230
+ assert_equal(%w[a b], header)
231
+ iter = fe.each
232
+ assert_respond_to(iter, :next)
233
+ assert_respond_to(iter, :peek)
234
+ assert_equal([["a", 1], ["b", 2]], iter.peek.to_a)
235
+ assert_equal([["a", 1], ["b", 2]], iter.peek.to_a)
236
+ assert_equal([["a", 1], ["b", 2]], iter.next.to_a)
237
+ assert_equal([["a", 3], ["b", 4]], iter.peek.to_a)
238
+ assert_equal([["a", 3], ["b", 4]], iter.next.to_a)
239
+ assert(!iter.closed?)
240
+ assert_raise(StopIteration) { iter.peek }
241
+ assert(iter.closed?)
242
+ assert_raise(StopIteration) { iter.next }
243
+ assert(iter.closed?)
244
+ end
245
+
246
+ def test_fileheaderenumerator_open_reader
247
+ tb = Tb.new %w[a b], [1, 2], [3, 4]
248
+ fe = tb.to_fileenumerator
249
+ iter0 = nil
250
+ fe.open_reader {|iter|
251
+ iter0 = iter
252
+ assert_respond_to(iter, :next)
253
+ assert_respond_to(iter, :peek)
254
+ assert_equal([["a", 1], ["b", 2]], iter.peek.to_a)
255
+ assert_equal([["a", 1], ["b", 2]], iter.peek.to_a)
256
+ assert_equal([["a", 1], ["b", 2]], iter.next.to_a)
257
+ assert_equal([["a", 3], ["b", 4]], iter.peek.to_a)
258
+ assert_equal([["a", 3], ["b", 4]], iter.next.to_a)
259
+ assert_raise(StopIteration) { iter.peek }
260
+ assert_raise(StopIteration) { iter.next }
261
+ assert(!iter.closed?)
262
+ }
263
+ assert(iter0.closed?)
264
+ end
265
+ end
data/test/test_json.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'tb'
2
+ require 'test/unit'
3
+
4
+ class TestTbJSON < Test::Unit::TestCase
5
+ def test_parse
6
+ r = Tb::JSONReader.new('[{"a":1, "b":2}, {"a":3, "b":4}]')
7
+ result = []
8
+ r.with_header {|header|
9
+ result << header
10
+ }.each {|obj|
11
+ result << obj
12
+ }
13
+ assert_equal([nil, {"a"=>1, "b"=>2}, {"a"=>3, "b"=>4}], result)
14
+ end
15
+ end
data/test/test_pager.rb CHANGED
@@ -26,13 +26,12 @@ class TestTbPager < Test::Unit::TestCase
26
26
  end
27
27
 
28
28
  def with_stdout(io)
29
- save = STDOUT.dup
30
- STDOUT.reopen(io)
29
+ save = $stdout
30
+ $stdout = io
31
31
  begin
32
32
  yield
33
33
  ensure
34
- STDOUT.reopen(save)
35
- save.close
34
+ $stdout = save
36
35
  end
37
36
  end
38
37
 
@@ -0,0 +1,122 @@
1
+ require 'tb'
2
+ require 'test/unit'
3
+
4
+ class TestTbPairs < Test::Unit::TestCase
5
+ def test_initialize
6
+ tp = Tb::Pairs.new([["a", 1], ["b", 2]])
7
+ assert_kind_of(Tb::Pairs, tp)
8
+ end
9
+
10
+ def test_ref
11
+ tp = Tb::Pairs.new([["a", 1], ["b", 2]])
12
+ assert_equal(1, tp["a"])
13
+ assert_equal(2, tp["b"])
14
+ assert_equal(nil, tp["z"])
15
+ end
16
+
17
+ def test_each
18
+ tp = Tb::Pairs.new([["a", 1], ["b", 2]])
19
+ result = []
20
+ tp.each {|k, v|
21
+ result << [k, v]
22
+ }
23
+ assert_equal([["a", 1], ["b", 2]], result)
24
+ end
25
+
26
+ def test_each_key
27
+ tp = Tb::Pairs.new([["a", 1], ["b", 2]])
28
+ result = []
29
+ tp.each_key {|k|
30
+ result << k
31
+ }
32
+ assert_equal(["a", "b"], result)
33
+ end
34
+
35
+ def test_each_value
36
+ tp = Tb::Pairs.new([["a", 1], ["b", 2]])
37
+ result = []
38
+ tp.each_value {|v|
39
+ result << v
40
+ }
41
+ assert_equal([1, 2], result)
42
+ end
43
+
44
+ def test_empty?
45
+ tp = Tb::Pairs.new([])
46
+ assert_equal(true, tp.empty?)
47
+ tp = Tb::Pairs.new([["a", 1], ["b", 2]])
48
+ assert_equal(false, tp.empty?)
49
+ end
50
+
51
+ def test_fetch
52
+ tp = Tb::Pairs.new([["a", 1], ["b", 2]])
53
+ assert_equal(false, tp.empty?)
54
+ assert_equal(1, tp.fetch("a"))
55
+ assert_raise(Tb::Pairs::KeyError) { tp.fetch("z") }
56
+ assert_equal(2, tp.fetch("b", 100))
57
+ assert_equal(2, tp.fetch("b") { 200 })
58
+ assert_equal(100, tp.fetch("z", 100))
59
+ assert_equal(200, tp.fetch("z") { 200 })
60
+ assert_raise(ArgumentError) { tp.fetch() }
61
+ assert_raise(ArgumentError) { tp.fetch(1, 2, 3) }
62
+ end
63
+
64
+ def test_has_key?
65
+ tp = Tb::Pairs.new([["a", 1], ["b", 2]])
66
+ assert_equal(true, tp.has_key?("a"))
67
+ assert_equal(false, tp.has_key?("z"))
68
+ end
69
+
70
+ def test_has_value?
71
+ tp = Tb::Pairs.new([["a", 1], ["b", 2]])
72
+ assert_equal(true, tp.has_value?(1))
73
+ assert_equal(false, tp.has_value?(100))
74
+ end
75
+
76
+ def test_index
77
+ tp = Tb::Pairs.new([["a", 1], ["b", 2]])
78
+ assert_equal("b", tp.index(2))
79
+ assert_equal(nil, tp.index(200))
80
+ end
81
+
82
+ def test_invert
83
+ tp = Tb::Pairs.new([["a", 1], ["b", 2]])
84
+ tp2 = tp.invert
85
+ assert_kind_of(Tb::Pairs, tp2)
86
+ assert_equal([[1, "a"], [2, "b"]], tp2.to_a)
87
+ end
88
+
89
+ def test_keys
90
+ tp = Tb::Pairs.new([["a", 1], ["b", 2]])
91
+ assert_equal(["a", "b"], tp.keys)
92
+ end
93
+
94
+ def test_length
95
+ tp = Tb::Pairs.new([["a", 1], ["b", 2]])
96
+ assert_equal(2, tp.length)
97
+ end
98
+
99
+ def test_merge
100
+ tp1 = Tb::Pairs.new([["a", 1], ["b", 2]])
101
+ tp2 = Tb::Pairs.new([["b", 3], ["c", 4]])
102
+ assert_equal([["a", 1], ["b", 3], ["c", 4]], tp1.merge(tp2).to_a)
103
+ assert_equal([["a", 1], ["b", ["b", 2, 3]], ["c", 4]], tp1.merge(tp2) {|k, v1, v2| [k, v1, v2] }.to_a)
104
+ end
105
+
106
+ def test_reject
107
+ tp = Tb::Pairs.new([["a", 1], ["b", 2]])
108
+ assert_equal([["a", 1]], tp.reject {|k, v| k == "b" }.to_a)
109
+ assert_equal([["b", 2]], tp.reject {|k, v| v == 1 }.to_a)
110
+ end
111
+
112
+ def test_values
113
+ tp = Tb::Pairs.new([["a", 1], ["b", 2]])
114
+ assert_equal([1, 2], tp.values)
115
+ end
116
+
117
+ def test_values_at
118
+ tp = Tb::Pairs.new([["a", 1], ["b", 2]])
119
+ assert_equal([1, 2], tp.values_at("a", "b"))
120
+ end
121
+
122
+ end
data/test/test_pnm.rb CHANGED
@@ -341,32 +341,32 @@ class TestTbPNM < Test::Unit::TestCase
341
341
  File.open("gb.pnm", "w") {|f| f << "P5\n1 1\n255\n\0" }
342
342
  File.open("pb.pnm", "w") {|f| f << "P6\n1 1\n255\n\0\0\0" }
343
343
 
344
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("ba.pbm") {|r| r.header })
345
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("pnm:ba") {|r| r.header })
346
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("ga.pgm") {|r| r.header })
347
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("pnm:ga") {|r| r.header })
348
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("pa.ppm") {|r| r.header })
349
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("pnm:pa") {|r| r.header })
350
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("bb.pbm") {|r| r.header })
351
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("pnm:bb") {|r| r.header })
352
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("gb.pgm") {|r| r.header })
353
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("pnm:gb") {|r| r.header })
354
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("pb.ppm") {|r| r.header })
355
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("pnm:pb") {|r| r.header })
344
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("ba.pbm") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
345
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("pnm:ba") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
346
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("ga.pgm") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
347
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("pnm:ga") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
348
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("pa.ppm") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
349
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("pnm:pa") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
350
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("bb.pbm") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
351
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("pnm:bb") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
352
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("gb.pgm") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
353
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("pnm:gb") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
354
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("pb.ppm") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
355
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("pnm:pb") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
356
356
 
357
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("pbm:ba") {|r| r.header })
358
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("pgm:ga") {|r| r.header })
359
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("ppm:pa") {|r| r.header })
360
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("pbm:bb") {|r| r.header })
361
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("pgm:gb") {|r| r.header })
362
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("ppm:pb") {|r| r.header })
357
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("pbm:ba") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
358
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("pgm:ga") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
359
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("ppm:pa") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
360
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("pbm:bb") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
361
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("pgm:gb") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
362
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("ppm:pb") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
363
363
 
364
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("ba.pnm") {|r| r.header })
365
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("ga.pnm") {|r| r.header })
366
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("pa.pnm") {|r| r.header })
367
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("bb.pnm") {|r| r.header })
368
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("gb.pnm") {|r| r.header })
369
- assert_equal(["type", "x", "y", "component", "value"], Tb::Reader.open("pb.pnm") {|r| r.header })
364
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("ba.pnm") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
365
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("ga.pnm") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
366
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("pa.pnm") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
367
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("bb.pnm") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
368
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("gb.pnm") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
369
+ assert_equal(["type", "x", "y", "component", "value"], Tb.open_reader("pb.pnm") {|r| header = nil; r.with_header {|h| header = h}.each {}; header })
370
370
  }
371
371
  }
372
372
  end