rubyzip 1.2.0 → 2.3.0

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.
Files changed (102) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +89 -43
  3. data/Rakefile +3 -0
  4. data/lib/zip.rb +14 -3
  5. data/lib/zip/central_directory.rb +12 -8
  6. data/lib/zip/compressor.rb +1 -2
  7. data/lib/zip/constants.rb +55 -3
  8. data/lib/zip/crypto/decrypted_io.rb +40 -0
  9. data/lib/zip/crypto/null_encryption.rb +2 -4
  10. data/lib/zip/crypto/traditional_encryption.rb +9 -9
  11. data/lib/zip/decompressor.rb +20 -2
  12. data/lib/zip/dos_time.rb +13 -8
  13. data/lib/zip/entry.rb +115 -80
  14. data/lib/zip/entry_set.rb +6 -4
  15. data/lib/zip/errors.rb +2 -0
  16. data/lib/zip/extra_field.rb +12 -10
  17. data/lib/zip/extra_field/generic.rb +10 -9
  18. data/lib/zip/extra_field/ntfs.rb +4 -0
  19. data/lib/zip/extra_field/old_unix.rb +3 -1
  20. data/lib/zip/extra_field/universal_time.rb +42 -12
  21. data/lib/zip/extra_field/unix.rb +3 -1
  22. data/lib/zip/extra_field/zip64.rb +4 -2
  23. data/lib/zip/extra_field/zip64_placeholder.rb +1 -2
  24. data/lib/zip/file.rb +136 -100
  25. data/lib/zip/filesystem.rb +199 -179
  26. data/lib/zip/inflater.rb +24 -36
  27. data/lib/zip/input_stream.rb +37 -27
  28. data/lib/zip/ioextras.rb +1 -1
  29. data/lib/zip/ioextras/abstract_input_stream.rb +20 -9
  30. data/lib/zip/ioextras/abstract_output_stream.rb +4 -4
  31. data/lib/zip/null_decompressor.rb +1 -9
  32. data/lib/zip/output_stream.rb +19 -10
  33. data/lib/zip/pass_thru_compressor.rb +2 -2
  34. data/lib/zip/pass_thru_decompressor.rb +14 -23
  35. data/lib/zip/streamable_directory.rb +3 -3
  36. data/lib/zip/streamable_stream.rb +6 -10
  37. data/lib/zip/version.rb +1 -1
  38. data/samples/example.rb +2 -2
  39. data/samples/example_filesystem.rb +1 -1
  40. data/samples/example_recursive.rb +15 -18
  41. data/samples/gtk_ruby_zip.rb +20 -20
  42. data/samples/qtzip.rb +7 -7
  43. data/samples/write_simple.rb +2 -4
  44. data/samples/zipfind.rb +23 -22
  45. metadata +41 -130
  46. data/test/basic_zip_file_test.rb +0 -60
  47. data/test/case_sensitivity_test.rb +0 -69
  48. data/test/central_directory_entry_test.rb +0 -69
  49. data/test/central_directory_test.rb +0 -100
  50. data/test/crypto/null_encryption_test.rb +0 -53
  51. data/test/crypto/traditional_encryption_test.rb +0 -80
  52. data/test/data/WarnInvalidDate.zip +0 -0
  53. data/test/data/file1.txt +0 -46
  54. data/test/data/file1.txt.deflatedData +0 -0
  55. data/test/data/file2.txt +0 -1504
  56. data/test/data/globTest.zip +0 -0
  57. data/test/data/globTest/foo.txt +0 -0
  58. data/test/data/globTest/foo/bar/baz/foo.txt +0 -0
  59. data/test/data/globTest/food.txt +0 -0
  60. data/test/data/mimetype +0 -1
  61. data/test/data/notzippedruby.rb +0 -7
  62. data/test/data/ntfs.zip +0 -0
  63. data/test/data/oddExtraField.zip +0 -0
  64. data/test/data/rubycode.zip +0 -0
  65. data/test/data/rubycode2.zip +0 -0
  66. data/test/data/test.xls +0 -0
  67. data/test/data/testDirectory.bin +0 -0
  68. data/test/data/zip64-sample.zip +0 -0
  69. data/test/data/zipWithDirs.zip +0 -0
  70. data/test/data/zipWithEncryption.zip +0 -0
  71. data/test/deflater_test.rb +0 -65
  72. data/test/encryption_test.rb +0 -42
  73. data/test/entry_set_test.rb +0 -152
  74. data/test/entry_test.rb +0 -163
  75. data/test/errors_test.rb +0 -34
  76. data/test/extra_field_test.rb +0 -76
  77. data/test/file_extract_directory_test.rb +0 -54
  78. data/test/file_extract_test.rb +0 -83
  79. data/test/file_permissions_test.rb +0 -69
  80. data/test/file_split_test.rb +0 -57
  81. data/test/file_test.rb +0 -563
  82. data/test/filesystem/dir_iterator_test.rb +0 -58
  83. data/test/filesystem/directory_test.rb +0 -121
  84. data/test/filesystem/file_mutating_test.rb +0 -88
  85. data/test/filesystem/file_nonmutating_test.rb +0 -508
  86. data/test/filesystem/file_stat_test.rb +0 -64
  87. data/test/gentestfiles.rb +0 -122
  88. data/test/inflater_test.rb +0 -14
  89. data/test/input_stream_test.rb +0 -182
  90. data/test/ioextras/abstract_input_stream_test.rb +0 -102
  91. data/test/ioextras/abstract_output_stream_test.rb +0 -106
  92. data/test/ioextras/fake_io_test.rb +0 -18
  93. data/test/local_entry_test.rb +0 -154
  94. data/test/output_stream_test.rb +0 -128
  95. data/test/pass_thru_compressor_test.rb +0 -30
  96. data/test/pass_thru_decompressor_test.rb +0 -14
  97. data/test/samples/example_recursive_test.rb +0 -37
  98. data/test/settings_test.rb +0 -95
  99. data/test/test_helper.rb +0 -221
  100. data/test/unicode_file_names_and_comments_test.rb +0 -50
  101. data/test/zip64_full_test.rb +0 -51
  102. data/test/zip64_support_test.rb +0 -14
