bzip2-ruby 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bzip2-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guy Decoux
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-05-02 00:00:00 -07:00
13
+ date: 2009-05-18 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -21,20 +21,22 @@ executables: []
21
21
  extensions:
22
22
  - ext/extconf.rb
23
23
  extra_rdoc_files:
24
+ - CHANGELOG.rdoc
24
25
  - README.rdoc
25
26
  files:
26
- - History.txt
27
+ - CHANGELOG.rdoc
27
28
  - README.rdoc
28
29
  - Rakefile
29
30
  - VERSION.yml
30
31
  - bzip2-ruby.gemspec
31
- - ext/bz2.c
32
+ - ext/bzip2.c
32
33
  - ext/extconf.rb
34
+ - lib/bzip2.rb
35
+ - spec/reader_spec.rb
36
+ - spec/spec_helper.rb
37
+ - spec/writer_spec.rb
33
38
  - tasks/extconf.rake
34
39
  - tasks/extconf/bz2.rake
35
- - test/reader.rb
36
- - test/runit_.rb
37
- - test/writer.rb
38
40
  has_rdoc: true
39
41
  homepage: http://github.com/brianmario/bzip2-ruby
40
42
  licenses: []
@@ -43,6 +45,7 @@ post_install_message:
43
45
  rdoc_options:
44
46
  - --charset=UTF-8
45
47
  require_paths:
48
+ - lib
46
49
  - ext
47
50
  required_ruby_version: !ruby/object:Gem::Requirement
48
51
  requirements:
@@ -64,6 +67,6 @@ signing_key:
64
67
  specification_version: 3
65
68
  summary: Ruby C bindings to libbzip2.
66
69
  test_files:
