rubyzip 1.2.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +55 -14
  3. data/lib/zip.rb +3 -1
  4. data/lib/zip/entry.rb +12 -0
  5. data/lib/zip/errors.rb +1 -0
  6. data/lib/zip/file.rb +7 -0
  7. data/lib/zip/version.rb +1 -1
  8. metadata +10 -153
  9. data/test/basic_zip_file_test.rb +0 -60
  10. data/test/case_sensitivity_test.rb +0 -69
  11. data/test/central_directory_entry_test.rb +0 -69
  12. data/test/central_directory_test.rb +0 -100
  13. data/test/crypto/null_encryption_test.rb +0 -57
  14. data/test/crypto/traditional_encryption_test.rb +0 -80
  15. data/test/data/WarnInvalidDate.zip +0 -0
  16. data/test/data/file1.txt +0 -46
  17. data/test/data/file1.txt.deflatedData +0 -0
  18. data/test/data/file2.txt +0 -1504
  19. data/test/data/globTest.zip +0 -0
  20. data/test/data/globTest/foo.txt +0 -0
  21. data/test/data/globTest/foo/bar/baz/foo.txt +0 -0
  22. data/test/data/globTest/food.txt +0 -0
  23. data/test/data/gpbit3stored.zip +0 -0
  24. data/test/data/mimetype +0 -1
  25. data/test/data/notzippedruby.rb +0 -7
  26. data/test/data/ntfs.zip +0 -0
  27. data/test/data/oddExtraField.zip +0 -0
  28. data/test/data/path_traversal/Makefile +0 -10
  29. data/test/data/path_traversal/jwilk/README.md +0 -5
  30. data/test/data/path_traversal/jwilk/absolute1.zip +0 -0
  31. data/test/data/path_traversal/jwilk/absolute2.zip +0 -0
  32. data/test/data/path_traversal/jwilk/dirsymlink.zip +0 -0
  33. data/test/data/path_traversal/jwilk/dirsymlink2a.zip +0 -0
  34. data/test/data/path_traversal/jwilk/dirsymlink2b.zip +0 -0
  35. data/test/data/path_traversal/jwilk/relative0.zip +0 -0
  36. data/test/data/path_traversal/jwilk/relative2.zip +0 -0
  37. data/test/data/path_traversal/jwilk/symlink.zip +0 -0
  38. data/test/data/path_traversal/relative1.zip +0 -0
  39. data/test/data/path_traversal/tilde.zip +0 -0
  40. data/test/data/path_traversal/tuzovakaoff/README.md +0 -3
  41. data/test/data/path_traversal/tuzovakaoff/absolutepath.zip +0 -0
  42. data/test/data/path_traversal/tuzovakaoff/symlink.zip +0 -0
  43. data/test/data/rubycode.zip +0 -0
  44. data/test/data/rubycode2.zip +0 -0
  45. data/test/data/test.xls +0 -0
  46. data/test/data/testDirectory.bin +0 -0
  47. data/test/data/zip64-sample.zip +0 -0
  48. data/test/data/zipWithDirs.zip +0 -0
  49. data/test/data/zipWithEncryption.zip +0 -0
  50. data/test/deflater_test.rb +0 -65
  51. data/test/encryption_test.rb +0 -42
  52. data/test/entry_set_test.rb +0 -163
  53. data/test/entry_test.rb +0 -154
  54. data/test/errors_test.rb +0 -35
  55. data/test/extra_field_test.rb +0 -76
  56. data/test/file_extract_directory_test.rb +0 -54
  57. data/test/file_extract_test.rb +0 -83
  58. data/test/file_permissions_test.rb +0 -65
  59. data/test/file_split_test.rb +0 -57
  60. data/test/file_test.rb +0 -646
  61. data/test/filesystem/dir_iterator_test.rb +0 -58
  62. data/test/filesystem/directory_test.rb +0 -139
  63. data/test/filesystem/file_mutating_test.rb +0 -87
  64. data/test/filesystem/file_nonmutating_test.rb +0 -508
  65. data/test/filesystem/file_stat_test.rb +0 -64
  66. data/test/gentestfiles.rb +0 -126
  67. data/test/inflater_test.rb +0 -14
  68. data/test/input_stream_test.rb +0 -182
  69. data/test/ioextras/abstract_input_stream_test.rb +0 -102
  70. data/test/ioextras/abstract_output_stream_test.rb +0 -106
  71. data/test/ioextras/fake_io_test.rb +0 -18
  72. data/test/local_entry_test.rb +0 -154
  73. data/test/output_stream_test.rb +0 -128
  74. data/test/pass_thru_compressor_test.rb +0 -30
  75. data/test/pass_thru_decompressor_test.rb +0 -14
  76. data/test/path_traversal_test.rb +0 -141
  77. data/test/samples/example_recursive_test.rb +0 -37
  78. data/test/settings_test.rb +0 -95
  79. data/test/test_helper.rb +0 -234
  80. data/test/unicode_file_names_and_comments_test.rb +0 -62
  81. data/test/zip64_full_test.rb +0 -51
  82. data/test/zip64_support_test.rb +0 -14
