rubyzip 0.5.9 → 0.5.11

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubyzip might be problematic. Click here for more details.

Files changed (7) hide show
  1. data/ChangeLog +34 -0
  2. data/NEWS +13 -0
  3. data/TODO +5 -1
  4. data/lib/zip/ioextras.rb +29 -1
  5. data/lib/zip/zip.rb +12 -12
  6. data/test/ziptest.rb +15 -5
  7. metadata +3 -3
data/ChangeLog CHANGED
@@ -1,3 +1,37 @@
1
+ 2005-09-03 10:27 thomas
2
+
3
+ * NEWS: [no log message]
4
+
5
+ 2005-09-03 10:02 thomas
6
+
7
+ * TODO, lib/zip/zip.rb: [no log message]
8
+
9
+ 2005-09-03 09:57 thomas
10
+
11
+ * lib/zip/ioextras.rb, lib/zip/zip.rb, test/ziptest.rb: Merged
12
+ patch from oss-ruby at technorama.net
13
+
14
+ 2005-09-03 09:54 thomas
15
+
16
+ * test/ziptest.rb: Added failing test that shows that read and gets
17
+ don't mix currently
18
+
19
+ 2005-08-29 08:50 thomas
20
+
21
+ * lib/zip/: ioextras.rb, zip.rb: [no log message]
22
+
23
+ 2005-08-29 08:41 thomas
24
+
25
+ * NEWS, lib/zip/zip.rb: [no log message]
26
+
27
+ 2005-08-29 08:35 thomas
28
+
29
+ * lib/zip/zip.rb: [no log message]
30
+
31
+ 2005-08-29 08:26 thomas
32
+
33
+ * lib/zip/zip.rb: [no log message]
34
+
1
35
  2005-08-07 14:27 thomas
2
36
 
3
37
  * lib/zip/zip.rb, NEWS: [no log message]
data/NEWS CHANGED
@@ -1,3 +1,16 @@
1
+ = Version 0.5.11
2
+
3
+ Fixed name clash file method copy_stream from fileutils.rb. Fixed
4
+ problem with references to constant CHUNK_SIZE.
5
+ ZipInputStream/AbstractInputStream read is now buffered like ruby IO's
6
+ read method, which means that read and gets etc can be mixed. The
7
+ unbuffered read method has been renamed to sysread.
8
+
9
+ = Version 0.5.10
10
+
11
+ Fixed method name resolution problem with FileUtils::copy_stream and
12
+ IOExtras::copy_stream.
13
+
1
14
  = Version 0.5.9
2
15
 
3
16
  Fixed serious memory consumption issue
data/TODO CHANGED
@@ -1,5 +1,9 @@
1
1
 
2
- * Fix problem with mixing AbstractInputStream::gets and AbstractInputStream::read
2
+ * rename write to syswrite
3
+ * provide alias for write -> syswrite in ioextras.rb
4
+ * (is buffering used anywhere with write?)
5
+ * produce_input should take an optional buffer parameter.
6
+ * Inflater.sysread should pass the buffer to produce_input.
3
7
  * Implement ZipFsDir.glob
4
8
  * ZipFile.checkIntegrity method
5
9
  * non-MSDOS permission attributes
@@ -2,7 +2,9 @@ module IOExtras #:nodoc:
2
2
 
3
3
  CHUNK_SIZE = 32768
4
4
 
5
- def copy_stream(ostream, istream)
5
+ RANGE_ALL = 0..-1
6
+
7
+ def self.copy_stream(ostream, istream)
6
8
  s = ''
7
9
  ostream.write(istream.read(CHUNK_SIZE, s)) until istream.eof?
8
10
  end
@@ -30,6 +32,32 @@ module IOExtras #:nodoc:
30
32
 
31
33
  attr_accessor :lineno
32
34
 
