archive-zip 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/NEWS CHANGED
@@ -6,6 +6,13 @@ detailed information is available in the rest of the documentation.
6
6
  <b>NOTE:</b> Date stamps in the following entries are in YYYY/MM/DD format.
7
7
 
8
8
 
9
+ == v0.3.0 (2009/01/23)
10
+
11
+ * Made a significant performance improvement for the extraction of compressed
12
+ entries for performance on par with InfoZIP's unzip. Parsing archives with
13
+ many entries is still a bit subpar however.
14
+
15
+
9
16
  == v0.2.0 (2008/08/06)
10
17
 
11
18
  * Traditional (weak) encryption is now supported.
@@ -34,8 +34,8 @@ module Zlib # :nodoc:
34
34
  # and _strategy_ are all passed directly to Zlib::Deflate.new(). See the
35
35
  # documentation of that method for their meanings.
36
36
  #
37
- # NOTE: Due to limitations in Ruby's finalization capabilities, the #close
38
- # method is _not_ automatically called when this object is garbage
37
+ # <b>NOTE:</b> Due to limitations in Ruby's finalization capabilities, the
38
+ # #close method is _not_ automatically called when this object is garbage
39
39
  # collected. Make sure to call #close when finished with this object.
40
40
  def initialize(io, level = Zlib::DEFAULT_COMPRESSION, window_bits = nil, mem_level = nil, strategy = nil)
41
41
  @delegate = io
@@ -46,9 +46,9 @@ module Zlib # :nodoc:
46
46
 
47
47
  # The CRC32 checksum of the uncompressed data written using this object.
48
48
  #
49
- # NOTE: Anything still in the internal write buffer has not been processed,
50
- # so calling #flush prior to examining this attribute may be necessary for
51
- # an accurate computation.
49
+ # <b>NOTE:</b> Anything still in the internal write buffer has not been
50
+ # processed, so calling #flush prior to examining this attribute may be
51
+ # necessary for an accurate computation.
52
52
  attr_reader :crc32
53
53
 
54
54
  protected
@@ -70,18 +70,18 @@ module Zlib # :nodoc:
70
70
 
71
71
  # Returns the number of bytes of compressed data produced so far.
72
72
  #
73
- # NOTE: Anything still in the internal write buffer has not been processed,
74
- # so calling #flush prior to calling this method may be necessary for an
75
- # accurate count.
73
+ # <b>NOTE:</b> Anything still in the internal write buffer has not been
74
+ # processed, so calling #flush prior to calling this method may be necessary
75
+ # for an accurate count.
76
76
  def compressed_size
77
77
  @deflater.total_out
78
78
  end
79
79
 
80
80
  # Returns the number of bytes sent to be compressed so far.
81
81
  #
82
- # NOTE: Anything still in the internal write buffer has not been processed,
83
- # so calling #flush prior to calling this method may be necessary for an
84
- # accurate count.
82
+ # <b>NOTE:</b> Anything still in the internal write buffer has not been
83
+ # processed, so calling #flush prior to calling this method may be necessary
84
+ # for an accurate count.
85
85
  def uncompressed_size
86
86
  @deflater.total_in
87
87
  end
@@ -111,6 +111,10 @@ module Zlib # :nodoc:
111
111
  class ZReader
112
112
  include IO::Like
113
113
 
114
+ # The number of bytes to read from the delegate object each time the
115
+ # internal read buffer is filled.
116
+ DEFAULT_DELEGATE_READ_SIZE = 4096
117
+
114
118
  # Creates a new instance of this class with the given arguments using #new
115
119
  # and then passes the instance to the given block. The #close method is
116
120
  # guaranteed to be called after the block completes.
@@ -133,11 +137,12 @@ module Zlib # :nodoc:
133
137
  # meaning. If _io_ also responds to _rewind_, then the _rewind_ method of
134
138
  # this class can be used to reset the whole stream back to the beginning.
135
139
  #
136
- # NOTE: Due to limitations in Ruby's finalization capabilities, the #close
137
- # method is _not_ automatically called when this object is garbage
140
+ # <b>NOTE:</b> Due to limitations in Ruby's finalization capabilities, the
141
+ # #close method is _not_ automatically called when this object is garbage
138
142
  # collected. Make sure to call #close when finished with this object.
139
143
  def initialize(io, window_bits = nil)
140
144
  @delegate = io
145
+ @delegate_read_size = DEFAULT_DELEGATE_READ_SIZE
141
146
  @window_bits = window_bits
142
147
  @inflater = Zlib::Inflate.new(@window_bits)
143
148
  @crc32 = 0
@@ -146,11 +151,15 @@ module Zlib # :nodoc:
146
151
 
147
152
  # The CRC32 checksum of the uncompressed data read using this object.
148
153
  #
149
- # NOTE: The contents of the internal read buffer are immediately processed
150
- # any time the buffer is filled, so this count is only accurate if all data
151
- # has been read out of this object.
154
+ # <b>NOTE:</b> The contents of the internal read buffer are immediately
155
+ # processed any time the buffer is filled, so this count is only accurate if
156
+ # all data has been read out of this object.
152
157
  attr_reader :crc32
153
158
 
159
+ # The number of bytes to read from the delegate object each time the
160
+ # internal read buffer is filled.
161
+ attr_accessor :delegate_read_size
162
+
154
163
  protected
155
164
 
156
165
  # The delegate object from which compressed data is read.
@@ -180,11 +189,14 @@ module Zlib # :nodoc:
180
189
  private
181
190
 
182
191
  def unbuffered_read(length)
183
- raise EOFError, 'end of file reached' if @inflater.finished?
192
+ if @decompress_buffer.empty? && @inflater.finished? then
193
+ raise EOFError, 'end of file reached'
194
+ end
184
195
 