@@ -1,62 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'test_helper'
4
-
5
- class ZipUnicodeFileNamesAndComments < MiniTest::Test
6
- FILENAME = File.join(File.dirname(__FILE__), 'test1.zip')
7
-
8
- def test_unicode_file_name
9
- file_entrys = ['текстовыйфайл.txt', 'Résumé.txt', '슬레이어스휘.txt']
10
- directory_entrys = ['папка/текстовыйфайл.txt', 'Résumé/Résumé.txt', '슬레이어스휘/슬레이어스휘.txt']
11
- stream = ::Zip::OutputStream.open(FILENAME) do |io|
12
- file_entrys.each do |filename|
13
- io.put_next_entry(filename)
14
- io.write(filename)
15
- end
16
- directory_entrys.each do |filepath|
17
- io.put_next_entry(filepath)
18
- io.write(filepath)
19
- end
20
- end
21
- assert(!stream.nil?)
22
- ::Zip::InputStream.open(FILENAME) do |io|
23
- file_entrys.each do |filename|
24
- entry = io.get_next_entry
25
- entry_name = entry.name
26
- entry_name = entry_name.force_encoding('UTF-8')
27
- assert(filename == entry_name)
28
- end
29
- directory_entrys.each do |filepath|
30
- entry = io.get_next_entry
31
- entry_name = entry.name
32
- entry_name = entry_name.force_encoding('UTF-8')
33
- assert(filepath == entry_name)
34
- end
35
- end
36
-
37
- ::Zip.force_entry_names_encoding = 'UTF-8'
38
- ::Zip::File.open(FILENAME) do |zip|
39
- file_entrys.each do |filename|
40
- refute_nil(zip.find_entry(filename))
41
- end
42
- directory_entrys.each do |filepath|
43
- refute_nil(zip.find_entry(filepath))
44
- end
45
- end
46
- ::Zip.force_entry_names_encoding = nil
47
-
48
- ::File.unlink(FILENAME)
49
- end
50
-
51
- def test_unicode_comment
52
- str = '渠道升级'
53
- ::Zip::File.open(FILENAME, Zip::File::CREATE) do |z|
54
- z.comment = str
55
- end
56
-
57
- ::Zip::File.open(FILENAME) do |z|
58
- assert(z.comment.force_encoding('UTF-8') == str)
59
- end
60
- ::File.unlink(FILENAME)
61
- end
62
- end
@@ -1,51 +0,0 @@
1
- if ENV['FULL_ZIP64_TEST']
2
- require 'minitest/autorun'
3
- require 'minitest/unit'
4
- require 'fileutils'
5
- require 'zip'
6
-
7
- # test zip64 support for real, by actually exceeding the 32-bit size/offset limits
8
- # this test does not, of course, run with the normal unit tests! ;)
9
-
10
- class Zip64FullTest < MiniTest::Test
11
- def teardown
12
- ::Zip.reset!
13
- end
14
-
15
- def prepare_test_file(test_filename)
16
- ::File.delete(test_filename) if ::File.exist?(test_filename)
17
- test_filename
18
- end
19
-
20
- def test_large_zip_file
21
- ::Zip.write_zip64_support = true
22
- first_text = 'starting out small'
23
- last_text = 'this tests files starting after 4GB in the archive'
24
- test_filename = prepare_test_file('huge.zip')
25
- ::Zip::OutputStream.open(test_filename) do |io|
26
- io.put_next_entry('first_file.txt')
27
- io.write(first_text)
28
-
29
- # write just over 4GB (stored, so the zip file exceeds 4GB)
30
- buf = 'blah' * 16_384
31
- io.put_next_entry('huge_file', nil, nil, ::Zip::Entry::STORED)
32
- 65_537.times { io.write(buf) }
33
-
34
- io.put_next_entry('last_file.txt')
35
- io.write(last_text)
36
- end
37
-
38
- ::Zip::File.open(test_filename) do |zf|
39
- assert_equal %w[first_file.txt huge_file last_file.txt], zf.entries.map(&:name)
40
- assert_equal first_text, zf.read('first_file.txt')
41
- assert_equal last_text, zf.read('last_file.txt')
42
- end
43
-
44
- # note: if this fails, be sure you have UnZip version 6.0 or newer
45
- # as this is the first version to support zip64 extensions
46
- # but some OSes (*cough* OSX) still bundle a 5.xx release
47
- assert system("unzip -tqq #{test_filename}"), 'third-party zip validation failed'
48
- end
49
- end
50
-
51
- end
@@ -1,14 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Zip64SupportTest < MiniTest::Test
4
- TEST_FILE = File.join(File.dirname(__FILE__), 'data', 'zip64-sample.zip')
5
-
6
- def test_open_zip64_file
7
- zip_file = ::Zip::File.open(TEST_FILE)
8
- assert(!zip_file.nil?)
9
- assert(zip_file.entries.count == 2)
10
- test_rb = zip_file.entries.find { |x| x.name == 'test.rb' }
11
- assert(test_rb.size == 482)
12
- assert(test_rb.compressed_size == 229)
13
- end
14
- end