Binary file
File without changes
File without changes
File without changes
@@ -1 +0,0 @@
1
- application/epub+zip
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- class NotZippedRuby
4
- def return_true
5
- true
6
- end
7
- end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,65 +0,0 @@
1
- require 'test_helper'
2
-
3
- class DeflaterTest < MiniTest::Test
4
- include CrcTest
5
-
6
- DEFLATER_TEST_FILE = 'test/data/generated/deflatertest.bin'
7
- BEST_COMP_FILE = 'test/data/generated/compressiontest_best_compression.bin'
8
- DEFAULT_COMP_FILE = 'test/data/generated/compressiontest_default_compression.bin'
9
- NO_COMP_FILE = 'test/data/generated/compressiontest_no_compression.bin'
10
-
11
- def test_output_operator
12
- txt = load_file('test/data/file2.txt')
13
- deflate(txt, DEFLATER_TEST_FILE)
14
- inflatedTxt = inflate(DEFLATER_TEST_FILE)
15
- assert_equal(txt, inflatedTxt)
16
- end
17
-
18
- def test_default_compression
19
- txt = load_file('test/data/file2.txt')
20
-
21
- Zip.default_compression = ::Zlib::BEST_COMPRESSION
22
- deflate(txt, BEST_COMP_FILE)
23
- Zip.default_compression = ::Zlib::DEFAULT_COMPRESSION
24
- deflate(txt, DEFAULT_COMP_FILE)
25
- Zip.default_compression = ::Zlib::NO_COMPRESSION
26
- deflate(txt, NO_COMP_FILE)
27
-
28
- best = File.size(BEST_COMP_FILE)
29
- default = File.size(DEFAULT_COMP_FILE)
30
- no = File.size(NO_COMP_FILE)
31
-
32
- assert(best < default)
33
- assert(best < no)
34
- assert(default < no)
35
- end
36
-
37
- private
38
-
39
- def load_file(fileName)
40
- txt = nil
41
- File.open(fileName, 'rb') { |f| txt = f.read }
42
- end
43
-
44
- def deflate(data, fileName)
45
- File.open(fileName, 'wb') do |file|
46
- deflater = ::Zip::Deflater.new(file)
47
- deflater << data
48
- deflater.finish
49
- assert_equal(deflater.size, data.size)
50
- file << 'trailing data for zlib with -MAX_WBITS'
51
- end
52
- end
53
-
54
- def inflate(fileName)
55
- txt = nil
56
- File.open(fileName, 'rb') do |file|
57
- inflater = ::Zip::Inflater.new(file)
58
- txt = inflater.sysread
59
- end
60
- end
61
-
62
- def test_crc
63
- run_crc_test(::Zip::Deflater)
64
- end
65
- end
@@ -1,42 +0,0 @@
1
- require 'test_helper'
2
-
3
- class EncryptionTest < MiniTest::Test
4
- ENCRYPT_ZIP_TEST_FILE = 'test/data/zipWithEncryption.zip'
5
- INPUT_FILE1 = 'test/data/file1.txt'
6
-
7
- def setup
8
- @default_compression = Zip.default_compression
9
- Zip.default_compression = ::Zlib::DEFAULT_COMPRESSION
10
- end
11
-
12
- def teardown
13
- Zip.default_compression = @default_compression
14
- end
15
-
16
- def test_encrypt
17
- test_file = open(ENCRYPT_ZIP_TEST_FILE, 'rb').read
18
-
19
- @rand = [250, 143, 107, 13, 143, 22, 155, 75, 228, 150, 12]
20
- @output = ::Zip::DOSTime.stub(:now, ::Zip::DOSTime.new(2014, 12, 17, 15, 56, 24)) do
21
- Random.stub(:rand, ->(_range) { @rand.shift }) do
22
- Zip::OutputStream.write_buffer(::StringIO.new(''), Zip::TraditionalEncrypter.new('password')) do |zos|
23
- zos.put_next_entry('file1.txt')
24
- zos.write open(INPUT_FILE1).read
25
- end.string
26
- end
27
- end
28
-
29
- @output.unpack('C*').each_with_index do |c, i|
30
- assert_equal test_file[i].ord, c
31
- end
32
- end
33
-
34
- def test_decrypt
35
- Zip::InputStream.open(ENCRYPT_ZIP_TEST_FILE, 0, Zip::TraditionalDecrypter.new('password')) do |zis|
36
- entry = zis.get_next_entry
37
- assert_equal 'file1.txt', entry.name
38
- assert_equal 1327, entry.size
39
- assert_equal open(INPUT_FILE1, 'r').read, zis.read
40
- end
41
- end
42
- end
@@ -1,152 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ZipEntrySetTest < MiniTest::Test
4
- ZIP_ENTRIES = [
5
- ::Zip::Entry.new('zipfile.zip', 'name1', 'comment1'),
6
- ::Zip::Entry.new('zipfile.zip', 'name3', 'comment1'),
7
- ::Zip::Entry.new('zipfile.zip', 'name2', 'comment1'),
8
- ::Zip::Entry.new('zipfile.zip', 'name4', 'comment1'),
9
- ::Zip::Entry.new('zipfile.zip', 'name5', 'comment1'),
10
- ::Zip::Entry.new('zipfile.zip', 'name6', 'comment1')
11
- ]
12
-
13
- def setup
14
- @zipEntrySet = ::Zip::EntrySet.new(ZIP_ENTRIES)
15
- end
16
-
17
- def teardown
18
- ::Zip.reset!
19
- end
20
-
21
- def test_include
22
- assert(@zipEntrySet.include?(ZIP_ENTRIES.first))
23
- assert(!@zipEntrySet.include?(::Zip::Entry.new('different.zip', 'different', 'aComment')))
24
- end
25
-
26
- def test_size
27
- assert_equal(ZIP_ENTRIES.size, @zipEntrySet.size)
28
- assert_equal(ZIP_ENTRIES.size, @zipEntrySet.length)
29
- @zipEntrySet << ::Zip::Entry.new('a', 'b', 'c')
30
- assert_equal(ZIP_ENTRIES.size + 1, @zipEntrySet.length)
31
- end
32
-
33
- def test_add
34
- zes = ::Zip::EntrySet.new
35
- entry1 = ::Zip::Entry.new('zf.zip', 'name1')
36
- entry2 = ::Zip::Entry.new('zf.zip', 'name2')
37
- zes << entry1
38
- assert(zes.include?(entry1))
39
- zes.push(entry2)
40
- assert(zes.include?(entry2))
41
- end
42
-
43
- def test_delete
44
- assert_equal(ZIP_ENTRIES.size, @zipEntrySet.size)
45
- entry = @zipEntrySet.delete(ZIP_ENTRIES.first)
46
- assert_equal(ZIP_ENTRIES.size - 1, @zipEntrySet.size)
47
- assert_equal(ZIP_ENTRIES.first, entry)
48
-
49
- entry = @zipEntrySet.delete(ZIP_ENTRIES.first)
50
- assert_equal(ZIP_ENTRIES.size - 1, @zipEntrySet.size)
51
- assert_nil(entry)
52
- end
53
-
54
- def test_each
55
- # Used each instead each_with_index due the bug in jRuby
56
- count = 0
57
- @zipEntrySet.each do |entry|
58
- assert(ZIP_ENTRIES.include?(entry))
59
- count += 1
60
- end
61
- assert_equal(ZIP_ENTRIES.size, count)
62
- end
63
-
64
- def test_entries
65
- assert_equal(ZIP_ENTRIES, @zipEntrySet.entries)
66
- end
67
-
68
- def test_find_entry
69
- entries = [::Zip::Entry.new('zipfile.zip', 'MiXeDcAsEnAmE', 'comment1')]
70
-
71
- ::Zip.case_insensitive_match = true
72
- zipEntrySet = ::Zip::EntrySet.new(entries)
73
- assert_equal(entries[0], zipEntrySet.find_entry('MiXeDcAsEnAmE'))
74
- assert_equal(entries[0], zipEntrySet.find_entry('mixedcasename'))
75
-
76
- ::Zip.case_insensitive_match = false
77
- zipEntrySet = ::Zip::EntrySet.new(entries)
78
- assert_equal(entries[0], zipEntrySet.find_entry('MiXeDcAsEnAmE'))
79
- assert_equal(nil, zipEntrySet.find_entry('mixedcasename'))
80
- end
81
-
82
- def test_entries_with_sort
83
- ::Zip.sort_entries = true
84
- assert_equal(ZIP_ENTRIES.sort, @zipEntrySet.entries)
85
- ::Zip.sort_entries = false
86
- assert_equal(ZIP_ENTRIES, @zipEntrySet.entries)
87
- end
88
-
89
- def test_entries_sorted_in_each
90
- ::Zip.sort_entries = true
91
- arr = []
92
- @zipEntrySet.each do |entry|
93
- arr << entry
94
- end
95
- assert_equal(ZIP_ENTRIES.sort, arr)
96
- end
97
-
98
- def test_compound
99
- newEntry = ::Zip::Entry.new('zf.zip', 'new entry', "new entry's comment")
100
- assert_equal(ZIP_ENTRIES.size, @zipEntrySet.size)
101
- @zipEntrySet << newEntry
102
- assert_equal(ZIP_ENTRIES.size + 1, @zipEntrySet.size)
103
- assert(@zipEntrySet.include?(newEntry))
104
-
105
- @zipEntrySet.delete(newEntry)
106
- assert_equal(ZIP_ENTRIES.size, @zipEntrySet.size)
107
- end
108
-
109
- def test_dup
110
- copy = @zipEntrySet.dup
111
- assert_equal(@zipEntrySet, copy)
112
-
113
- # demonstrate that this is a deep copy
114
- copy.entries[0].name = 'a totally different name'
115
- assert(@zipEntrySet != copy)
116
- end
117
-
118
- def test_parent
119
- entries = [
120
- ::Zip::Entry.new('zf.zip', 'a/'),
121
- ::Zip::Entry.new('zf.zip', 'a/b/'),
122
- ::Zip::Entry.new('zf.zip', 'a/b/c/')
123
- ]
124
- entrySet = ::Zip::EntrySet.new(entries)
125
-
126
- assert_equal(nil, entrySet.parent(entries[0]))
127
- assert_equal(entries[0], entrySet.parent(entries[1]))
128
- assert_equal(entries[1], entrySet.parent(entries[2]))
129
- end
130
-
131
- def test_glob
132
- res = @zipEntrySet.glob('name[2-4]')
133
- assert_equal(3, res.size)
134
- assert_equal(ZIP_ENTRIES[1, 3].sort, res.sort)
135
- end
136
-
137
- def test_glob2
138
- entries = [
139
- ::Zip::Entry.new('zf.zip', 'a/'),
140
- ::Zip::Entry.new('zf.zip', 'a/b/b1'),
141
- ::Zip::Entry.new('zf.zip', 'a/b/c/'),
142
- ::Zip::Entry.new('zf.zip', 'a/b/c/c1')
143
- ]
144
- entrySet = ::Zip::EntrySet.new(entries)
145
-
146
- assert_equal(entries[0, 1], entrySet.glob('*'))
147
- # assert_equal(entries[FIXME], entrySet.glob("**"))
148
- # res = entrySet.glob('a*')
149
- # assert_equal(entries.size, res.size)
150
- # assert_equal(entrySet.map { |e| e.name }, res.map { |e| e.name })
151
- end
152
- end
@@ -1,163 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ZipEntryTest < MiniTest::Test
4
- TEST_ZIPFILE = 'someZipFile.zip'
5
- TEST_COMMENT = 'a comment'
6
- TEST_COMPRESSED_SIZE = 1234
7
- TEST_CRC = 325_324
8
- TEST_EXTRA = 'Some data here'
9
- TEST_COMPRESSIONMETHOD = ::Zip::Entry::DEFLATED
10
- TEST_NAME = 'entry name'
11
- TEST_SIZE = 8432
12
- TEST_ISDIRECTORY = false
13
- TEST_TIME = Time.now
14
-
15
- def test_constructor_and_getters
16
- entry = ::Zip::Entry.new(TEST_ZIPFILE,
17
- TEST_NAME,
18
- TEST_COMMENT,
19
- TEST_EXTRA,
20
- TEST_COMPRESSED_SIZE,
21
- TEST_CRC,
22
- TEST_COMPRESSIONMETHOD,
23
- TEST_SIZE,
24
- TEST_TIME)
25
-
26
- assert_equal(TEST_COMMENT, entry.comment)
27
- assert_equal(TEST_COMPRESSED_SIZE, entry.compressed_size)
28
- assert_equal(TEST_CRC, entry.crc)
29
- assert_instance_of(::Zip::ExtraField, entry.extra)
30
- assert_equal(TEST_COMPRESSIONMETHOD, entry.compression_method)
31
- assert_equal(TEST_NAME, entry.name)
32
- assert_equal(TEST_SIZE, entry.size)
33
- assert_equal(TEST_TIME, entry.time)
34
- end
35
-
36
- def test_is_directory_and_is_file
37
- assert(::Zip::Entry.new(TEST_ZIPFILE, 'hello').file?)
38
- assert(!::Zip::Entry.new(TEST_ZIPFILE, 'hello').directory?)
39
-
40
- assert(::Zip::Entry.new(TEST_ZIPFILE, 'dir/hello').file?)
41
- assert(!::Zip::Entry.new(TEST_ZIPFILE, 'dir/hello').directory?)
42
-
43
- assert(::Zip::Entry.new(TEST_ZIPFILE, 'hello/').directory?)
44
- assert(!::Zip::Entry.new(TEST_ZIPFILE, 'hello/').file?)
45
-
46
- assert(::Zip::Entry.new(TEST_ZIPFILE, 'dir/hello/').directory?)
47
- assert(!::Zip::Entry.new(TEST_ZIPFILE, 'dir/hello/').file?)
48
- end
49
-
50
- def test_equality
51
- entry1 = ::Zip::Entry.new('file.zip', 'name', 'isNotCompared',
52
- 'something extra', 123, 1234,
53
- ::Zip::Entry::DEFLATED, 10_000)
54
- entry2 = ::Zip::Entry.new('file.zip', 'name', 'isNotComparedXXX',
55
- 'something extra', 123, 1234,
56
- ::Zip::Entry::DEFLATED, 10_000)
57
- entry3 = ::Zip::Entry.new('file.zip', 'name2', 'isNotComparedXXX',
58
- 'something extra', 123, 1234,
59
- ::Zip::Entry::DEFLATED, 10_000)
60
- entry4 = ::Zip::Entry.new('file.zip', 'name2', 'isNotComparedXXX',
61
- 'something extraXX', 123, 1234,
62
- ::Zip::Entry::DEFLATED, 10_000)
63
- entry5 = ::Zip::Entry.new('file.zip', 'name2', 'isNotComparedXXX',
64
- 'something extraXX', 12, 1234,
65
- ::Zip::Entry::DEFLATED, 10_000)
66
- entry6 = ::Zip::Entry.new('file.zip', 'name2', 'isNotComparedXXX',
67
- 'something extraXX', 12, 123,
68
- ::Zip::Entry::DEFLATED, 10_000)
69
- entry7 = ::Zip::Entry.new('file.zip', 'name2', 'isNotComparedXXX',
70
- 'something extraXX', 12, 123,
71
- ::Zip::Entry::STORED, 10_000)
72
- entry8 = ::Zip::Entry.new('file.zip', 'name2', 'isNotComparedXXX',
73
- 'something extraXX', 12, 123,
74
- ::Zip::Entry::STORED, 100_000)
75
-
76
- assert_equal(entry1, entry1)
77
- assert_equal(entry1, entry2)
78
-
79
- assert(entry2 != entry3)
80
- assert(entry3 != entry4)
81
- assert(entry4 != entry5)
82
- assert(entry5 != entry6)
83
- assert(entry6 != entry7)
84
- assert(entry7 != entry8)
85
-
86
- assert(entry7 != 'hello')
87
- assert(entry7 != 12)
88
- end
89
-
90
- def test_compare
91
- assert_equal(0, (::Zip::Entry.new('zf.zip', 'a') <=> ::Zip::Entry.new('zf.zip', 'a')))
92
- assert_equal(1, (::Zip::Entry.new('zf.zip', 'b') <=> ::Zip::Entry.new('zf.zip', 'a')))
93
- assert_equal(-1, (::Zip::Entry.new('zf.zip', 'a') <=> ::Zip::Entry.new('zf.zip', 'b')))
94
-
95
- entries = [
96
- ::Zip::Entry.new('zf.zip', '5'),
97
- ::Zip::Entry.new('zf.zip', '1'),
98
- ::Zip::Entry.new('zf.zip', '3'),
99
- ::Zip::Entry.new('zf.zip', '4'),
100
- ::Zip::Entry.new('zf.zip', '0'),
101
- ::Zip::Entry.new('zf.zip', '2')
102
- ]
103
-
104
- entries.sort!
105
- assert_equal('0', entries[0].to_s)
106
- assert_equal('1', entries[1].to_s)
107
- assert_equal('2', entries[2].to_s)
108
- assert_equal('3', entries[3].to_s)
109
- assert_equal('4', entries[4].to_s)
110
- assert_equal('5', entries[5].to_s)
111
- end
112
-
113
- def test_parent_as_string
114
- entry1 = ::Zip::Entry.new('zf.zip', 'aa')
115
- entry2 = ::Zip::Entry.new('zf.zip', 'aa/')
116
- entry3 = ::Zip::Entry.new('zf.zip', 'aa/bb')
117
- entry4 = ::Zip::Entry.new('zf.zip', 'aa/bb/')
118
- entry5 = ::Zip::Entry.new('zf.zip', 'aa/bb/cc')
119
- entry6 = ::Zip::Entry.new('zf.zip', 'aa/bb/cc/')
120
-
121
- assert_equal(nil, entry1.parent_as_string)
122
- assert_equal(nil, entry2.parent_as_string)
123
- assert_equal('aa/', entry3.parent_as_string)
124
- assert_equal('aa/', entry4.parent_as_string)
125
- assert_equal('aa/bb/', entry5.parent_as_string)
126
- assert_equal('aa/bb/', entry6.parent_as_string)
127
- end
128
-
129
- def test_entry_name_cannot_start_with_slash
130
- assert_raises(::Zip::EntryNameError) { ::Zip::Entry.new('zf.zip', '/hej/der') }
131
- end
132
-
133
- def test_store_file_without_compression
134
- File.delete('/tmp/no_compress.zip') if File.exist?('/tmp/no_compress.zip')
135
- files = Dir[File.join('test/data/globTest', '**', '**')]
136
-
137
- Zip.setup do |z|
138
- z.write_zip64_support = false
139
- end
140
-
141
- zipfile = Zip::File.open('/tmp/no_compress.zip', Zip::File::CREATE)
142
- mimetype_entry = Zip::Entry.new(zipfile, # @zipfile
143
- 'mimetype', # @name
144
- '', # @comment
145
- '', # @extra
146
- 0, # @compressed_size
147
- 0, # @crc
148
- Zip::Entry::STORED) # @comppressed_method
149
-
150
- zipfile.add(mimetype_entry, 'test/data/mimetype')
151
-
152
- files.each do |file|
153
- zipfile.add(file.sub('test/data/globTest/', ''), file)
154
- end
155
- zipfile.close
156
-
157
- f = File.open('/tmp/no_compress.zip', 'rb')
158
- first_100_bytes = f.read(100)
159
- f.close
160
-
161
- assert_match(/mimetypeapplication\/epub\+zip/, first_100_bytes)
162
- end
163
- end