archive-zip 0.12.0 → 0.13.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/NEWS.md +5 -0
- data/README.md +1 -1
- data/lib/archive/support/ioextensions.rb +5 -7
- data/lib/archive/support/iowindow.rb +34 -87
- data/lib/archive/support/stringio.rb +27 -0
- data/lib/archive/support/zlib.rb +0 -435
- data/lib/archive/zip/codec/deflate/reader.rb +187 -0
- data/lib/archive/zip/codec/deflate/writer.rb +209 -0
- data/lib/archive/zip/codec/deflate.rb +92 -244
- data/lib/archive/zip/codec/null_encryption.rb +4 -184
- data/lib/archive/zip/codec/store/reader.rb +97 -0
- data/lib/archive/zip/codec/store/writer.rb +78 -0
- data/lib/archive/zip/codec/store.rb +6 -231
- data/lib/archive/zip/codec/traditional_encryption/base.rb +85 -0
- data/lib/archive/zip/codec/traditional_encryption/reader.rb +65 -0
- data/lib/archive/zip/codec/traditional_encryption/writer.rb +71 -0
- data/lib/archive/zip/codec/traditional_encryption.rb +6 -360
- data/lib/archive/zip/dos_time.rb +103 -0
- data/lib/archive/zip/entry.rb +86 -70
- data/lib/archive/zip.rb +2 -5
- metadata +35 -227
- data/.yardopts +0 -1
- data/Rakefile +0 -247
- data/lib/archive/support/binary_stringio.rb +0 -30
- data/lib/archive/support/integer.rb +0 -13
- data/lib/archive/support/io-like.rb +0 -14
- data/lib/archive/support/time.rb +0 -119
- data/lib/archive/zip/version.rb +0 -6
- data/spec/archive/dos_time_spec.rb +0 -113
- data/spec/archive/zip/archive_spec.rb +0 -54
- data/spec/archive/zip/codec/deflate/compress/checksum_spec.rb +0 -44
- data/spec/archive/zip/codec/deflate/compress/close_spec.rb +0 -45
- data/spec/archive/zip/codec/deflate/compress/crc32_spec.rb +0 -23
- data/spec/archive/zip/codec/deflate/compress/data_descriptor_spec.rb +0 -74
- data/spec/archive/zip/codec/deflate/compress/new_spec.rb +0 -39
- data/spec/archive/zip/codec/deflate/compress/open_spec.rb +0 -48
- data/spec/archive/zip/codec/deflate/compress/write_spec.rb +0 -111
- data/spec/archive/zip/codec/deflate/decompress/checksum_spec.rb +0 -20
- data/spec/archive/zip/codec/deflate/decompress/close_spec.rb +0 -34
- data/spec/archive/zip/codec/deflate/decompress/crc32_spec.rb +0 -20
- data/spec/archive/zip/codec/deflate/decompress/data_descriptor_spec.rb +0 -74
- data/spec/archive/zip/codec/deflate/decompress/new_spec.rb +0 -16
- data/spec/archive/zip/codec/deflate/decompress/open_spec.rb +0 -29
- data/spec/archive/zip/codec/deflate/fixtures/classes.rb +0 -25
- data/spec/archive/zip/codec/deflate/fixtures/compressed_file.bin +0 -1
- data/spec/archive/zip/codec/deflate/fixtures/compressed_file_nocomp.bin +0 -0
- data/spec/archive/zip/codec/deflate/fixtures/raw_file.txt +0 -10
- data/spec/archive/zip/codec/null_encryption/decrypt/close_spec.rb +0 -34
- data/spec/archive/zip/codec/null_encryption/decrypt/new_spec.rb +0 -16
- data/spec/archive/zip/codec/null_encryption/decrypt/open_spec.rb +0 -29
- data/spec/archive/zip/codec/null_encryption/decrypt/read_spec.rb +0 -26
- data/spec/archive/zip/codec/null_encryption/decrypt/rewind_spec.rb +0 -27
- data/spec/archive/zip/codec/null_encryption/decrypt/seek_spec.rb +0 -59
- data/spec/archive/zip/codec/null_encryption/decrypt/tell_spec.rb +0 -23
- data/spec/archive/zip/codec/null_encryption/encrypt/close_spec.rb +0 -34
- data/spec/archive/zip/codec/null_encryption/encrypt/new_spec.rb +0 -16
- data/spec/archive/zip/codec/null_encryption/encrypt/open_spec.rb +0 -31
- data/spec/archive/zip/codec/null_encryption/encrypt/rewind_spec.rb +0 -28
- data/spec/archive/zip/codec/null_encryption/encrypt/seek_spec.rb +0 -52
- data/spec/archive/zip/codec/null_encryption/encrypt/tell_spec.rb +0 -31
- data/spec/archive/zip/codec/null_encryption/encrypt/write_spec.rb +0 -31
- data/spec/archive/zip/codec/null_encryption/fixtures/classes.rb +0 -12
- data/spec/archive/zip/codec/null_encryption/fixtures/raw_file.txt +0 -10
- data/spec/archive/zip/codec/store/compress/close_spec.rb +0 -34
- data/spec/archive/zip/codec/store/compress/data_descriptor_spec.rb +0 -77
- data/spec/archive/zip/codec/store/compress/new_spec.rb +0 -16
- data/spec/archive/zip/codec/store/compress/open_spec.rb +0 -29
- data/spec/archive/zip/codec/store/compress/rewind_spec.rb +0 -28
- data/spec/archive/zip/codec/store/compress/seek_spec.rb +0 -52
- data/spec/archive/zip/codec/store/compress/tell_spec.rb +0 -31
- data/spec/archive/zip/codec/store/compress/write_spec.rb +0 -29
- data/spec/archive/zip/codec/store/decompress/close_spec.rb +0 -34
- data/spec/archive/zip/codec/store/decompress/data_descriptor_spec.rb +0 -75
- data/spec/archive/zip/codec/store/decompress/new_spec.rb +0 -16
- data/spec/archive/zip/codec/store/decompress/open_spec.rb +0 -29
- data/spec/archive/zip/codec/store/decompress/read_spec.rb +0 -26
- data/spec/archive/zip/codec/store/decompress/rewind_spec.rb +0 -27
- data/spec/archive/zip/codec/store/decompress/seek_spec.rb +0 -59
- data/spec/archive/zip/codec/store/decompress/tell_spec.rb +0 -23
- data/spec/archive/zip/codec/store/fixtures/classes.rb +0 -12
- data/spec/archive/zip/codec/store/fixtures/raw_file.txt +0 -10
- data/spec/archive/zip/codec/traditional_encryption/decrypt/close_spec.rb +0 -53
- data/spec/archive/zip/codec/traditional_encryption/decrypt/new_spec.rb +0 -20
- data/spec/archive/zip/codec/traditional_encryption/decrypt/open_spec.rb +0 -43
- data/spec/archive/zip/codec/traditional_encryption/decrypt/read_spec.rb +0 -127
- data/spec/archive/zip/codec/traditional_encryption/decrypt/rewind_spec.rb +0 -36
- data/spec/archive/zip/codec/traditional_encryption/decrypt/seek_spec.rb +0 -80
- data/spec/archive/zip/codec/traditional_encryption/decrypt/tell_spec.rb +0 -27
- data/spec/archive/zip/codec/traditional_encryption/encrypt/close_spec.rb +0 -53
- data/spec/archive/zip/codec/traditional_encryption/encrypt/new_spec.rb +0 -20
- data/spec/archive/zip/codec/traditional_encryption/encrypt/open_spec.rb +0 -41
- data/spec/archive/zip/codec/traditional_encryption/encrypt/rewind_spec.rb +0 -39
- data/spec/archive/zip/codec/traditional_encryption/encrypt/seek_spec.rb +0 -73
- data/spec/archive/zip/codec/traditional_encryption/encrypt/tell_spec.rb +0 -40
- data/spec/archive/zip/codec/traditional_encryption/encrypt/write_spec.rb +0 -114
- data/spec/archive/zip/codec/traditional_encryption/fixtures/classes.rb +0 -27
- data/spec/archive/zip/codec/traditional_encryption/fixtures/encrypted_file.bin +0 -0
- data/spec/archive/zip/codec/traditional_encryption/fixtures/raw_file.txt +0 -10
- data/spec/binary_stringio/new_spec.rb +0 -40
- data/spec/binary_stringio/set_encoding_spec.rb +0 -17
- data/spec/ioextensions/read_exactly_spec.rb +0 -52
- data/spec/zlib/fixtures/classes.rb +0 -65
- data/spec/zlib/fixtures/compressed_file.bin +0 -1
- data/spec/zlib/fixtures/compressed_file_gzip.bin +0 -0
- data/spec/zlib/fixtures/compressed_file_huffman.bin +0 -2
- data/spec/zlib/fixtures/compressed_file_minmem.bin +0 -0
- data/spec/zlib/fixtures/compressed_file_minwin.bin +0 -1
- data/spec/zlib/fixtures/compressed_file_nocomp.bin +0 -0
- data/spec/zlib/fixtures/compressed_file_raw.bin +0 -1
- data/spec/zlib/fixtures/raw_file.txt +0 -10
- data/spec/zlib/zreader/checksum_spec.rb +0 -42
- data/spec/zlib/zreader/close_spec.rb +0 -16
- data/spec/zlib/zreader/compressed_size_spec.rb +0 -20
- data/spec/zlib/zreader/new_spec.rb +0 -43
- data/spec/zlib/zreader/open_spec.rb +0 -51
- data/spec/zlib/zreader/read_spec.rb +0 -58
- data/spec/zlib/zreader/rewind_spec.rb +0 -25
- data/spec/zlib/zreader/seek_spec.rb +0 -57
- data/spec/zlib/zreader/tell_spec.rb +0 -23
- data/spec/zlib/zreader/uncompressed_size_spec.rb +0 -20
- data/spec/zlib/zwriter/checksum_spec.rb +0 -43
- data/spec/zlib/zwriter/close_spec.rb +0 -16
- data/spec/zlib/zwriter/compressed_size_spec.rb +0 -21
- data/spec/zlib/zwriter/new_spec.rb +0 -66
- data/spec/zlib/zwriter/open_spec.rb +0 -70
- data/spec/zlib/zwriter/rewind_spec.rb +0 -28
- data/spec/zlib/zwriter/seek_spec.rb +0 -52
- data/spec/zlib/zwriter/tell_spec.rb +0 -31
- data/spec/zlib/zwriter/uncompressed_size_spec.rb +0 -21
- data/spec/zlib/zwriter/write_spec.rb +0 -28
@@ -1,23 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
|
5
|
-
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
-
|
7
|
-
require 'archive/support/zlib'
|
8
|
-
|
9
|
-
describe "Zlib::ZReader#tell" do
|
10
|
-
it "returns the current position of the stream" do
|
11
|
-
ZlibSpecs.compressed_data do |cd|
|
12
|
-
Zlib::ZReader.open(cd) do |zr|
|
13
|
-
zr.tell.must_equal 0
|
14
|
-
zr.read(4)
|
15
|
-
zr.tell.must_equal 4
|
16
|
-
zr.read
|
17
|
-
zr.tell.must_equal 235
|
18
|
-
zr.rewind
|
19
|
-
zr.tell.must_equal 0
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
|
5
|
-
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
-
|
7
|
-
require 'archive/support/zlib'
|
8
|
-
|
9
|
-
describe "Zlib::ZReader#uncompressed_size" do
|
10
|
-
it "returns the number of bytes of uncompressed data" do
|
11
|
-
closed_zr = ZlibSpecs.compressed_data_raw do |compressed_data|
|
12
|
-
Zlib::ZReader.open(compressed_data, -15) do |zr|
|
13
|
-
zr.read
|
14
|
-
zr.uncompressed_size.must_equal 235
|
15
|
-
zr
|
16
|
-
end
|
17
|
-
end
|
18
|
-
closed_zr.uncompressed_size.must_equal 235
|
19
|
-
end
|
20
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
|
5
|
-
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
-
|
7
|
-
require 'archive/support/zlib'
|
8
|
-
require 'archive/support/binary_stringio'
|
9
|
-
|
10
|
-
describe "Zlib::ZWriter#checksum" do
|
11
|
-
it "computes the ADLER32 checksum of zlib formatted data" do
|
12
|
-
compressed_data = BinaryStringIO.new
|
13
|
-
closed_zw = Zlib::ZWriter.open(compressed_data, nil, 15) do |zw|
|
14
|
-
zw.write(ZlibSpecs.test_data)
|
15
|
-
zw.flush
|
16
|
-
zw.checksum.must_equal Zlib.adler32(ZlibSpecs.test_data)
|
17
|
-
zw
|
18
|
-
end
|
19
|
-
closed_zw.checksum.must_equal Zlib.adler32(ZlibSpecs.test_data)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "computes the CRC32 checksum of gzip formatted data" do
|
23
|
-
compressed_data = BinaryStringIO.new
|
24
|
-
closed_zw = Zlib::ZWriter.open(compressed_data, nil, 31) do |zw|
|
25
|
-
zw.write(ZlibSpecs.test_data)
|
26
|
-
zw.flush
|
27
|
-
zw.checksum.must_equal Zlib.crc32(ZlibSpecs.test_data)
|
28
|
-
zw
|
29
|
-
end
|
30
|
-
closed_zw.checksum.must_equal Zlib.crc32(ZlibSpecs.test_data)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "does not compute a checksum for raw zlib data" do
|
34
|
-
compressed_data = BinaryStringIO.new
|
35
|
-
closed_zw = Zlib::ZWriter.open(compressed_data, nil, -15) do |zw|
|
36
|
-
zw.write(ZlibSpecs.test_data)
|
37
|
-
zw.flush
|
38
|
-
zw.checksum.must_be_nil
|
39
|
-
zw
|
40
|
-
end
|
41
|
-
closed_zw.checksum.must_be_nil
|
42
|
-
end
|
43
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
|
5
|
-
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
-
|
7
|
-
require 'archive/support/zlib'
|
8
|
-
require 'archive/support/binary_stringio'
|
9
|
-
|
10
|
-
describe "Zlib::ZWriter.close" do
|
11
|
-
it "closes the stream" do
|
12
|
-
zw = Zlib::ZWriter.new(BinaryStringIO.new)
|
13
|
-
zw.close
|
14
|
-
zw.closed?.must_equal true
|
15
|
-
end
|
16
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
|
5
|
-
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
-
|
7
|
-
require 'archive/support/zlib'
|
8
|
-
require 'archive/support/binary_stringio'
|
9
|
-
|
10
|
-
describe "Zlib::ZWriter#compressed_size" do
|
11
|
-
it "returns the number of bytes of compressed data" do
|
12
|
-
compressed_data = BinaryStringIO.new
|
13
|
-
closed_zw = Zlib::ZWriter.open(compressed_data, nil, -15) do |zw|
|
14
|
-
zw.sync = true
|
15
|
-
zw.write(ZlibSpecs.test_data)
|
16
|
-
zw.compressed_size.must_be :>=, 0
|
17
|
-
zw
|
18
|
-
end
|
19
|
-
closed_zw.compressed_size.must_equal 160
|
20
|
-
end
|
21
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
|
5
|
-
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
-
|
7
|
-
require 'archive/support/zlib'
|
8
|
-
require 'archive/support/binary_stringio'
|
9
|
-
|
10
|
-
describe "Zlib::ZWriter.new" do
|
11
|
-
it "returns a new instance" do
|
12
|
-
zw = Zlib::ZWriter.new(BinaryStringIO.new)
|
13
|
-
zw.class.must_equal Zlib::ZWriter
|
14
|
-
zw.close
|
15
|
-
end
|
16
|
-
|
17
|
-
it "provides default settings for level, window_bits, mem_level, and strategy" do
|
18
|
-
data = ZlibSpecs.test_data
|
19
|
-
compressed_data = BinaryStringIO.new
|
20
|
-
zw = Zlib::ZWriter.new(compressed_data)
|
21
|
-
zw.write(data)
|
22
|
-
zw.close
|
23
|
-
|
24
|
-
compressed_data.string.must_equal ZlibSpecs.compressed_data
|
25
|
-
end
|
26
|
-
|
27
|
-
it "allows level to be set" do
|
28
|
-
data = ZlibSpecs.test_data
|
29
|
-
compressed_data = BinaryStringIO.new
|
30
|
-
zw = Zlib::ZWriter.new(compressed_data, Zlib::NO_COMPRESSION)
|
31
|
-
zw.write(data)
|
32
|
-
zw.close
|
33
|
-
|
34
|
-
compressed_data.string.must_equal ZlibSpecs.compressed_data_nocomp
|
35
|
-
end
|
36
|
-
|
37
|
-
it "allows window_bits to be set" do
|
38
|
-
data = ZlibSpecs.test_data
|
39
|
-
compressed_data = BinaryStringIO.new
|
40
|
-
zw = Zlib::ZWriter.new(compressed_data, nil, 8)
|
41
|
-
zw.write(data)
|
42
|
-
zw.close
|
43
|
-
|
44
|
-
compressed_data.string.must_equal ZlibSpecs.compressed_data_minwin
|
45
|
-
end
|
46
|
-
|
47
|
-
it "allows mem_level to be set" do
|
48
|
-
data = ZlibSpecs.test_data
|
49
|
-
compressed_data = BinaryStringIO.new
|
50
|
-
zw = Zlib::ZWriter.new(compressed_data, nil, nil, 1)
|
51
|
-
zw.write(data)
|
52
|
-
zw.close
|
53
|
-
|
54
|
-
compressed_data.string.must_equal ZlibSpecs.compressed_data_minmem
|
55
|
-
end
|
56
|
-
|
57
|
-
it "allows strategy to be set" do
|
58
|
-
data = ZlibSpecs.test_data
|
59
|
-
compressed_data = BinaryStringIO.new
|
60
|
-
zw = Zlib::ZWriter.new(compressed_data, nil, nil, nil, Zlib::HUFFMAN_ONLY)
|
61
|
-
zw.write(data)
|
62
|
-
zw.close
|
63
|
-
|
64
|
-
compressed_data.string.must_equal ZlibSpecs.compressed_data_huffman
|
65
|
-
end
|
66
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
|
5
|
-
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
-
|
7
|
-
require 'archive/support/zlib'
|
8
|
-
require 'archive/support/binary_stringio'
|
9
|
-
|
10
|
-
describe "Zlib::ZWriter.open" do
|
11
|
-
it "returns a new instance when run without a block" do
|
12
|
-
zw = Zlib::ZWriter.open(BinaryStringIO.new)
|
13
|
-
zw.class.must_equal Zlib::ZWriter
|
14
|
-
zw.close
|
15
|
-
end
|
16
|
-
|
17
|
-
it "executes a block with a new instance as an argument" do
|
18
|
-
Zlib::ZWriter.open(BinaryStringIO.new) { |zr| zr.class.must_equal Zlib::ZWriter }
|
19
|
-
end
|
20
|
-
|
21
|
-
it "closes the object after executing a block" do
|
22
|
-
Zlib::ZWriter.open(BinaryStringIO.new) { |zr| zr }.closed?.must_equal true
|
23
|
-
end
|
24
|
-
|
25
|
-
it "provides default settings for level, window_bits, mem_level, and strategy" do
|
26
|
-
data = ZlibSpecs.test_data
|
27
|
-
compressed_data = BinaryStringIO.new
|
28
|
-
Zlib::ZWriter.open(compressed_data) { |zw| zw.write(data) }
|
29
|
-
|
30
|
-
compressed_data.string.must_equal ZlibSpecs.compressed_data
|
31
|
-
end
|
32
|
-
|
33
|
-
it "allows level to be set" do
|
34
|
-
data = ZlibSpecs.test_data
|
35
|
-
compressed_data = BinaryStringIO.new
|
36
|
-
Zlib::ZWriter.open(compressed_data, Zlib::NO_COMPRESSION) do |zw|
|
37
|
-
zw.write(data)
|
38
|
-
end
|
39
|
-
|
40
|
-
compressed_data.string.must_equal ZlibSpecs.compressed_data_nocomp
|
41
|
-
end
|
42
|
-
|
43
|
-
it "allows window_bits to be set" do
|
44
|
-
data = ZlibSpecs.test_data
|
45
|
-
compressed_data = BinaryStringIO.new
|
46
|
-
Zlib::ZWriter.open(compressed_data, nil, 8) { |zw| zw.write(data) }
|
47
|
-
|
48
|
-
compressed_data.string.must_equal ZlibSpecs.compressed_data_minwin
|
49
|
-
end
|
50
|
-
|
51
|
-
it "allows mem_level to be set" do
|
52
|
-
data = ZlibSpecs.test_data
|
53
|
-
compressed_data = BinaryStringIO.new
|
54
|
-
Zlib::ZWriter.open(compressed_data, nil, nil, 1) { |zw| zw.write(data) }
|
55
|
-
|
56
|
-
compressed_data.string.must_equal ZlibSpecs.compressed_data_minmem
|
57
|
-
end
|
58
|
-
|
59
|
-
it "allows strategy to be set" do
|
60
|
-
data = ZlibSpecs.test_data
|
61
|
-
compressed_data = BinaryStringIO.new
|
62
|
-
Zlib::ZWriter.open(
|
63
|
-
compressed_data, nil, nil, nil, Zlib::HUFFMAN_ONLY
|
64
|
-
) do |zw|
|
65
|
-
zw.write(data)
|
66
|
-
end
|
67
|
-
|
68
|
-
compressed_data.string.must_equal ZlibSpecs.compressed_data_huffman
|
69
|
-
end
|
70
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
|
5
|
-
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
-
|
7
|
-
require 'archive/support/zlib'
|
8
|
-
require 'archive/support/binary_stringio'
|
9
|
-
|
10
|
-
describe "Zlib::ZWriter#rewind" do
|
11
|
-
it "can rewind the stream when the delegate responds to rewind" do
|
12
|
-
sio = BinaryStringIO.new
|
13
|
-
Zlib::ZWriter.open(sio) do |zw|
|
14
|
-
zw.write('test')
|
15
|
-
zw.rewind
|
16
|
-
zw.write(ZlibSpecs.test_data)
|
17
|
-
end
|
18
|
-
sio.string.must_equal ZlibSpecs.compressed_data
|
19
|
-
end
|
20
|
-
|
21
|
-
it "raises Errno::EINVAL when attempting to rewind the stream when the delegate does not respond to rewind" do
|
22
|
-
delegate = MiniTest::Mock.new
|
23
|
-
delegate.expect(:write, 8, [String])
|
24
|
-
Zlib::ZWriter.open(delegate) do |zw|
|
25
|
-
lambda { zw.rewind }.must_raise Errno::EINVAL
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
|
5
|
-
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
-
|
7
|
-
require 'archive/support/zlib'
|
8
|
-
require 'archive/support/binary_stringio'
|
9
|
-
|
10
|
-
describe "Zlib::ZWriter#seek" do
|
11
|
-
it "can seek to the beginning of the stream when the delegate responds to rewind" do
|
12
|
-
compressed_data = BinaryStringIO.new
|
13
|
-
Zlib::ZWriter.open(compressed_data) do |c|
|
14
|
-
c.write('test')
|
15
|
-
c.seek(0).must_equal 0
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
it "raises Errno::EINVAL when attempting to seek to the beginning of the stream when the delegate does not respond to rewind" do
|
20
|
-
delegate = MiniTest::Mock.new
|
21
|
-
delegate.expect(:write, 8, [String])
|
22
|
-
Zlib::ZWriter.open(delegate) do |c|
|
23
|
-
lambda { c.seek(0) }.must_raise Errno::EINVAL
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it "raises Errno::EINVAL when seeking forward or backward from the current position of the stream" do
|
28
|
-
compressed_data = BinaryStringIO.new
|
29
|
-
Zlib::ZWriter.open(compressed_data) do |c|
|
30
|
-
c.write('test')
|
31
|
-
lambda { c.seek(1, IO::SEEK_CUR) }.must_raise Errno::EINVAL
|
32
|
-
lambda { c.seek(-1, IO::SEEK_CUR) }.must_raise Errno::EINVAL
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
it "raises Errno::EINVAL when seeking a non-zero offset relative to the beginning of the stream" do
|
37
|
-
compressed_data = BinaryStringIO.new
|
38
|
-
Zlib::ZWriter.open(compressed_data) do |c|
|
39
|
-
lambda { c.seek(-1, IO::SEEK_SET) }.must_raise Errno::EINVAL
|
40
|
-
lambda { c.seek(1, IO::SEEK_SET) }.must_raise Errno::EINVAL
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
it "raises Errno::EINVAL when seeking relative to the end of the stream" do
|
45
|
-
compressed_data = BinaryStringIO.new
|
46
|
-
Zlib::ZWriter.open(compressed_data) do |c|
|
47
|
-
lambda { c.seek(0, IO::SEEK_END) }.must_raise Errno::EINVAL
|
48
|
-
lambda { c.seek(-1, IO::SEEK_END) }.must_raise Errno::EINVAL
|
49
|
-
lambda { c.seek(1, IO::SEEK_END) }.must_raise Errno::EINVAL
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
|
5
|
-
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
-
|
7
|
-
require 'archive/support/zlib'
|
8
|
-
require 'archive/support/binary_stringio'
|
9
|
-
|
10
|
-
describe "Zlib::ZWriter#tell" do
|
11
|
-
it "returns the current position of the stream" do
|
12
|
-
sio = BinaryStringIO.new
|
13
|
-
Zlib::ZWriter.open(sio) do |zw|
|
14
|
-
zw.tell.must_equal 0
|
15
|
-
zw.write('test1')
|
16
|
-
zw.tell.must_equal 5
|
17
|
-
zw.write('test2')
|
18
|
-
zw.tell.must_equal 10
|
19
|
-
zw.rewind
|
20
|
-
zw.tell.must_equal 0
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it "raises IOError on closed stream" do
|
25
|
-
delegate = MiniTest::Mock.new
|
26
|
-
delegate.expect(:write, 8, [String])
|
27
|
-
lambda do
|
28
|
-
Zlib::ZWriter.open(delegate) { |zw| zw }.tell
|
29
|
-
end.must_raise IOError
|
30
|
-
end
|
31
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
|
5
|
-
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
-
|
7
|
-
require 'archive/support/zlib'
|
8
|
-
require 'archive/support/binary_stringio'
|
9
|
-
|
10
|
-
describe "Zlib::ZWriter#uncompressed_size" do
|
11
|
-
it "returns the number of bytes of uncompressed data" do
|
12
|
-
compressed_data = BinaryStringIO.new
|
13
|
-
closed_zw = Zlib::ZWriter.open(compressed_data, nil, -15) do |zw|
|
14
|
-
zw.sync = true
|
15
|
-
zw.write(ZlibSpecs.test_data)
|
16
|
-
zw.uncompressed_size.must_equal 235
|
17
|
-
zw
|
18
|
-
end
|
19
|
-
closed_zw.uncompressed_size.must_equal 235
|
20
|
-
end
|
21
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'minitest/autorun'
|
4
|
-
|
5
|
-
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
-
|
7
|
-
require 'archive/support/zlib'
|
8
|
-
require 'archive/support/binary_stringio'
|
9
|
-
|
10
|
-
describe "Zlib::ZWriter#write" do
|
11
|
-
it "calls the write method of the delegate" do
|
12
|
-
delegate = MiniTest::Mock.new
|
13
|
-
delegate.expect(
|
14
|
-
:write, ZlibSpecs.compressed_data.size, [ZlibSpecs.compressed_data]
|
15
|
-
)
|
16
|
-
Zlib::ZWriter.open(delegate) do |zw|
|
17
|
-
zw.write(ZlibSpecs.test_data)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
it "compresses data" do
|
22
|
-
compressed_data = BinaryStringIO.new
|
23
|
-
Zlib::ZWriter.open(compressed_data) do |zw|
|
24
|
-
zw.write(ZlibSpecs.test_data)
|
25
|
-
end
|
26
|
-
compressed_data.string.must_equal ZlibSpecs.compressed_data
|
27
|
-
end
|
28
|
-
end
|