archive-zip 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/LICENSE +22 -57
- data/{NEWS → NEWS.md} +29 -16
- data/README.md +250 -0
- data/Rakefile +119 -76
- data/lib/archive/support/binary_stringio.rb +9 -2
- data/lib/archive/support/time.rb +2 -2
- data/lib/archive/zip.rb +1 -1
- data/lib/archive/zip/entry.rb +2 -2
- data/lib/archive/zip/version.rb +1 -1
- data/spec/archive/zip/archive_spec.rb +54 -0
- data/spec/archive/zip/codec/deflate/compress/checksum_spec.rb +8 -6
- data/spec/archive/zip/codec/deflate/compress/close_spec.rb +13 -12
- data/spec/archive/zip/codec/deflate/compress/crc32_spec.rb +6 -4
- data/spec/archive/zip/codec/deflate/compress/data_descriptor_spec.rb +17 -10
- data/spec/archive/zip/codec/deflate/compress/new_spec.rb +7 -5
- data/spec/archive/zip/codec/deflate/compress/open_spec.rb +9 -7
- data/spec/archive/zip/codec/deflate/compress/write_spec.rb +15 -15
- data/spec/archive/zip/codec/deflate/decompress/checksum_spec.rb +6 -4
- data/spec/archive/zip/codec/deflate/decompress/close_spec.rb +10 -9
- data/spec/archive/zip/codec/deflate/decompress/crc32_spec.rb +6 -4
- data/spec/archive/zip/codec/deflate/decompress/data_descriptor_spec.rb +17 -10
- data/spec/archive/zip/codec/deflate/decompress/new_spec.rb +5 -3
- data/spec/archive/zip/codec/deflate/decompress/open_spec.rb +7 -5
- data/spec/archive/zip/codec/null_encryption/decrypt/close_spec.rb +10 -9
- data/spec/archive/zip/codec/null_encryption/decrypt/new_spec.rb +6 -4
- data/spec/archive/zip/codec/null_encryption/decrypt/open_spec.rb +8 -6
- data/spec/archive/zip/codec/null_encryption/decrypt/read_spec.rb +8 -6
- data/spec/archive/zip/codec/null_encryption/decrypt/rewind_spec.rb +9 -7
- data/spec/archive/zip/codec/null_encryption/decrypt/seek_spec.rb +15 -13
- data/spec/archive/zip/codec/null_encryption/decrypt/tell_spec.rb +8 -6
- data/spec/archive/zip/codec/null_encryption/encrypt/close_spec.rb +10 -9
- data/spec/archive/zip/codec/null_encryption/encrypt/new_spec.rb +5 -3
- data/spec/archive/zip/codec/null_encryption/encrypt/open_spec.rb +9 -5
- data/spec/archive/zip/codec/null_encryption/encrypt/rewind_spec.rb +9 -7
- data/spec/archive/zip/codec/null_encryption/encrypt/seek_spec.rb +15 -13
- data/spec/archive/zip/codec/null_encryption/encrypt/tell_spec.rb +11 -9
- data/spec/archive/zip/codec/null_encryption/encrypt/write_spec.rb +12 -10
- data/spec/archive/zip/codec/store/compress/close_spec.rb +10 -9
- data/spec/archive/zip/codec/store/compress/data_descriptor_spec.rb +19 -10
- data/spec/archive/zip/codec/store/compress/new_spec.rb +5 -3
- data/spec/archive/zip/codec/store/compress/open_spec.rb +7 -5
- data/spec/archive/zip/codec/store/compress/rewind_spec.rb +9 -7
- data/spec/archive/zip/codec/store/compress/seek_spec.rb +15 -13
- data/spec/archive/zip/codec/store/compress/tell_spec.rb +11 -9
- data/spec/archive/zip/codec/store/compress/write_spec.rb +10 -10
- data/spec/archive/zip/codec/store/decompress/close_spec.rb +10 -9
- data/spec/archive/zip/codec/store/decompress/data_descriptor_spec.rb +17 -10
- data/spec/archive/zip/codec/store/decompress/new_spec.rb +5 -3
- data/spec/archive/zip/codec/store/decompress/open_spec.rb +7 -5
- data/spec/archive/zip/codec/store/decompress/read_spec.rb +8 -6
- data/spec/archive/zip/codec/store/decompress/rewind_spec.rb +9 -7
- data/spec/archive/zip/codec/store/decompress/seek_spec.rb +15 -13
- data/spec/archive/zip/codec/store/decompress/tell_spec.rb +8 -6
- data/spec/archive/zip/codec/traditional_encryption/decrypt/close_spec.rb +13 -24
- data/spec/archive/zip/codec/traditional_encryption/decrypt/new_spec.rb +6 -4
- data/spec/archive/zip/codec/traditional_encryption/decrypt/open_spec.rb +10 -6
- data/spec/archive/zip/codec/traditional_encryption/decrypt/read_spec.rb +12 -13
- data/spec/archive/zip/codec/traditional_encryption/decrypt/rewind_spec.rb +10 -12
- data/spec/archive/zip/codec/traditional_encryption/decrypt/seek_spec.rb +16 -18
- data/spec/archive/zip/codec/traditional_encryption/decrypt/tell_spec.rb +8 -6
- data/spec/archive/zip/codec/traditional_encryption/encrypt/close_spec.rb +13 -24
- data/spec/archive/zip/codec/traditional_encryption/encrypt/new_spec.rb +5 -3
- data/spec/archive/zip/codec/traditional_encryption/encrypt/open_spec.rb +7 -5
- data/spec/archive/zip/codec/traditional_encryption/encrypt/rewind_spec.rb +10 -12
- data/spec/archive/zip/codec/traditional_encryption/encrypt/seek_spec.rb +16 -18
- data/spec/archive/zip/codec/traditional_encryption/encrypt/tell_spec.rb +12 -14
- data/spec/archive/zip/codec/traditional_encryption/encrypt/write_spec.rb +8 -23
- data/spec/binary_stringio/new_spec.rb +18 -12
- data/spec/binary_stringio/set_encoding_spec.rb +10 -7
- data/spec/ioextensions/read_exactly_spec.rb +14 -12
- data/spec/zlib/zreader/checksum_spec.rb +10 -8
- data/spec/zlib/zreader/close_spec.rb +5 -3
- data/spec/zlib/zreader/compressed_size_spec.rb +6 -4
- data/spec/zlib/zreader/new_spec.rb +7 -5
- data/spec/zlib/zreader/open_spec.rb +9 -7
- data/spec/zlib/zreader/read_spec.rb +10 -8
- data/spec/zlib/zreader/rewind_spec.rb +7 -5
- data/spec/zlib/zreader/seek_spec.rb +13 -11
- data/spec/zlib/zreader/tell_spec.rb +8 -6
- data/spec/zlib/zreader/uncompressed_size_spec.rb +6 -4
- data/spec/zlib/zwriter/checksum_spec.rb +10 -8
- data/spec/zlib/zwriter/close_spec.rb +5 -3
- data/spec/zlib/zwriter/compressed_size_spec.rb +6 -4
- data/spec/zlib/zwriter/new_spec.rb +10 -8
- data/spec/zlib/zwriter/open_spec.rb +12 -10
- data/spec/zlib/zwriter/rewind_spec.rb +9 -7
- data/spec/zlib/zwriter/seek_spec.rb +15 -17
- data/spec/zlib/zwriter/tell_spec.rb +11 -9
- data/spec/zlib/zwriter/uncompressed_size_spec.rb +6 -4
- data/spec/zlib/zwriter/write_spec.rb +9 -9
- metadata +268 -217
- data/CONTRIBUTORS +0 -13
- data/GPL +0 -676
- data/HACKING +0 -105
- data/LEGAL +0 -8
- data/README +0 -151
- data/TODO +0 -5
- data/default.mspec +0 -8
- data/spec_helper.rb +0 -49
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/deflate'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
@@ -13,9 +15,9 @@ describe "Archive::Zip::Codec::Deflate::Compress#crc32" do
|
|
13
15
|
) do |compressor|
|
14
16
|
compressor.write(DeflateSpecs.test_data)
|
15
17
|
compressor.flush
|
16
|
-
compressor.crc32.
|
18
|
+
compressor.crc32.must_equal Zlib.crc32(DeflateSpecs.test_data)
|
17
19
|
compressor
|
18
20
|
end
|
19
|
-
closed_compressor.crc32.
|
21
|
+
closed_compressor.crc32.must_equal Zlib.crc32(DeflateSpecs.test_data)
|
20
22
|
end
|
21
23
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/deflate'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
@@ -14,11 +16,12 @@ describe "Archive::Zip::Codec::Deflate::Compress#data_descriptor" do
|
|
14
16
|
) do |compressor|
|
15
17
|
compressor.write(test_data)
|
16
18
|
compressor.flush
|
17
|
-
compressor.data_descriptor.class.
|
19
|
+
compressor.data_descriptor.class.must_equal(Archive::Zip::DataDescriptor)
|
18
20
|
compressor
|
19
21
|
end
|
20
|
-
closed_compressor.data_descriptor.class.
|
22
|
+
closed_compressor.data_descriptor.class.must_equal(
|
21
23
|
Archive::Zip::DataDescriptor
|
24
|
+
)
|
22
25
|
end
|
23
26
|
|
24
27
|
it "has a crc32 attribute containing the CRC32 checksum" do
|
@@ -29,10 +32,10 @@ describe "Archive::Zip::Codec::Deflate::Compress#data_descriptor" do
|
|
29
32
|
) do |compressor|
|
30
33
|
compressor.write(test_data)
|
31
34
|
compressor.flush
|
32
|
-
compressor.data_descriptor.crc32.
|
35
|
+
compressor.data_descriptor.crc32.must_equal(Zlib.crc32(test_data))
|
33
36
|
compressor
|
34
37
|
end
|
35
|
-
closed_compressor.data_descriptor.crc32.
|
38
|
+
closed_compressor.data_descriptor.crc32.must_equal(Zlib.crc32(test_data))
|
36
39
|
end
|
37
40
|
|
38
41
|
it "has a compressed_size attribute containing the size of the compressed data" do
|
@@ -43,12 +46,14 @@ describe "Archive::Zip::Codec::Deflate::Compress#data_descriptor" do
|
|
43
46
|
) do |compressor|
|
44
47
|
compressor.write(test_data)
|
45
48
|
compressor.flush
|
46
|
-
compressor.data_descriptor.compressed_size.
|
49
|
+
compressor.data_descriptor.compressed_size.must_equal(
|
47
50
|
compressed_data.size
|
51
|
+
)
|
48
52
|
compressor
|
49
53
|
end
|
50
|
-
closed_compressor.data_descriptor.compressed_size.
|
54
|
+
closed_compressor.data_descriptor.compressed_size.must_equal(
|
51
55
|
compressed_data.size
|
56
|
+
)
|
52
57
|
end
|
53
58
|
|
54
59
|
it "has an uncompressed_size attribute containing the size of the input data" do
|
@@ -59,9 +64,11 @@ describe "Archive::Zip::Codec::Deflate::Compress#data_descriptor" do
|
|
59
64
|
) do |compressor|
|
60
65
|
compressor.write(test_data)
|
61
66
|
compressor.flush
|
62
|
-
compressor.data_descriptor.uncompressed_size.
|
67
|
+
compressor.data_descriptor.uncompressed_size.must_equal(test_data.size)
|
63
68
|
compressor
|
64
69
|
end
|
65
|
-
closed_compressor.data_descriptor.uncompressed_size.
|
70
|
+
closed_compressor.data_descriptor.uncompressed_size.must_equal(
|
71
|
+
test_data.size
|
72
|
+
)
|
66
73
|
end
|
67
74
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/deflate'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
@@ -10,7 +12,7 @@ describe "Archive::Zip::Codec::Deflate::Compress.new" do
|
|
10
12
|
c = Archive::Zip::Codec::Deflate::Compress.new(
|
11
13
|
BinaryStringIO.new, Zlib::DEFAULT_COMPRESSION
|
12
14
|
)
|
13
|
-
c.
|
15
|
+
c.must_be_instance_of(Archive::Zip::Codec::Deflate::Compress)
|
14
16
|
c.close
|
15
17
|
end
|
16
18
|
|
@@ -23,7 +25,7 @@ describe "Archive::Zip::Codec::Deflate::Compress.new" do
|
|
23
25
|
c.write(data)
|
24
26
|
c.close
|
25
27
|
|
26
|
-
compressed_data.string.
|
28
|
+
compressed_data.string.must_equal(DeflateSpecs.compressed_data)
|
27
29
|
|
28
30
|
compressed_data = BinaryStringIO.new
|
29
31
|
c = Archive::Zip::Codec::Deflate::Compress.new(
|
@@ -32,6 +34,6 @@ describe "Archive::Zip::Codec::Deflate::Compress.new" do
|
|
32
34
|
c.write(data)
|
33
35
|
c.close
|
34
36
|
|
35
|
-
compressed_data.string.
|
37
|
+
compressed_data.string.must_equal(DeflateSpecs.compressed_data_nocomp)
|
36
38
|
end
|
37
39
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/deflate'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
@@ -10,20 +12,20 @@ describe "Archive::Zip::Codec::Deflate::Compress.open" do
|
|
10
12
|
c = Archive::Zip::Codec::Deflate::Compress.open(
|
11
13
|
BinaryStringIO.new, Zlib::DEFAULT_COMPRESSION
|
12
14
|
)
|
13
|
-
c.
|
15
|
+
c.must_be_instance_of(Archive::Zip::Codec::Deflate::Compress)
|
14
16
|
c.close
|
15
17
|
end
|
16
18
|
|
17
19
|
it "executes a block with a new instance as an argument" do
|
18
20
|
Archive::Zip::Codec::Deflate::Compress.open(
|
19
21
|
BinaryStringIO.new, Zlib::DEFAULT_COMPRESSION
|
20
|
-
) { |c| c.
|
22
|
+
) { |c| c.must_be_instance_of(Archive::Zip::Codec::Deflate::Compress) }
|
21
23
|
end
|
22
24
|
|
23
25
|
it "closes the object after executing a block" do
|
24
26
|
Archive::Zip::Codec::Deflate::Compress.open(
|
25
27
|
BinaryStringIO.new, Zlib::DEFAULT_COMPRESSION
|
26
|
-
) { |c| c }.closed?.
|
28
|
+
) { |c| c }.closed?.must_equal(true)
|
27
29
|
end
|
28
30
|
|
29
31
|
it "allows level to be set" do
|
@@ -33,7 +35,7 @@ describe "Archive::Zip::Codec::Deflate::Compress.open" do
|
|
33
35
|
compressed_data, Zlib::DEFAULT_COMPRESSION
|
34
36
|
) { |c| c.write(data) }
|
35
37
|
|
36
|
-
compressed_data.string.
|
38
|
+
compressed_data.string.must_equal(DeflateSpecs.compressed_data)
|
37
39
|
|
38
40
|
data = DeflateSpecs.test_data
|
39
41
|
compressed_data = BinaryStringIO.new
|
@@ -41,6 +43,6 @@ describe "Archive::Zip::Codec::Deflate::Compress.open" do
|
|
41
43
|
compressed_data, Zlib::NO_COMPRESSION
|
42
44
|
) { |c| c.write(data) }
|
43
45
|
|
44
|
-
compressed_data.string.
|
46
|
+
compressed_data.string.must_equal(DeflateSpecs.compressed_data_nocomp)
|
45
47
|
end
|
46
48
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/deflate'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
8
10
|
describe "Archive::Zip::Codec::Deflate::Compress#write" do
|
9
11
|
it "calls the write method of the delegate" do
|
10
|
-
delegate =
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
delegate.should_receive(:write).at_least(:once).and_return(1)
|
16
|
-
delegate.should_receive(:close).once.and_return(nil)
|
12
|
+
delegate = MiniTest::Mock.new
|
13
|
+
delegate.expect(
|
14
|
+
:write, DeflateSpecs.compressed_data.size, [DeflateSpecs.compressed_data]
|
15
|
+
)
|
16
|
+
delegate.expect(:close, nil)
|
17
17
|
Archive::Zip::Codec::Deflate::Compress.open(
|
18
18
|
delegate, Zlib::DEFAULT_COMPRESSION
|
19
19
|
) do |compressor|
|
@@ -28,7 +28,7 @@ describe "Archive::Zip::Codec::Deflate::Compress#write" do
|
|
28
28
|
) do |compressor|
|
29
29
|
compressor.write(DeflateSpecs.test_data)
|
30
30
|
end
|
31
|
-
compressed_data.string.
|
31
|
+
compressed_data.string.must_equal(DeflateSpecs.compressed_data)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "writes compressed data to a delegate that only performs partial writes" do
|
@@ -46,13 +46,13 @@ describe "Archive::Zip::Codec::Deflate::Compress#write" do
|
|
46
46
|
) do |compressor|
|
47
47
|
compressor.write(DeflateSpecs.test_data)
|
48
48
|
end
|
49
|
-
compressed_data.string.
|
49
|
+
compressed_data.string.must_equal(DeflateSpecs.compressed_data)
|
50
50
|
end
|
51
51
|
|
52
52
|
it "writes compressed data to a delegate that raises Errno::EAGAIN" do
|
53
53
|
compressed_data = BinaryStringIO.new
|
54
|
-
# Override compressed_data.write to raise Errno::EAGAIN every other time
|
55
|
-
# called.
|
54
|
+
# Override compressed_data.write to raise Errno::EAGAIN every other time
|
55
|
+
# it's called.
|
56
56
|
class << compressed_data
|
57
57
|
alias :write_orig :write
|
58
58
|
def write(buffer)
|
@@ -75,7 +75,7 @@ describe "Archive::Zip::Codec::Deflate::Compress#write" do
|
|
75
75
|
retry
|
76
76
|
end
|
77
77
|
end
|
78
|
-
compressed_data.string.
|
78
|
+
compressed_data.string.must_equal(DeflateSpecs.compressed_data)
|
79
79
|
end
|
80
80
|
|
81
81
|
it "writes compressed data to a delegate that raises Errno::EINTR" do
|
@@ -104,6 +104,6 @@ describe "Archive::Zip::Codec::Deflate::Compress#write" do
|
|
104
104
|
retry
|
105
105
|
end
|
106
106
|
end
|
107
|
-
compressed_data.string.
|
107
|
+
compressed_data.string.must_equal(DeflateSpecs.compressed_data)
|
108
108
|
end
|
109
109
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/deflate'
|
6
8
|
|
7
9
|
describe "Archive::Zip::Deflate::Decompress#checksum" do
|
@@ -9,10 +11,10 @@ describe "Archive::Zip::Deflate::Decompress#checksum" do
|
|
9
11
|
closed_decompressor = DeflateSpecs.compressed_data do |f|
|
10
12
|
Archive::Zip::Codec::Deflate::Decompress.open(f) do |decompressor|
|
11
13
|
decompressor.read
|
12
|
-
decompressor.checksum.
|
14
|
+
decompressor.checksum.must_equal(Zlib.crc32(DeflateSpecs.test_data))
|
13
15
|
decompressor
|
14
16
|
end
|
15
17
|
end
|
16
|
-
closed_decompressor.checksum.
|
18
|
+
closed_decompressor.checksum.must_equal(Zlib.crc32(DeflateSpecs.test_data))
|
17
19
|
end
|
18
20
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/deflate'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
@@ -9,24 +11,23 @@ describe "Archive::Zip::Codec::Deflate::Decompress#close" do
|
|
9
11
|
it "closes the stream" do
|
10
12
|
c = Archive::Zip::Codec::Deflate::Decompress.new(BinaryStringIO.new)
|
11
13
|
c.close
|
12
|
-
c.closed?.
|
14
|
+
c.closed?.must_equal(true)
|
13
15
|
end
|
14
16
|
|
15
17
|
it "closes the delegate stream by default" do
|
16
|
-
delegate =
|
17
|
-
delegate.
|
18
|
+
delegate = MiniTest::Mock.new
|
19
|
+
delegate.expect(:close, nil)
|
18
20
|
c = Archive::Zip::Codec::Deflate::Decompress.new(delegate)
|
19
21
|
c.close
|
20
22
|
end
|
21
23
|
|
22
24
|
it "optionally leaves the delegate stream open" do
|
23
|
-
delegate =
|
24
|
-
delegate.
|
25
|
+
delegate = MiniTest::Mock.new
|
26
|
+
delegate.expect(:close, nil)
|
25
27
|
c = Archive::Zip::Codec::Deflate::Decompress.new(delegate)
|
26
28
|
c.close(true)
|
27
29
|
|
28
|
-
delegate =
|
29
|
-
delegate.should_not_receive(:close)
|
30
|
+
delegate = MiniTest::Mock.new
|
30
31
|
c = Archive::Zip::Codec::Deflate::Decompress.new(delegate)
|
31
32
|
c.close(false)
|
32
33
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/deflate'
|
6
8
|
|
7
9
|
describe "Archive::Zip::Deflate::Decompress#crc32" do
|
@@ -9,10 +11,10 @@ describe "Archive::Zip::Deflate::Decompress#crc32" do
|
|
9
11
|
closed_decompressor = DeflateSpecs.compressed_data do |f|
|
10
12
|
Archive::Zip::Codec::Deflate::Decompress.open(f) do |decompressor|
|
11
13
|
decompressor.read
|
12
|
-
decompressor.crc32.
|
14
|
+
decompressor.crc32.must_equal(Zlib.crc32(DeflateSpecs.test_data))
|
13
15
|
decompressor
|
14
16
|
end
|
15
17
|
end
|
16
|
-
closed_decompressor.crc32.
|
18
|
+
closed_decompressor.crc32.must_equal(Zlib.crc32(DeflateSpecs.test_data))
|
17
19
|
end
|
18
20
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/deflate'
|
6
8
|
|
7
9
|
describe "Archive::Zip::Codec::Deflate::Decompress#data_descriptor" do
|
@@ -11,12 +13,14 @@ describe "Archive::Zip::Codec::Deflate::Decompress#data_descriptor" do
|
|
11
13
|
cd
|
12
14
|
) do |decompressor|
|
13
15
|
decompressor.read
|
14
|
-
decompressor.data_descriptor.
|
16
|
+
decompressor.data_descriptor.must_be_instance_of(
|
15
17
|
Archive::Zip::DataDescriptor
|
18
|
+
)
|
16
19
|
decompressor
|
17
20
|
end
|
18
|
-
closed_decompressor.data_descriptor.
|
21
|
+
closed_decompressor.data_descriptor.must_be_instance_of(
|
19
22
|
Archive::Zip::DataDescriptor
|
23
|
+
)
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
@@ -27,10 +31,10 @@ describe "Archive::Zip::Codec::Deflate::Decompress#data_descriptor" do
|
|
27
31
|
cd
|
28
32
|
) do |decompressor|
|
29
33
|
decompressor.read
|
30
|
-
decompressor.data_descriptor.crc32.
|
34
|
+
decompressor.data_descriptor.crc32.must_equal(crc32)
|
31
35
|
decompressor
|
32
36
|
end
|
33
|
-
closed_decompressor.data_descriptor.crc32.
|
37
|
+
closed_decompressor.data_descriptor.crc32.must_equal(crc32)
|
34
38
|
end
|
35
39
|
end
|
36
40
|
|
@@ -41,11 +45,12 @@ describe "Archive::Zip::Codec::Deflate::Decompress#data_descriptor" do
|
|
41
45
|
cd
|
42
46
|
) do |decompressor|
|
43
47
|
decompressor.read
|
44
|
-
decompressor.data_descriptor.compressed_size.
|
48
|
+
decompressor.data_descriptor.compressed_size.must_equal(compressed_size)
|
45
49
|
decompressor
|
46
50
|
end
|
47
|
-
closed_decompressor.data_descriptor.compressed_size.
|
51
|
+
closed_decompressor.data_descriptor.compressed_size.must_equal(
|
48
52
|
compressed_size
|
53
|
+
)
|
49
54
|
end
|
50
55
|
end
|
51
56
|
|
@@ -56,12 +61,14 @@ describe "Archive::Zip::Codec::Deflate::Decompress#data_descriptor" do
|
|
56
61
|
cd
|
57
62
|
) do |decompressor|
|
58
63
|
decompressor.read
|
59
|
-
decompressor.data_descriptor.uncompressed_size.
|
64
|
+
decompressor.data_descriptor.uncompressed_size.must_equal(
|
60
65
|
uncompressed_size
|
66
|
+
)
|
61
67
|
decompressor
|
62
68
|
end
|
63
|
-
closed_decompressor.data_descriptor.uncompressed_size.
|
69
|
+
closed_decompressor.data_descriptor.uncompressed_size.must_equal(
|
64
70
|
uncompressed_size
|
71
|
+
)
|
65
72
|
end
|
66
73
|
end
|
67
74
|
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/deflate'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
8
10
|
describe "Archive::Zip::Codec::Deflate::Decompress.new" do
|
9
11
|
it "returns a new instance" do
|
10
12
|
d = Archive::Zip::Codec::Deflate::Decompress.new(BinaryStringIO.new)
|
11
|
-
d.
|
13
|
+
d.must_be_instance_of(Archive::Zip::Codec::Deflate::Decompress)
|
12
14
|
d.close
|
13
15
|
end
|
14
16
|
end
|
@@ -1,20 +1,22 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/deflate'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
8
10
|
describe "Archive::Zip::Codec::Deflate::Decompress.open" do
|
9
11
|
it "returns a new instance when run without a block" do
|
10
12
|
d = Archive::Zip::Codec::Deflate::Decompress.open(BinaryStringIO.new)
|
11
|
-
d.
|
13
|
+
d.must_be_instance_of(Archive::Zip::Codec::Deflate::Decompress)
|
12
14
|
d.close
|
13
15
|
end
|
14
16
|
|
15
17
|
it "executes a block with a new instance as an argument" do
|
16
18
|
Archive::Zip::Codec::Deflate::Decompress.open(BinaryStringIO.new) do |decompressor|
|
17
|
-
decompressor.
|
19
|
+
decompressor.must_be_instance_of(Archive::Zip::Codec::Deflate::Decompress)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
@@ -22,6 +24,6 @@ describe "Archive::Zip::Codec::Deflate::Decompress.open" do
|
|
22
24
|
d = Archive::Zip::Codec::Deflate::Decompress.open(BinaryStringIO.new) do |decompressor|
|
23
25
|
decompressor
|
24
26
|
end
|
25
|
-
d.closed?.
|
27
|
+
d.closed?.must_equal(true)
|
26
28
|
end
|
27
29
|
end
|