35
+ def read(numberOfBytes = nil, buf = nil)
36
+ buf = "" unless (buf)
37
+
38
+ if numberOfBytes
39
+ if numberOfBytes <= @outputBuffer.length
40
+ buf[RANGE_ALL] = @outputBuffer.slice!(0, numberOfBytes)
41
+ else
42
+ if @outputBuffer.length > 0
43
+ buf[RANGE_ALL] = @outputBuffer + sysread(numberOfBytes - @outputBuffer.length, buf)
44
+ @outputBuffer.slice!(RANGE_ALL)
45
+ else
46
+ buf[RANGE_ALL] = sysread(nil, buf)
47
+ end
48
+ end
49
+ else
50
+ if @outputBuffer.length > 0
51
+ buf[RANGE_ALL] = @outputBuffer + sysread(nil, buf)
52
+ @outputBuffer.slice!(RANGE_ALL)
53
+ else
54
+ buf[RANGE_ALL] = sysread(nil, buf)
55
+ end
56
+ end
57
+
58
+ buf
59
+ end
60
+
33
61
  def readlines(aSepString = $/)
34
62
  retVal = []
35
63
  each_line(aSepString) { |line| retVal << line }
@@ -19,12 +19,10 @@ end
19
19
 
20
20
  module Zip
21
21
 
22
- VERSION = '0.5.9'
22
+ VERSION = '0.5.11'
23
23
 
24
24
  RUBY_MINOR_VERSION = RUBY_VERSION.split(".")[1].to_i
25
25
 
26
- CHUNK_SIZE=32768
27
-
28
26
  # Ruby 1.7.x compatibility
29
27
  # In ruby 1.6.x and 1.8.0 reading from an empty stream returns
30
28
  # an empty string the first time and then nil.
@@ -122,8 +120,8 @@ module Zip
122
120
  end
123
121
 
124
122
  # Modeled after IO.read
125
- def read(numberOfBytes = nil)
126
- @decompressor.read(numberOfBytes)
123
+ def sysread(numberOfBytes = nil, buf = nil)
124
+ @decompressor.sysread(numberOfBytes, buf)
127
125
  end
128
126
 
129
127
  protected
@@ -157,6 +155,7 @@ module Zip
157
155
 
158
156
 
159
157
  class Decompressor #:nodoc:all
158
+ CHUNK_SIZE=32768
160
159
  def initialize(inputStream)
161
160
  super()
162
161
  @inputStream=inputStream
@@ -171,7 +170,8 @@ module Zip
171
170
  @hasReturnedEmptyString = ! EMPTY_FILE_RETURNS_EMPTY_STRING_FIRST
172
171
  end
173
172
 
174
- def read(numberOfBytes = nil)
173
+ # BUG: do something with buf
174
+ def sysread(numberOfBytes = nil, buf = nil)
175
175
  readEverything = (numberOfBytes == nil)
176
176
  while (readEverything || @outputBuffer.length < numberOfBytes)
177
177
  break if internal_input_finished?
@@ -222,7 +222,7 @@ module Zip
222
222
  end
223
223
 
224
224
  # TODO: Specialize to handle different behaviour in ruby > 1.7.0 ?
225
- def read(numberOfBytes = nil)
225
+ def sysread(numberOfBytes = nil, buf = nil)
226
226
  if input_finished?
227
227
  hasReturnedEmptyStringVal=@hasReturnedEmptyString
228
228
  @hasReturnedEmptyString=true
@@ -234,11 +234,11 @@ module Zip
234
234
  numberOfBytes = @charsToRead-@readSoFar
235
235
  end
236
236
  @readSoFar += numberOfBytes
237
- @inputStream.read(numberOfBytes)
237
+ @inputStream.read(numberOfBytes, buf)
238
238
  end
239
239
 
240
240
  def produce_input
241
- read(Decompressor::CHUNK_SIZE)
241
+ sysread(Decompressor::CHUNK_SIZE)
242
242
  end
243
243
 
244
244
  def input_finished?
@@ -248,7 +248,7 @@ module Zip
248
248
 
249
249
  class NullDecompressor #:nodoc:all
250
250
  include Singleton
251
- def read(numberOfBytes = nil)
251
+ def sysread(numberOfBytes = nil, buf = nil)
252
252
  nil
253
253
  end
254
254
 
@@ -1279,7 +1279,7 @@ module Zip
1279
1279
 
1280
1280
  def write_to_zip_output_stream(aZipOutputStream)
1281
1281
  aZipOutputStream.put_next_entry(self)