185
196
  begin
186
197
  while @decompress_buffer.length < length && ! @inflater.finished? do
187
- @decompress_buffer << @inflater.inflate(delegate.read(1))
198
+ @decompress_buffer <<
199
+ @inflater.inflate(delegate.read(@delegate_read_size))
188
200
  end
189
201
  rescue Errno::EINTR, Errno::EAGAIN
190
202
  raise if @decompress_buffer.empty?
data/lib/archive/zip.rb CHANGED
@@ -242,9 +242,10 @@ module Archive # :nodoc:
242
242
  # <b>:flatten</b>::
243
243
  # When set to +false+ (the default), the directory paths containing
244
244
  # archived files will be included in the zip paths of entries representing
245
- # the files. When set to +true+ files are archived without any containing
246
- # directory structure in the zip paths. Setting to +true+ implies that
247
- # <b>:directories</b> is +false+ and <b>:path_prefix</b> is empty.
245
+ # the files. When set to +true+, files are archived without any
246
+ # containing directory structure in the zip paths. Setting to +true+
247
+ # implies that <b>:directories</b> is +false+ and <b>:path_prefix</b> is
248
+ # empty.
248
249
  # <b>:exclude</b>::
249
250
  # Specifies a proc or lambda which takes a single argument containing a
250
251
  # prospective zip entry and returns +true+ if the entry should be excluded
@@ -444,13 +445,13 @@ module Archive # :nodoc:
444
445
  # <tt>:all</tt>.
445
446
  # <b>:create</b>::
446
447
  # When set to +true+ (the default), files and directories which do not
447
- # already exist will be extracted. When set to +false+ only files and
448
+ # already exist will be extracted. When set to +false+, only files and
448
449
  # directories which already exist will be extracted (depending on the
449
450
  # setting of <b>:overwrite</b>).
450
451
  # <b>:flatten</b>::
451
452
  # When set to +false+ (the default), the directory paths containing
452
453
  # extracted files will be created within +destination+ in order to contain
453
- # the files. When set to +true+ files are extracted directly to
454
+ # the files. When set to +true+, files are extracted directly to
454
455
  # +destination+ and directory entries are skipped.
455
456
  # <b>:exclude</b>::
456
457
  # Specifies a proc or lambda which takes a single argument containing a
@@ -626,8 +627,8 @@ module Archive # :nodoc:
626
627
 
627
628
  private
628
629
 
629
- # NOTE: For now _io_ MUST be seekable and report such by returning +true+
630
- # from its seekable? method. See IO#seekable?.
630
+ # <b>NOTE:</b> For now _io_ MUST be seekable and report such by returning
631
+ # +true+ from its seekable? method. See IO#seekable?.
631
632
  #
632
633
  # Raises Archive::Zip::IOError if _io_ is not seekable.
633
634
  def parse(io)
@@ -25,10 +25,10 @@ module Archive; class Zip
25
25
  # like-named attributes of _other_ and raises Archive::Zip::Error for any
26
26
  # mismatches.
27
27
  #
28
- # NOTE: The compressed_size attribute is not checked because encrypted
29
- # entries may have misleading compressed sizes. Checking only the CRC32 and
30
- # uncompressed size of the data should be sufficient to ensure that an entry
31
- # has been successfully extracted.
28
+ # <b>NOTE:</b> The compressed_size attribute is not checked because
29
+ # encrypted entries may have misleading compressed sizes. Checking only the
30
+ # CRC32 and uncompressed size of the data should be sufficient to ensure
31
+ # that an entry has been successfully extracted.
32
32
  def verify(other)
33
33
  unless crc32 == other.crc32 then
34
34
  raise Zip::Error,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: archive-zip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Bopp
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-07 00:00:00 -05:00
12
+ date: 2009-01-23 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -37,24 +37,24 @@ extra_rdoc_files:
37
37
  - NEWS
38
38
  - README
39
39
  files:
40
+ - lib/archive/support/io-like.rb
41
+ - lib/archive/support/io.rb
42
+ - lib/archive/support/iowindow.rb
43
+ - lib/archive/support/stringio.rb
44
+ - lib/archive/support/time.rb
45
+ - lib/archive/support/zlib.rb
46
+ - lib/archive/zip/codec/deflate.rb
47
+ - lib/archive/zip/codec/null_encryption.rb
48
+ - lib/archive/zip/codec/store.rb
49
+ - lib/archive/zip/codec/traditional_encryption.rb
40
50
  - lib/archive/zip/codec.rb
41
- - lib/archive/zip/entry.rb
42
51
  - lib/archive/zip/data_descriptor.rb
52
+ - lib/archive/zip/entry.rb
53
+ - lib/archive/zip/error.rb
43
54
  - lib/archive/zip/extra_field/extended_timestamp.rb
44
- - lib/archive/zip/extra_field/unix.rb
45
55
  - lib/archive/zip/extra_field/raw.rb
46
- - lib/archive/zip/error.rb
56
+ - lib/archive/zip/extra_field/unix.rb
47
57
  - lib/archive/zip/extra_field.rb
48
- - lib/archive/zip/codec/null_encryption.rb
49
- - lib/archive/zip/codec/store.rb
50
- - lib/archive/zip/codec/deflate.rb
51
- - lib/archive/zip/codec/traditional_encryption.rb
52
- - lib/archive/support/io.rb
53
- - lib/archive/support/iowindow.rb
54
- - lib/archive/support/zlib.rb
55
- - lib/archive/support/io-like.rb
56
- - lib/archive/support/time.rb
57
- - lib/archive/support/stringio.rb
58
58
  - lib/archive/zip.rb
59
59
  - CONTRIBUTORS
60
60
  - HACKING