67
- - test/reader.rb
68
- - test/runit_.rb
69
- - test/writer.rb
70
+ - spec/reader_spec.rb
71
+ - spec/spec_helper.rb
72
+ - spec/writer_spec.rb
@@ -1,5 +0,0 @@
1
- == 0.2.2 2008-12-22
2
-
3
- * 1 major enhancement:
4
- * Gemify bz2 library from http://moulon.inra.fr/ruby/bz2.html
5
- * All credit goes to Guy Decoux <ts@moulon.inra.fr>
@@ -1,370 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- # This is the test from rubicon
4
-
5
- $LOAD_PATH.unshift(*%w{.. tests})
6
- require 'rubygems'
7
- require 'bzip2'
8
- require 'runit_'
9
-
10
- Inh = defined?(RUNIT) ? RUNIT : Test::Unit
11
-
12
- $file = "_10lines_"
13
- $data = [
14
- "00: This is a line\n",
15
- "01: This is a line\n",
16
- "02: This is a line\n",
17
- "03: This is a line\n",
18
- "04: This is a line\n",
19
- "05: This is a line\n",
20
- "06: This is a line\n",
21
- "07: This is a line\n",
22
- "08: This is a line\n",
23
- "09: This is a line\n"
24
- ]
25
-
26
- open("|bzip2 > #$file", "w") do |f|
27
- $data.each { |l| f.puts l }
28
- end
29
-
30
- class TestReader < Inh::TestCase
31
-
32
- SAMPLE = "08: This is a line\n"
33
-
34
- def test_f_s_foreach
35
- count = 0
36
- Bzip2::Reader.foreach($file) do |line|
37
- num = line[0..1].to_i
38
- assert_equal(count, num)
39
- count += 1
40
- end
41
- assert_equal($data.size, count)
42
-
43
- count = 0
44
- Bzip2::Reader.foreach($file, nil) do |file|
45
- file.split(/\n/).each do |line|
46
- num = line[0..1].to_i
47
- assert_equal(count, num)
48
- count += 1
49
- end
50
- end
51
- assert_equal($data.size, count)
52
-
53
- count = 0
54
- Bzip2::Reader.foreach($file, ' ') do |thing|
55
- count += 1
56
- end
57
- assert_equal(41, count)
58
- end
59
-
60
- def test_f_s_readlines
61
- lines = Bzip2::Reader.readlines($file)
62
- assert_equal($data.size, lines.size)
63
-
64
- lines = Bzip2::Reader.readlines($file, nil)
65
- assert_equal(1, lines.size)
66
- assert_equal(SAMPLE.length * $data.size, lines[0].size)
67
- end
68
-
69
- def test_f_closed?
70
- f = Bzip2::Reader.open($file)
71
- assert(!f.closed?)
72
- f.close
73
- assert(f.closed?)
74
- end
75
-
76
- def test_f_each
77
- count = 0
78
- Bzip2::Reader.open($file) do |file|
79
- file.each do |line|
80
- num = line[0..1].to_i
81
- assert_equal(count, num)
82
- count += 1
83
- end
84
- assert_equal($data.size, count)
85
- end
86
-
87
- count = 0
88
- Bzip2::Reader.open($file) do |file|
89
- file.each(nil) do |contents|
90
- contents.split(/\n/).each do |line|
91
- num = line[0..1].to_i
92
- assert_equal(count, num)
93
- count += 1
94
- end
95
- end
96
- end
97
- assert_equal($data.size, count)
98
-
99
- count = 0
100
- Bzip2::Reader.open($file) do |file|
101
- file.each(' ') do |thing|
102
- count += 1
103
- end
104
- end
105
- assert_equal(41, count)
106
- end
107
-
108
- def test_f_each_byte
109
- count = 0
110
- data = $data.join
111
-
112
- Bzip2::Reader.open($file) do |file|
113
- file.each_byte do |b|
114
- assert_equal(data[count], b)
115
- count += 1
116
- end
117
- end
118
- assert_equal(SAMPLE.length * $data.size, count)
119
- end
120
-
121
- def test_f_each_line
122
- count = 0
123
- Bzip2::Reader.open($file) do |file|
124
- file.each_line do |line|
125
- num = line[0..1].to_i
126
- assert_equal(count, num)
127
- count += 1
128
- end
129
- assert_equal($data.size, count)
130
- end
131
-
132
- count = 0
133
- Bzip2::Reader.open($file) do |file|
134
- file.each_line(nil) do |contents|
135
- contents.split(/\n/).each do |line|
136
- num = line[0..1].to_i
137
- assert_equal(count, num)
138
- count += 1
139
- end
140
- end
141
- end
142
- assert_equal($data.size, count)
143
-
144
- count = 0
145
- Bzip2::Reader.open($file) do |file|
146
- file.each_line(' ') do |thing|
147
- count += 1
148
- end
149
- end
150
- assert_equal(41, count)
151
- end
152
-
153
- def test_f_eof
154
- Bzip2::Reader.open($file) do |file|
155
- $data.size.times do
156
- assert(!file.eof)
157
- assert(!file.eof?)
158
- file.gets
159
- end
160
- assert(file.eof)
161
- assert(file.eof?)
162
- end
163
- end
164
-
165
- def test_f_getc
166
- count = 0
167
- data = $data.join
168
-
169
- Bzip2::Reader.open($file) do |file|
170
- while (ch = file.getc)
171
- assert_equal(data[count], ch)
172
- count += 1
173
- end
174
- assert_equal(nil, file.getc)
175
- end
176
- assert_equal(SAMPLE.length * $data.size, count)
177
- end
178
-
179
- def test_f_gets
180
- count = 0
181
- Bzip2::Reader.open($file) do |file|
182
- while (line = file.gets)
183
- num = line[0..1].to_i
184
- assert_equal(count, num)
185
- count += 1
186
- end
187
- assert_equal(nil, file.gets)
188
- assert_equal($data.size, count)
189
- end
190
-
191
- count = 0
192
- Bzip2::Reader.open($file) do |file|
193
- while (line = file.gets("line\n"))
194
- assert_equal($data[count], line)
195
- num = line[0..1].to_i
196
- assert_equal(count, num)
197
- count += 1
198
- end
199
- assert_equal(nil, file.gets)
200
- assert_equal($data.size, count)
201
- end
202
-
203
- count = 0
204
- Bzip2::Reader.open($file) do |file|
205
- while (contents = file.gets(nil))
206
- contents.split(/\n/).each do |line|
207
- num = line[0..1].to_i
208
- assert_equal(count, num)
209
- count += 1
210
- end
211
- end
212
- end
213
- assert_equal($data.size, count)
214
-
215
- count = 0
216
- Bzip2::Reader.open($file) do |file|
217
- while (thing = file.gets(' '))
218
- count += 1
219
- end
220
- end
221
- assert_equal(41, count)
222
- end
223
-
224
- def test_f_read
225
- Bzip2::Reader.open($file) do |file|
226
- content = file.read
227
- assert_equal(SAMPLE.length * $data.size, content.length)
228
- count = 0
229
- content.split(/\n/).each do |line|
230
- num = line[0..1].to_i
231
- assert_equal(count, num)
232
- count += 1
233
- end
234
- end
235
-
236
- Bzip2::Reader.open($file) do |file|
237
- assert_equal("00: This is ", file.read(12))
238
- assert_equal("a line\n01: T", file.read(12))
239
- end
240
- end
241
-
242
- def test_f_readchar
243
- count = 0
244
- data = $data.join
245
- Bzip2::Reader.open($file) do |file|
246
- 190.times do |count|
247
- ch = file.readchar
248
- assert_equal(data[count], ch)
249
- count += 1
250
- end
251
- assert_raises(Bzip2::EOZError) { file.readchar }
252
- end
253
- end
254
-
255
- def test_f_readline
256
- count = 0
257
- Bzip2::Reader.open($file) do |file|
258
- $data.size.times do |count|
259
- line = file.readline
260
- num = line[0..1].to_i
261
- assert_equal(count, num)
262
- count += 1
263
- end
264
- assert_raises(Bzip2::EOZError) { file.readline }
265
- end
266
-
267
- count = 0
268
- Bzip2::Reader.open($file) do |file|
269
- contents = file.readline(nil)
270
- contents.split(/\n/).each do |line|
271
- num = line[0..1].to_i
272
- assert_equal(count, num)
273
- count += 1
274
- end
275
- assert_raises(Bzip2::EOZError) { file.readline }
276
- end
277
- assert_equal($data.size, count)
278
-
279
- count = 0
280
- Bzip2::Reader.open($file) do |file|
281
- 41.times do |count|
282
- thing = file.readline(' ')
283
- count += 1
284
- end
285
- assert_raises(Bzip2::EOZError) { file.readline }
286
- end
287
- end
288
-
289
- def test_f_readlines
290
- Bzip2::Reader.open($file) do |file|
291
- lines = file.readlines
292
- assert_equal($data.size, lines.size)
293
- end
294
-
295
- Bzip2::Reader.open($file) do |file|
296
- lines = file.readlines(nil)
297
- assert_equal(1, lines.size)
298
- assert_equal(SAMPLE.length * $data.size, lines[0].size)
299
- end
300
- end
301
-
302
- def test_f_ungetc
303
- Bzip2::Reader.open($file) do |file|
304
- assert_equal(?0, file.getc)
305
- assert_equal(?0, file.getc)
306
- assert_equal(?:, file.getc)
307
- assert_equal(?\s, file.getc)
308
- assert_nil(file.ungetc(?:))
309
- assert_equal(?:, file.getc)
310
- 1 while file.getc
311
- assert_nil(file.ungetc(?A))
312
- assert_equal(?A, file.getc)
313
- end
314
- end
315
-
316
- def test_f_ungets
317
- count = 0
318
- Bzip2::Reader.open($file) do |file|
319
- assert_equal($data[count], file.gets)
320
- assert_equal(count + 1, file.lineno);
321
- assert_nil(file.ungets($data[count]))
322
- assert_equal($data[count], file.gets)
323
- count += 1
324
- end
325
- end
326
-
327
- def test_s_readline
328
- count = 0
329
- string = IO.readlines($file, nil)[0]
330
- file = Bzip2::Reader.new(string)
331
- $data.size.times do |count|
332
- line = file.readline
333
- num = line[0..1].to_i
334
- assert_equal(count, num)
335
- count += 1
336
- end
337
- assert_raises(Bzip2::EOZError) { file.readline }
338
- file.close
339
-
340
- count = 0
341
- file = Bzip2::Reader.new(string)
342
- contents = file.readline(nil)
343
- contents.split(/\n/).each do |line|
344
- num = line[0..1].to_i
345
- assert_equal(count, num)
346
- count += 1
347
- end
348
- assert_raises(Bzip2::EOZError) { file.readline }
349
- assert_equal($data.size, count)
350
- file.close
351
-
352
- count = 0
353
- file = Bzip2::Reader.new(string)
354
- 41.times do |count|
355
- thing = file.readline(' ')
356
- count += 1
357
- end
358
- assert_raises(Bzip2::EOZError) { file.readline }
359
- file.close
360
- end
361
-
362
- def test_zzz
363
- File.unlink($file)
364
- end
365
- end
366
-
367
-
368
- if defined?(RUNIT)
369
- RUNIT::CUI::TestRunner.run(TestReader.suite)
370
- end
@@ -1,32 +0,0 @@
1
- begin
2
- require 'test/unit'
3
- rescue LoadError
4
- require 'runit/testcase'
5
- require 'runit/cui/testrunner'
6
-
7
- module RUNIT
8
- module Assert
9
- def assert_raises(error, message = nil)
10
- begin
11
- yield
12
- rescue error
13
- assert(true, message)
14
- rescue
15
- assert_fail("must fail with #{error} : #{string}")
16
- else
17
- assert_fail("*must* fail : #{string}")
18
- end
19
- end
20
- end
21
- end
22
- end
23
-
24
-
25
- if RUBY_VERSION > "1.7"
26
- class Array
27
- alias indices select
28
- end
29
- class Hash
30
- alias indexes select
31
- end
32
- end