1282
- get_input_stream { |is| copy_stream(aZipOutputStream, is) }
1282
+ get_input_stream { |is| IOExtras.copy_stream(aZipOutputStream, is) }
1283
1283
  end
1284
1284
 
1285
1285
  def == (other)
@@ -1343,7 +1343,7 @@ module Zip
1343
1343
 
1344
1344
  def write_to_zip_output_stream(aZipOutputStream)
1345
1345
  aZipOutputStream.put_next_entry(self)
1346
- get_input_stream { |is| copy_stream(aZipOutputStream, is) }
1346
+ get_input_stream { |is| IOExtras.copy_stream(aZipOutputStream, is) }
1347
1347
  end
1348
1348
  end
1349
1349
 
@@ -276,12 +276,12 @@ module DecompressorTests
276
276
  end
277
277
 
278
278
  def test_readEverything
279
- assert_equal(@refText, @decompressor.read)
279
+ assert_equal(@refText, @decompressor.sysread)
280
280
  end
281
281
 
282
282
  def test_readInChunks
283
283
  chunkSize = 5
284
- while (decompressedChunk = @decompressor.read(chunkSize))
284
+ while (decompressedChunk = @decompressor.sysread(chunkSize))
285
285
  assert_equal(@refText.slice!(0, chunkSize), decompressedChunk)
286
286
  end
287
287
  assert_equal(0, @refText.size)
@@ -293,7 +293,7 @@ module DecompressorTests
293
293
  assert(@refLines.length > 40)
294
294
 
295
295
 
296
- assert_equal(@refText[0...100], @decompressor.read(100))
296
+ assert_equal(@refText[0...100], @decompressor.sysread(100))
297
297
 
298
298
  assert(! @decompressor.input_finished?)
299
299
  buf = @decompressor.produce_input
@@ -463,6 +463,16 @@ class ZipInputStreamTest < Test::Unit::TestCase
463
463
  assert_entry(e.name, zis, e.name)
464
464
  }
465
465
  end
466
+
467
+ def test_mix_read_and_gets
468
+ ZipInputStream.open(TestZipFile::TEST_ZIP2.zip_name) {
469
+ |zis|
470
+ e = zis.get_next_entry
471
+ assert_equal("#!/usr/bin/env ruby\n", zis.gets)
472
+ assert_equal("\n", zis.gets)
473
+ assert_equal("$VERBOSE =", zis.read(10))
474
+ }
475
+ end
466
476
 
467
477
  end
468
478
 
@@ -558,7 +568,7 @@ class DeflaterTest < Test::Unit::TestCase
558
568
  File.open(fileName, "rb") {
559
569
  |file|
560
570
  inflater = Inflater.new(file)
561
- txt = inflater.read
571
+ txt = inflater.sysread
562
572
  }
563
573
  end
564
574
 
@@ -1574,6 +1584,6 @@ class ZipExtraFieldTest < Test::Unit::TestCase
1574
1584
 
1575
1585
  end
1576
1586
 
1577
- # Copyright (C) 2002, 2003 Thomas Sondergaard
1587
+ # Copyright (C) 2002-2005 Thomas Sondergaard
1578
1588
  # rubyzip is free software; you can redistribute it and/or
1579
1589
  # modify it under the terms of the ruby license.
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: rubyzip
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.9
7
- date: 2005-08-07 00:00:00 +02:00
6
+ version: 0.5.11
7
+ date: 2005-09-03 00:00:00 +02:00
8
8
  summary: rubyzip is a ruby module for reading and writing zip files
9
9
  require_paths:
10
10
  - lib
@@ -59,12 +59,12 @@ files:
59
59
  - test/data/testDirectory.bin
60
60
  - test/data/zipWithDirs.zip
61
61
  - test/data/file2.txt.other
62
- - lib/zip/ioextras.rb
63
62
  - lib/zip/stdrubyext.rb
64
63
  - lib/zip/tempfile_bugfixed.rb
65
64
  - lib/zip/zip.rb
66
65
  - lib/zip/zipfilesystem.rb
67
66
  - lib/zip/ziprequire.rb
67
+ - lib/zip/ioextras.rb
68
68
  test_files: []
69
69
  rdoc_options: []
70
70
  extra_rdoc_files: []