rubyzip 1.1.7 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubyzip might be problematic. Click here for more details.

Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +69 -32
  3. data/Rakefile +3 -4
  4. data/lib/zip.rb +3 -5
  5. data/lib/zip/central_directory.rb +7 -7
  6. data/lib/zip/compressor.rb +0 -0
  7. data/lib/zip/constants.rb +2 -2
  8. data/lib/zip/crypto/null_encryption.rb +3 -3
  9. data/lib/zip/crypto/traditional_encryption.rb +5 -5
  10. data/lib/zip/decompressor.rb +2 -2
  11. data/lib/zip/deflater.rb +8 -6
  12. data/lib/zip/dos_time.rb +4 -5
  13. data/lib/zip/entry.rb +68 -80
  14. data/lib/zip/entry_set.rb +11 -11
  15. data/lib/zip/errors.rb +1 -0
  16. data/lib/zip/extra_field.rb +6 -6
  17. data/lib/zip/extra_field/generic.rb +7 -7
  18. data/lib/zip/extra_field/ntfs.rb +14 -16
  19. data/lib/zip/extra_field/old_unix.rb +9 -10
  20. data/lib/zip/extra_field/universal_time.rb +14 -14
  21. data/lib/zip/extra_field/unix.rb +8 -9
  22. data/lib/zip/extra_field/zip64.rb +12 -11
  23. data/lib/zip/extra_field/zip64_placeholder.rb +1 -1
  24. data/lib/zip/file.rb +45 -49
  25. data/lib/zip/filesystem.rb +132 -135
  26. data/lib/zip/inflater.rb +3 -3
  27. data/lib/zip/input_stream.rb +13 -7
  28. data/lib/zip/ioextras.rb +1 -3
  29. data/lib/zip/ioextras/abstract_input_stream.rb +5 -9
  30. data/lib/zip/ioextras/abstract_output_stream.rb +0 -2
  31. data/lib/zip/null_compressor.rb +2 -2
  32. data/lib/zip/null_decompressor.rb +3 -3
  33. data/lib/zip/null_input_stream.rb +0 -0
  34. data/lib/zip/output_stream.rb +8 -9
  35. data/lib/zip/pass_thru_compressor.rb +4 -4
  36. data/lib/zip/pass_thru_decompressor.rb +2 -3
  37. data/lib/zip/streamable_directory.rb +2 -2
  38. data/lib/zip/streamable_stream.rb +2 -2
  39. data/lib/zip/version.rb +1 -1
  40. data/samples/example.rb +29 -39
  41. data/samples/example_filesystem.rb +16 -18
  42. data/samples/example_recursive.rb +33 -24
  43. data/samples/{gtkRubyzip.rb → gtk_ruby_zip.rb} +23 -25
  44. data/samples/qtzip.rb +17 -26
  45. data/samples/write_simple.rb +12 -13
  46. data/samples/zipfind.rb +24 -32
  47. data/test/basic_zip_file_test.rb +11 -15
  48. data/test/case_sensitivity_test.rb +69 -0
  49. data/test/central_directory_entry_test.rb +31 -35
  50. data/test/central_directory_test.rb +46 -50
  51. data/test/crypto/null_encryption_test.rb +2 -2
  52. data/test/crypto/traditional_encryption_test.rb +5 -5
  53. data/test/data/notzippedruby.rb +1 -1
  54. data/test/data/oddExtraField.zip +0 -0
  55. data/test/data/test.xls +0 -0
  56. data/test/deflater_test.rb +10 -12
  57. data/test/encryption_test.rb +2 -2
  58. data/test/entry_set_test.rb +38 -24
  59. data/test/entry_test.rb +76 -78
  60. data/test/errors_test.rb +0 -2
  61. data/test/extra_field_test.rb +19 -21
  62. data/test/file_extract_directory_test.rb +12 -14
  63. data/test/file_extract_test.rb +33 -40
  64. data/test/file_permissions_test.rb +69 -0
  65. data/test/file_split_test.rb +24 -27
  66. data/test/file_test.rb +174 -170
  67. data/test/filesystem/dir_iterator_test.rb +13 -17
  68. data/test/filesystem/directory_test.rb +80 -90
  69. data/test/filesystem/file_mutating_test.rb +51 -63
  70. data/test/filesystem/file_nonmutating_test.rb +222 -228
  71. data/test/filesystem/file_stat_test.rb +17 -19
  72. data/test/gentestfiles.rb +43 -55
  73. data/test/inflater_test.rb +1 -1
  74. data/test/input_stream_test.rb +42 -30
  75. data/test/ioextras/abstract_input_stream_test.rb +21 -22
  76. data/test/ioextras/abstract_output_stream_test.rb +32 -32
  77. data/test/local_entry_test.rb +35 -37
  78. data/test/output_stream_test.rb +20 -21
  79. data/test/pass_thru_compressor_test.rb +5 -6
  80. data/test/pass_thru_decompressor_test.rb +0 -1
  81. data/test/samples/example_recursive_test.rb +37 -0
  82. data/test/settings_test.rb +18 -15
  83. data/test/test_helper.rb +37 -44
  84. data/test/unicode_file_names_and_comments_test.rb +5 -7
  85. data/test/zip64_full_test.rb +9 -11
  86. data/test/zip64_support_test.rb +0 -1
  87. metadata +14 -32
@@ -3,18 +3,17 @@ require 'test_helper'
3
3
  class ZipFileExtractDirectoryTest < MiniTest::Test
4
4
  include CommonZipFileFixture
5
5
 
6
- TEST_OUT_NAME = "test/data/generated/emptyOutDir"
6
+ TEST_OUT_NAME = 'test/data/generated/emptyOutDir'
7
7
 
8
8
  def open_zip(&aProc)
9
- assert(aProc != nil)
9
+ assert(!aProc.nil?)
10
10
  ::Zip::File.open(TestZipFile::TEST_ZIP4.zip_name, &aProc)
11
11
  end
12
12
 
13
13
  def extract_test_dir(&aProc)
14
- open_zip {
15
- |zf|
14
+ open_zip do |zf|
16
15
  zf.extract(TestFiles::EMPTY_TEST_DIR, TEST_OUT_NAME, &aProc)
17
- }
16
+ end
18
17
  end
19
18
 
20
19
  def setup
@@ -24,32 +23,31 @@ class ZipFileExtractDirectoryTest < MiniTest::Test
24
23
  File.delete(TEST_OUT_NAME) if File.exist? TEST_OUT_NAME
25
24
  end
26
25
 
27
- def test_extractDirectory
26
+ def test_extract_directory
28
27
  extract_test_dir
29
28
  assert(File.directory?(TEST_OUT_NAME))
30
29
  end
31
30
 
32
- def test_extractDirectoryExistsAsDir
31
+ def test_extract_directory_exists_as_dir
33
32
  Dir.mkdir TEST_OUT_NAME
34
33
  extract_test_dir
35
34
  assert(File.directory?(TEST_OUT_NAME))
36
35
  end
37
36
 
38
- def test_extractDirectoryExistsAsFile
39
- File.open(TEST_OUT_NAME, "w") { |f| f.puts "something" }
37
+ def test_extract_directory_exists_as_file
38
+ File.open(TEST_OUT_NAME, 'w') { |f| f.puts 'something' }
40
39
  assert_raises(::Zip::DestinationFileExistsError) { extract_test_dir }
41
40
  end
42
41
 
43
- def test_extractDirectoryExistsAsFileOverwrite
44
- File.open(TEST_OUT_NAME, "w") { |f| f.puts "something" }
42
+ def test_extract_directory_exists_as_file_overwrite
43
+ File.open(TEST_OUT_NAME, 'w') { |f| f.puts 'something' }
45
44
  gotCalled = false
46
- extract_test_dir {
47
- |entry, destPath|
45
+ extract_test_dir do |entry, destPath|
48
46
  gotCalled = true
49
47
  assert_equal(TEST_OUT_NAME, destPath)
50
48
  assert(entry.directory?)
51
49
  true
52
- }
50
+ end
53
51
  assert(gotCalled)
54
52
  assert(File.directory?(TEST_OUT_NAME))
55
53
  end
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class ZipFileExtractTest < MiniTest::Test
4
4
  include CommonZipFileFixture
5
- EXTRACTED_FILENAME = "test/data/generated/extEntry"
5
+ EXTRACTED_FILENAME = 'test/data/generated/extEntry'
6
6
  ENTRY_TO_EXTRACT, *REMAINING_ENTRIES = TEST_ZIP.entry_names.reverse
7
7
 
8
8
  def setup
@@ -11,14 +11,12 @@ class ZipFileExtractTest < MiniTest::Test
11
11
  end
12
12
 
13
13
  def test_extract
14
- ::Zip::File.open(TEST_ZIP.zip_name) {
15
- |zf|
14
+ ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
16
15
  zf.extract(ENTRY_TO_EXTRACT, EXTRACTED_FILENAME)
17
16
 
18
17
  assert(File.exist?(EXTRACTED_FILENAME))
19
- AssertEntry::assert_contents(EXTRACTED_FILENAME,
20
- zf.get_input_stream(ENTRY_TO_EXTRACT) { |is| is.read })
21
-
18
+ AssertEntry.assert_contents(EXTRACTED_FILENAME,
19
+ zf.get_input_stream(ENTRY_TO_EXTRACT) { |is| is.read })
22
20
 
23
21
  ::File.unlink(EXTRACTED_FILENAME)
24
22
 
@@ -26,65 +24,60 @@ class ZipFileExtractTest < MiniTest::Test
26
24
  entry.extract(EXTRACTED_FILENAME)
27
25
 
28
26
  assert(File.exist?(EXTRACTED_FILENAME))
29
- AssertEntry::assert_contents(EXTRACTED_FILENAME,
30
- entry.get_input_stream() { |is| is.read })
31
-
32
- }
27
+ AssertEntry.assert_contents(EXTRACTED_FILENAME,
28
+ entry.get_input_stream { |is| is.read })
29
+ end
33
30
  end
34
31
 
35
- def test_extractExists
36
- writtenText = "written text"
37
- ::File.open(EXTRACTED_FILENAME, "w") { |f| f.write(writtenText) }
32
+ def test_extract_exists
33
+ writtenText = 'written text'
34
+ ::File.open(EXTRACTED_FILENAME, 'w') { |f| f.write(writtenText) }
38
35
 
39
- assert_raises(::Zip::DestinationFileExistsError) {
40
- ::Zip::File.open(TEST_ZIP.zip_name) { |zf|
36
+ assert_raises(::Zip::DestinationFileExistsError) do
37
+ ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
41
38
  zf.extract(zf.entries.first, EXTRACTED_FILENAME)
42
- }
43
- }
44
- File.open(EXTRACTED_FILENAME, "r") { |f|
39
+ end
40
+ end
41
+ File.open(EXTRACTED_FILENAME, 'r') do |f|
45
42
  assert_equal(writtenText, f.read)
46
- }
43
+ end
47
44
  end
48
45
 
49
- def test_extractExistsOverwrite
50
- writtenText = "written text"
51
- ::File.open(EXTRACTED_FILENAME, "w") { |f| f.write(writtenText) }
46
+ def test_extract_exists_overwrite
47
+ writtenText = 'written text'
48
+ ::File.open(EXTRACTED_FILENAME, 'w') { |f| f.write(writtenText) }
52
49
 
53
50
  gotCalledCorrectly = false
54
- ::Zip::File.open(TEST_ZIP.zip_name) {
55
- |zf|
56
- zf.extract(zf.entries.first, EXTRACTED_FILENAME) {
57
- |entry, extractLoc|
51
+ ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
52
+ zf.extract(zf.entries.first, EXTRACTED_FILENAME) do |entry, extractLoc|
58
53
  gotCalledCorrectly = zf.entries.first == entry &&
59
- extractLoc == EXTRACTED_FILENAME
54
+ extractLoc == EXTRACTED_FILENAME
60
55
  true
61
- }
62
- }
56
+ end
57
+ end
63
58
 
64
59
  assert(gotCalledCorrectly)
65
- ::File.open(EXTRACTED_FILENAME, "r") {
66
- |f|
60
+ ::File.open(EXTRACTED_FILENAME, 'r') do |f|
67
61
  assert(writtenText != f.read)
68
- }
62
+ end
69
63
  end
70
64
 
71
- def test_extractNonEntry
65
+ def test_extract_non_entry
72
66
  zf = ::Zip::File.new(TEST_ZIP.zip_name)
73
- assert_raises(Errno::ENOENT) { zf.extract("nonExistingEntry", "nonExistingEntry") }
67
+ assert_raises(Errno::ENOENT) { zf.extract('nonExistingEntry', 'nonExistingEntry') }
74
68
  ensure
75
69
  zf.close if zf
76
70
  end
77
71
 
78
- def test_extractNonEntry2
79
- outFile = "outfile"
80
- assert_raises(Errno::ENOENT) {
72
+ def test_extract_non_entry_2
73
+ outFile = 'outfile'
74
+ assert_raises(Errno::ENOENT) do
81
75
  zf = ::Zip::File.new(TEST_ZIP.zip_name)
82
- nonEntry = "hotdog-diddelidoo"
76
+ nonEntry = 'hotdog-diddelidoo'
83
77
  assert(!zf.entries.include?(nonEntry))
84
78
  zf.extract(nonEntry, outFile)
85
79
  zf.close
86
- }
80
+ end
87
81
  assert(!File.exist?(outFile))
88
82
  end
89
-
90
83
  end
@@ -0,0 +1,69 @@
1
+ require 'test_helper'
2
+
3
+ class FilePermissionsTest < MiniTest::Test
4
+
5
+ FILENAME = File.join(File.dirname(__FILE__), "umask.zip")
6
+
7
+ def teardown
8
+ ::File.unlink(FILENAME)
9
+ end
10
+
11
+ if ::Zip::RUNNING_ON_WINDOWS
12
+ # Windows tests
13
+
14
+ DEFAULT_PERMS = 0644
15
+
16
+ def test_windows_perms
17
+ create_file
18
+
19
+ assert_equal DEFAULT_PERMS, ::File.stat(FILENAME).mode
20
+ end
21
+
22
+ else
23
+ # Unix tests
24
+
25
+ DEFAULT_PERMS = 0100666
26
+
27
+ def test_current_umask
28
+ umask = DEFAULT_PERMS - ::File.umask
29
+ create_file
30
+
31
+ assert_equal umask, ::File.stat(FILENAME).mode
32
+ end
33
+
34
+ def test_umask_000
35
+ set_umask(0000) do
36
+ create_file
37
+ end
38
+
39
+ assert_equal DEFAULT_PERMS, ::File.stat(FILENAME).mode
40
+ end
41
+
42
+ def test_umask_066
43
+ umask = 0066
44
+ set_umask(umask) do
45
+ create_file
46
+ end
47
+
48
+ assert_equal((DEFAULT_PERMS - umask), ::File.stat(FILENAME).mode)
49
+ end
50
+
51
+ end
52
+
53
+ def create_file
54
+ ::Zip::File.open(FILENAME, ::Zip::File::CREATE) do |zip|
55
+ zip.comment = "test"
56
+ end
57
+ end
58
+
59
+ # If anything goes wrong, make sure the umask is restored.
60
+ def set_umask(umask, &block)
61
+ begin
62
+ saved_umask = ::File.umask(umask)
63
+ yield
64
+ ensure
65
+ ::File.umask(saved_umask)
66
+ end
67
+ end
68
+
69
+ end
@@ -2,9 +2,9 @@ require 'test_helper'
2
2
 
3
3
  class ZipFileSplitTest < MiniTest::Test
4
4
  TEST_ZIP = TestZipFile::TEST_ZIP2.clone
5
- TEST_ZIP.zip_name = "large_zip_file.zip"
6
- EXTRACTED_FILENAME = "test/data/generated/extEntrySplit"
7
- UNSPLITTED_FILENAME = "test/data/generated/unsplitted.zip"
5
+ TEST_ZIP.zip_name = 'large_zip_file.zip'
6
+ EXTRACTED_FILENAME = 'test/data/generated/extEntrySplit'
7
+ UNSPLITTED_FILENAME = 'test/data/generated/unsplitted.zip'
8
8
  ENTRY_TO_EXTRACT = TEST_ZIP.entry_names.first
9
9
 
10
10
  def setup
@@ -21,40 +21,37 @@ class ZipFileSplitTest < MiniTest::Test
21
21
  end
22
22
 
23
23
  def test_split_method_respond
24
- assert_respond_to ::Zip::File, :split, "Does not have split class method"
24
+ assert_respond_to ::Zip::File, :split, 'Does not have split class method'
25
25
  end
26
26
 
27
27
  def test_split
28
- result = ::Zip::File.split(TEST_ZIP.zip_name, 65536, false)
29
-
30
- unless result.nil?
31
- Dir["#{TEST_ZIP.zip_name}.*"].sort.each_with_index do |zip_file_name, index|
32
- File.open(zip_file_name, 'rb') do |zip_file|
33
- zip_file.read([::Zip::File::SPLIT_SIGNATURE].pack('V').size) if index == 0
34
- File.open(UNSPLITTED_FILENAME, 'ab') do |file|
35
- file << zip_file.read
36
- end
28
+ result = ::Zip::File.split(TEST_ZIP.zip_name, 65_536, false)
29
+
30
+ return if result.nil?
31
+ Dir["#{TEST_ZIP.zip_name}.*"].sort.each_with_index do |zip_file_name, index|
32
+ File.open(zip_file_name, 'rb') do |zip_file|
33
+ zip_file.read([::Zip::File::SPLIT_SIGNATURE].pack('V').size) if index == 0
34
+ File.open(UNSPLITTED_FILENAME, 'ab') do |file|
35
+ file << zip_file.read
37
36
  end
38
37
  end
38
+ end
39
39
 
40
- ::Zip::File.open(UNSPLITTED_FILENAME) do |zf|
41
- zf.extract(ENTRY_TO_EXTRACT, EXTRACTED_FILENAME)
42
-
43
- assert(File.exist?(EXTRACTED_FILENAME))
44
- AssertEntry::assert_contents(EXTRACTED_FILENAME,
45
- zf.get_input_stream(ENTRY_TO_EXTRACT) { |is| is.read })
46
-
40
+ ::Zip::File.open(UNSPLITTED_FILENAME) do |zf|
41
+ zf.extract(ENTRY_TO_EXTRACT, EXTRACTED_FILENAME)
47
42
 
48
- File.unlink(EXTRACTED_FILENAME)
43
+ assert(File.exist?(EXTRACTED_FILENAME))
44
+ AssertEntry.assert_contents(EXTRACTED_FILENAME,
45
+ zf.get_input_stream(ENTRY_TO_EXTRACT) { |is| is.read })
49
46
 
50
- entry = zf.get_entry(ENTRY_TO_EXTRACT)
51
- entry.extract(EXTRACTED_FILENAME)
47
+ File.unlink(EXTRACTED_FILENAME)
52
48
 
53
- assert(File.exist?(EXTRACTED_FILENAME))
54
- AssertEntry::assert_contents(EXTRACTED_FILENAME,
55
- entry.get_input_stream() { |is| is.read })
49
+ entry = zf.get_entry(ENTRY_TO_EXTRACT)
50
+ entry.extract(EXTRACTED_FILENAME)
56
51
 
57
- end
52
+ assert(File.exist?(EXTRACTED_FILENAME))
53
+ AssertEntry.assert_contents(EXTRACTED_FILENAME,
54
+ entry.get_input_stream { |is| is.read })
58
55
  end
59
56
  end
60
57
  end
@@ -1,6 +1,5 @@
1
1
  require 'test_helper'
2
2
 
3
-
4
3
  class ZipFileTest < MiniTest::Test
5
4
  include CommonZipFileFixture
6
5
 
@@ -11,12 +10,12 @@ class ZipFileTest < MiniTest::Test
11
10
  ::Zip.write_zip64_support = false
12
11
  end
13
12
 
14
- def test_createFromScratchToBuffer
15
- comment = "a short comment"
13
+ def test_create_from_scratch_to_buffer
14
+ comment = 'a short comment'
16
15
 
17
16
  buffer = ::Zip::File.add_buffer do |zf|
18
- zf.get_output_stream("myFile") { |os| os.write "myFile contains just this" }
19
- zf.mkdir("dir1")
17
+ zf.get_output_stream('myFile') { |os| os.write 'myFile contains just this' }
18
+ zf.mkdir('dir1')
20
19
  zf.comment = comment
21
20
  end
22
21
 
@@ -27,12 +26,12 @@ class ZipFileTest < MiniTest::Test
27
26
  assert_equal(2, zfRead.entries.length)
28
27
  end
29
28
 
30
- def test_createFromScratch
31
- comment = "a short comment"
29
+ def test_create_from_scratch
30
+ comment = 'a short comment'
32
31
 
33
32
  zf = ::Zip::File.new(EMPTY_FILENAME, ::Zip::File::CREATE)
34
- zf.get_output_stream("myFile") { |os| os.write "myFile contains just this" }
35
- zf.mkdir("dir1")
33
+ zf.get_output_stream('myFile') { |os| os.write 'myFile contains just this' }
34
+ zf.mkdir('dir1')
36
35
  zf.comment = comment
37
36
  zf.close
38
37
 
@@ -43,29 +42,25 @@ class ZipFileTest < MiniTest::Test
43
42
 
44
43
  def test_get_output_stream
45
44
  entryCount = nil
46
- ::Zip::File.open(TEST_ZIP.zip_name) {
47
- |zf|
45
+ ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
48
46
  entryCount = zf.size
49
- zf.get_output_stream('newEntry.txt') {
50
- |os|
51
- os.write "Putting stuff in newEntry.txt"
52
- }
53
- assert_equal(entryCount+1, zf.size)
54
- assert_equal("Putting stuff in newEntry.txt", zf.read("newEntry.txt"))
55
-
56
- zf.get_output_stream(zf.get_entry('test/data/generated/empty.txt')) {
57
- |os|
58
- os.write "Putting stuff in data/generated/empty.txt"
59
- }
60
- assert_equal(entryCount+1, zf.size)
61
- assert_equal("Putting stuff in data/generated/empty.txt", zf.read("test/data/generated/empty.txt"))
47
+ zf.get_output_stream('newEntry.txt') do |os|
48
+ os.write 'Putting stuff in newEntry.txt'
49
+ end
50
+ assert_equal(entryCount + 1, zf.size)
51
+ assert_equal('Putting stuff in newEntry.txt', zf.read('newEntry.txt'))
52
+
53
+ zf.get_output_stream(zf.get_entry('test/data/generated/empty.txt')) do |os|
54
+ os.write 'Putting stuff in data/generated/empty.txt'
55
+ end
56
+ assert_equal(entryCount + 1, zf.size)
57
+ assert_equal('Putting stuff in data/generated/empty.txt', zf.read('test/data/generated/empty.txt'))
62
58
 
63
59
  custom_entry_args = [ZipEntryTest::TEST_COMMENT, ZipEntryTest::TEST_EXTRA, ZipEntryTest::TEST_COMPRESSED_SIZE, ZipEntryTest::TEST_CRC, ::Zip::Entry::STORED, ZipEntryTest::TEST_SIZE, ZipEntryTest::TEST_TIME]
64
- zf.get_output_stream('entry_with_custom_args.txt', nil, *custom_entry_args) {
65
- |os|
66
- os.write "Some data"
67
- }
68
- assert_equal(entryCount+2, zf.size)
60
+ zf.get_output_stream('entry_with_custom_args.txt', nil, *custom_entry_args) do |os|
61
+ os.write 'Some data'
62
+ end
63
+ assert_equal(entryCount + 2, zf.size)
69
64
  entry = zf.get_entry('entry_with_custom_args.txt')
70
65
  assert_equal(custom_entry_args[0], entry.comment)
71
66
  assert_equal(custom_entry_args[2], entry.compressed_size)
@@ -74,26 +69,31 @@ class ZipFileTest < MiniTest::Test
74
69
  assert_equal(custom_entry_args[5], entry.size)
75
70
  assert_equal(custom_entry_args[6], entry.time)
76
71
 
77
- zf.get_output_stream('entry.bin') {
78
- |os|
72
+ zf.get_output_stream('entry.bin') do |os|
79
73
  os.write(::File.open('test/data/generated/5entry.zip', 'rb').read)
80
- }
81
- }
74
+ end
75
+ end
82
76
 
83
- ::Zip::File.open(TEST_ZIP.zip_name) {
84
- |zf|
85
- assert_equal(entryCount+3, zf.size)
86
- assert_equal("Putting stuff in newEntry.txt", zf.read("newEntry.txt"))
87
- assert_equal("Putting stuff in data/generated/empty.txt", zf.read("test/data/generated/empty.txt"))
88
- assert_equal(File.open('test/data/generated/5entry.zip', 'rb').read, zf.read("entry.bin"))
89
- }
77
+ ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
78
+ assert_equal(entryCount + 3, zf.size)
79
+ assert_equal('Putting stuff in newEntry.txt', zf.read('newEntry.txt'))
80
+ assert_equal('Putting stuff in data/generated/empty.txt', zf.read('test/data/generated/empty.txt'))
81
+ assert_equal(File.open('test/data/generated/5entry.zip', 'rb').read, zf.read('entry.bin'))
82
+ end
83
+ end
84
+
85
+ def test_open_buffer_with_stringio
86
+ string_io = StringIO.new File.read('test/data/rubycode.zip')
87
+ ::Zip::File.open_buffer string_io do |zf|
88
+ assert zf.entries.map { |e| e.name }.include?('zippedruby1.rb')
89
+ end
90
90
  end
91
91
 
92
92
  def test_cleans_up_tempfiles_after_close
93
93
  zf = ::Zip::File.new(EMPTY_FILENAME, ::Zip::File::CREATE)
94
- zf.get_output_stream("myFile") do |os|
94
+ zf.get_output_stream('myFile') do |os|
95
95
  @tempfile_path = os.path
96
- os.write "myFile contains just this"
96
+ os.write 'myFile contains just this'
97
97
  end
98
98
 
99
99
  assert_equal(true, File.exist?(@tempfile_path))
@@ -104,15 +104,15 @@ class ZipFileTest < MiniTest::Test
104
104
  end
105
105
 
106
106
  def test_add
107
- srcFile = "test/data/file2.txt"
108
- entryName = "newEntryName.rb"
107
+ srcFile = 'test/data/file2.txt'
108
+ entryName = 'newEntryName.rb'
109
109
  assert(::File.exist?(srcFile))
110
110
  zf = ::Zip::File.new(EMPTY_FILENAME, ::Zip::File::CREATE)
111
111
  zf.add(entryName, srcFile)
112
112
  zf.close
113
113
 
114
114
  zfRead = ::Zip::File.new(EMPTY_FILENAME)
115
- assert_equal("", zfRead.comment)
115
+ assert_equal('', zfRead.comment)
116
116
  assert_equal(1, zfRead.entries.length)
117
117
  assert_equal(entryName, zfRead.entries.first.name)
118
118
  AssertEntry.assert_contents(srcFile,
@@ -122,8 +122,8 @@ class ZipFileTest < MiniTest::Test
122
122
  def test_recover_permissions_after_add_files_to_archive
123
123
  srcZip = TEST_ZIP.zip_name
124
124
  ::File.chmod(0664, srcZip)
125
- srcFile = "test/data/file2.txt"
126
- entryName = "newEntryName.rb"
125
+ srcFile = 'test/data/file2.txt'
126
+ entryName = 'newEntryName.rb'
127
127
  assert_equal(::File.stat(srcZip).mode, 0100664)
128
128
  assert(::File.exist?(srcZip))
129
129
  zf = ::Zip::File.new(srcZip, ::Zip::File::CREATE)
@@ -132,40 +132,35 @@ class ZipFileTest < MiniTest::Test
132
132
  assert_equal(::File.stat(srcZip).mode, 0100664)
133
133
  end
134
134
 
135
- def test_addExistingEntryName
136
- assert_raises(::Zip::EntryExistsError) {
137
- ::Zip::File.open(TEST_ZIP.zip_name) {
138
- |zf|
139
- zf.add(zf.entries.first.name, "test/data/file2.txt")
140
- }
141
- }
135
+ def test_add_existing_entry_name
136
+ assert_raises(::Zip::EntryExistsError) do
137
+ ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
138
+ zf.add(zf.entries.first.name, 'test/data/file2.txt')
139
+ end
140
+ end
142
141
  end
143
142
 
144
- def test_addExistingEntryNameReplace
143
+ def test_add_existing_entry_name_replace
145
144
  gotCalled = false
146
145
  replacedEntry = nil
147
- ::Zip::File.open(TEST_ZIP.zip_name) {
148
- |zf|
146
+ ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
149
147
  replacedEntry = zf.entries.first.name
150
- zf.add(replacedEntry, "test/data/file2.txt") { gotCalled = true; true }
151
- }
148
+ zf.add(replacedEntry, 'test/data/file2.txt') { gotCalled = true; true }
149
+ end
152
150
  assert(gotCalled)
153
- ::Zip::File.open(TEST_ZIP.zip_name) {
154
- |zf|
155
- assert_contains(zf, replacedEntry, "test/data/file2.txt")
156
- }
151
+ ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
152
+ assert_contains(zf, replacedEntry, 'test/data/file2.txt')
153
+ end
157
154
  end
158
155
 
159
- def test_addDirectory
160
- ::Zip::File.open(TEST_ZIP.zip_name) {
161
- |zf|
156
+ def test_add_directory
157
+ ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
162
158
  zf.add(TestFiles::EMPTY_TEST_DIR, TestFiles::EMPTY_TEST_DIR)
163
- }
164
- ::Zip::File.open(TEST_ZIP.zip_name) {
165
- |zf|
166
- dirEntry = zf.entries.detect { |e| e.name == TestFiles::EMPTY_TEST_DIR+"/" }
159
+ end
160
+ ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
161
+ dirEntry = zf.entries.detect { |e| e.name == TestFiles::EMPTY_TEST_DIR + '/' }
167
162
  assert(dirEntry.directory?)
168
- }
163
+ end
169
164
  end
170
165
 
171
166
  def test_remove
@@ -193,7 +188,7 @@ class ZipFileTest < MiniTest::Test
193
188
  assert(zf.entries.map { |e| e.name }.include?(entryToRename))
194
189
 
195
190
  contents = zf.read(entryToRename)
196
- newName = "changed entry name"
191
+ newName = 'changed entry name'
197
192
  assert(!zf.entries.map { |e| e.name }.include?(newName))
198
193
 
199
194
  zf.rename(entryToRename, newName)
@@ -211,9 +206,7 @@ class ZipFileTest < MiniTest::Test
211
206
 
212
207
  def test_rename_with_each
213
208
  zf_name = 'test_rename_zip.zip'
214
- if ::File.exist?(zf_name)
215
- ::File.unlink(zf_name)
216
- end
209
+ ::File.unlink(zf_name) if ::File.exist?(zf_name)
217
210
  arr = []
218
211
  arr_renamed = []
219
212
  ::Zip::File.open(zf_name, ::Zip::File::CREATE) do |zf|
@@ -229,7 +222,7 @@ class ZipFileTest < MiniTest::Test
229
222
  zf = ::Zip::File.open(zf_name)
230
223
  assert_equal(zf.entries.map(&:name), arr)
231
224
  zf.close
232
- Zip::File.open(zf_name, "wb") do |z|
225
+ Zip::File.open(zf_name, 'wb') do |z|
233
226
  z.each do |f|
234
227
  z.rename(f, "Z#{f.name}")
235
228
  end
@@ -237,12 +230,10 @@ class ZipFileTest < MiniTest::Test
237
230
  zf = ::Zip::File.open(zf_name)
238
231
  assert_equal(zf.entries.map(&:name), arr_renamed)
239
232
  zf.close
240
- if ::File.exist?(zf_name)
241
- ::File.unlink(zf_name)
242
- end
233
+ ::File.unlink(zf_name) if ::File.exist?(zf_name)
243
234
  end
244
235
 
245
- def test_renameToExistingEntry
236
+ def test_rename_to_existing_entry
246
237
  oldEntries = nil
247
238
  ::Zip::File.open(TEST_ZIP.zip_name) { |zf| oldEntries = zf.entries }
248
239
 
@@ -257,7 +248,7 @@ class ZipFileTest < MiniTest::Test
257
248
  end
258
249
  end
259
250
 
260
- def test_renameToExistingEntryOverwrite
251
+ def test_rename_to_existing_entry_overwrite
261
252
  oldEntries = nil
262
253
  ::Zip::File.open(TEST_ZIP.zip_name) { |zf| oldEntries = zf.entries }
263
254
 
@@ -276,61 +267,54 @@ class ZipFileTest < MiniTest::Test
276
267
  end
277
268
  end
278
269
 
279
- def test_renameNonEntry
280
- nonEntry = "bogusEntry"
281
- target_entry = "target_entryName"
270
+ def test_rename_non_entry
271
+ nonEntry = 'bogusEntry'
272
+ target_entry = 'target_entryName'
282
273
  zf = ::Zip::File.new(TEST_ZIP.zip_name)
283
274
  assert(!zf.entries.include?(nonEntry))
284
- assert_raises(Errno::ENOENT) {
285
- zf.rename(nonEntry, target_entry)
286
- }
275
+ assert_raises(Errno::ENOENT) { zf.rename(nonEntry, target_entry) }
287
276
  zf.commit
288
277
  assert(!zf.entries.include?(target_entry))
289
278
  ensure
290
279
  zf.close
291
280
  end
292
281
 
293
- def test_renameEntryToExistingEntry
282
+ def test_rename_entry_to_existing_entry
294
283
  entry1, entry2, * = TEST_ZIP.entry_names
295
284
  zf = ::Zip::File.new(TEST_ZIP.zip_name)
296
- assert_raises(::Zip::EntryExistsError) {
297
- zf.rename(entry1, entry2)
298
- }
285
+ assert_raises(::Zip::EntryExistsError) { zf.rename(entry1, entry2) }
299
286
  ensure
300
287
  zf.close
301
288
  end
302
289
 
303
290
  def test_replace
304
291
  entryToReplace = TEST_ZIP.entry_names[2]
305
- newEntrySrcFilename = "test/data/file2.txt"
292
+ newEntrySrcFilename = 'test/data/file2.txt'
306
293
  zf = ::Zip::File.new(TEST_ZIP.zip_name)
307
294
  zf.replace(entryToReplace, newEntrySrcFilename)
308
295
 
309
296
  zf.close
310
297
  zfRead = ::Zip::File.new(TEST_ZIP.zip_name)
311
- AssertEntry::assert_contents(newEntrySrcFilename,
312
- zfRead.get_input_stream(entryToReplace) { |is| is.read })
313
- AssertEntry::assert_contents(TEST_ZIP.entry_names[0],
314
- zfRead.get_input_stream(TEST_ZIP.entry_names[0]) { |is| is.read })
315
- AssertEntry::assert_contents(TEST_ZIP.entry_names[1],
316
- zfRead.get_input_stream(TEST_ZIP.entry_names[1]) { |is| is.read })
317
- AssertEntry::assert_contents(TEST_ZIP.entry_names[3],
318
- zfRead.get_input_stream(TEST_ZIP.entry_names[3]) { |is| is.read })
298
+ AssertEntry.assert_contents(newEntrySrcFilename,
299
+ zfRead.get_input_stream(entryToReplace) { |is| is.read })
300
+ AssertEntry.assert_contents(TEST_ZIP.entry_names[0],
301
+ zfRead.get_input_stream(TEST_ZIP.entry_names[0]) { |is| is.read })
302
+ AssertEntry.assert_contents(TEST_ZIP.entry_names[1],
303
+ zfRead.get_input_stream(TEST_ZIP.entry_names[1]) { |is| is.read })
304
+ AssertEntry.assert_contents(TEST_ZIP.entry_names[3],
305
+ zfRead.get_input_stream(TEST_ZIP.entry_names[3]) { |is| is.read })
319
306
  zfRead.close
320
307
  end
321
308
 
322
- def test_replaceNonEntry
323
- entryToReplace = "nonExistingEntryname"
324
- ::Zip::File.open(TEST_ZIP.zip_name) {
325
- |zf|
326
- assert_raises(Errno::ENOENT) {
327
- zf.replace(entryToReplace, "test/data/file2.txt")
328
- }
329
- }
309
+ def test_replace_non_entry
310
+ entryToReplace = 'nonExistingEntryname'
311
+ ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
312
+ assert_raises(Errno::ENOENT) { zf.replace(entryToReplace, 'test/data/file2.txt') }
313
+ end
330
314
  end
331
315
 
332
316
  def test_commit
333
- newName = "renamedFirst"
317
+ newName = 'renamedFirst'
334
318
  zf = ::Zip::File.new(TEST_ZIP.zip_name)
335
319
  oldName = zf.entries.first
336
320
  zf.rename(oldName, newName)
@@ -338,7 +322,7 @@ class ZipFileTest < MiniTest::Test
338
322
 
339
323
  zfRead = ::Zip::File.new(TEST_ZIP.zip_name)
340
324
  assert(zfRead.entries.detect { |e| e.name == newName } != nil)
341
- assert(zfRead.entries.detect { |e| e.name == oldName } == nil)
325
+ assert(zfRead.entries.detect { |e| e.name == oldName }.nil?)
342
326
  zfRead.close
343
327
 
344
328
  zf.close
@@ -356,8 +340,8 @@ class ZipFileTest < MiniTest::Test
356
340
  zf.commit
357
341
  zf.close
358
342
  zf2 = ::Zip::File.open(filename)
359
- assert(zf2.entries.detect {|e| e.name == 'test1.txt'} != nil )
360
- assert(zf2.entries.detect {|e| e.name == 'test2.txt'} != nil )
343
+ assert(zf2.entries.detect { |e| e.name == 'test1.txt' } != nil)
344
+ assert(zf2.entries.detect { |e| e.name == 'test2.txt' } != nil)
361
345
  res = system("unzip -t #{filename}")
362
346
  assert_equal(res, true)
363
347
  end
@@ -368,7 +352,7 @@ class ZipFileTest < MiniTest::Test
368
352
  end
369
353
 
370
354
  def test_write_buffer
371
- newName = "renamedFirst"
355
+ newName = 'renamedFirst'
372
356
  zf = ::Zip::File.new(TEST_ZIP.zip_name)
373
357
  oldName = zf.entries.first
374
358
  zf.rename(oldName, newName)
@@ -377,7 +361,7 @@ class ZipFileTest < MiniTest::Test
377
361
  File.open(TEST_ZIP.zip_name, 'wb') { |f| f.write buffer.string }
378
362
  zfRead = ::Zip::File.new(TEST_ZIP.zip_name)
379
363
  assert(zfRead.entries.detect { |e| e.name == newName } != nil)
380
- assert(zfRead.entries.detect { |e| e.name == oldName } == nil)
364
+ assert(zfRead.entries.detect { |e| e.name == oldName }.nil?)
381
365
  zfRead.close
382
366
 
383
367
  zf.close
@@ -386,27 +370,26 @@ class ZipFileTest < MiniTest::Test
386
370
  # This test tests that after commit, you
387
371
  # can delete the file you used to add the entry to the zip file
388
372
  # with
389
- def test_commitUseZipEntry
373
+ def test_commit_use_zip_entry
390
374
  FileUtils.cp(TestFiles::RANDOM_ASCII_FILE1, OK_DELETE_FILE)
391
375
  zf = ::Zip::File.open(TEST_ZIP.zip_name)
392
- zf.add("okToDelete.txt", OK_DELETE_FILE)
393
- assert_contains(zf, "okToDelete.txt")
376
+ zf.add('okToDelete.txt', OK_DELETE_FILE)
377
+ assert_contains(zf, 'okToDelete.txt')
394
378
  zf.commit
395
379
  File.rename(OK_DELETE_FILE, OK_DELETE_MOVED_FILE)
396
- assert_contains(zf, "okToDelete.txt", OK_DELETE_MOVED_FILE)
380
+ assert_contains(zf, 'okToDelete.txt', OK_DELETE_MOVED_FILE)
397
381
  end
398
382
 
399
- # def test_close
400
- # zf = ZipFile.new(TEST_ZIP.zip_name)
401
- # zf.close
402
- # assert_raises(IOError) {
403
- # zf.extract(TEST_ZIP.entry_names.first, "hullubullu")
404
- # }
405
- # end
383
+ # def test_close
384
+ # zf = ZipFile.new(TEST_ZIP.zip_name)
385
+ # zf.close
386
+ # assert_raises(IOError) {
387
+ # zf.extract(TEST_ZIP.entry_names.first, "hullubullu")
388
+ # }
389
+ # end
406
390
 
407
391
  def test_compound1
408
- renamedName = "renamedName"
409
- originalEntries = []
392
+ renamedName = 'renamedName'
410
393
  filename_to_remove = ''
411
394
  begin
412
395
  zf = ::Zip::File.new(TEST_ZIP.zip_name)
@@ -421,11 +404,10 @@ class ZipFileTest < MiniTest::Test
421
404
  zf.rename(entry_to_rename, renamedName)
422
405
  assert_contains(zf, renamedName)
423
406
 
424
- TestFiles::BINARY_TEST_FILES.each {
425
- |filename|
407
+ TestFiles::BINARY_TEST_FILES.each do |filename|
426
408
  zf.add(filename, filename)
427
409
  assert_contains(zf, filename)
428
- }
410
+ end
429
411
 
430
412
  assert_contains(zf, originalEntries.last.to_s)
431
413
  filename_to_remove = originalEntries.map(&:to_s).find { |name| name.match('longBinary') }
@@ -439,10 +421,9 @@ class ZipFileTest < MiniTest::Test
439
421
  zfRead = ::Zip::File.new(TEST_ZIP.zip_name)
440
422
  assert_contains(zfRead, TestFiles::RANDOM_ASCII_FILE1)
441
423
  assert_contains(zfRead, renamedName)
442
- TestFiles::BINARY_TEST_FILES.each {
443
- |filename|
424
+ TestFiles::BINARY_TEST_FILES.each do |filename|
444
425
  assert_contains(zfRead, filename)
445
- }
426
+ end
446
427
  assert_not_contains(zfRead, filename_to_remove)
447
428
  ensure
448
429
  zfRead.close
@@ -454,23 +435,21 @@ class ZipFileTest < MiniTest::Test
454
435
  zf = ::Zip::File.new(TEST_ZIP.zip_name)
455
436
  originalEntries = zf.entries.dup
456
437
 
457
- originalEntries.each {
458
- |entry|
438
+ originalEntries.each do |entry|
459
439
  zf.remove(entry)
460
440
  assert_not_contains(zf, entry)
461
- }
441
+ end
462
442
  assert(zf.entries.empty?)
463
443
 
464
- TestFiles::ASCII_TEST_FILES.each {
465
- |filename|
444
+ TestFiles::ASCII_TEST_FILES.each do |filename|
466
445
  zf.add(filename, filename)
467
446
  assert_contains(zf, filename)
468
- }
447
+ end
469
448
  assert_equal(zf.entries.sort.map { |e| e.name }, TestFiles::ASCII_TEST_FILES)
470
449
 
471
- zf.rename(TestFiles::ASCII_TEST_FILES[0], "newName")
450
+ zf.rename(TestFiles::ASCII_TEST_FILES[0], 'newName')
472
451
  assert_not_contains(zf, TestFiles::ASCII_TEST_FILES[0])
473
- assert_contains(zf, "newName")
452
+ assert_contains(zf, 'newName')
474
453
  ensure
475
454
  zf.close
476
455
  end
@@ -478,56 +457,51 @@ class ZipFileTest < MiniTest::Test
478
457
  zfRead = ::Zip::File.new(TEST_ZIP.zip_name)
479
458
  asciiTestFiles = TestFiles::ASCII_TEST_FILES.dup
480
459
  asciiTestFiles.shift
481
- asciiTestFiles.each {
482
- |filename|
460
+ asciiTestFiles.each do |filename|
483
461
  assert_contains(zf, filename)
484
- }
462
+ end
485
463
 
486
- assert_contains(zf, "newName")
464
+ assert_contains(zf, 'newName')
487
465
  ensure
488
466
  zfRead.close
489
467
  end
490
468
  end
491
469
 
492
- def test_changeComment
470
+ def test_change_comment
493
471
  ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
494
- zf.comment = "my changed comment"
472
+ zf.comment = 'my changed comment'
495
473
  end
496
474
  zfRead = ::Zip::File.open(TEST_ZIP.zip_name)
497
- assert_equal("my changed comment", zfRead.comment)
475
+ assert_equal('my changed comment', zfRead.comment)
498
476
  end
499
477
 
500
478
  def test_preserve_file_order
501
479
  entryNames = nil
502
- ::Zip::File.open(TEST_ZIP.zip_name) {
503
- |zf|
480
+ ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
504
481
  entryNames = zf.entries.map { |e| e.to_s }
505
- zf.get_output_stream("a.txt") { |os| os.write "this is a.txt" }
506
- zf.get_output_stream("z.txt") { |os| os.write "this is z.txt" }
507
- zf.get_output_stream("k.txt") { |os| os.write "this is k.txt" }
508
- entryNames << "a.txt" << "z.txt" << "k.txt"
509
- }
510
-
511
- ::Zip::File.open(TEST_ZIP.zip_name) {
512
- |zf|
482
+ zf.get_output_stream('a.txt') { |os| os.write 'this is a.txt' }
483
+ zf.get_output_stream('z.txt') { |os| os.write 'this is z.txt' }
484
+ zf.get_output_stream('k.txt') { |os| os.write 'this is k.txt' }
485
+ entryNames << 'a.txt' << 'z.txt' << 'k.txt'
486
+ end
487
+
488
+ ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
513
489
  assert_equal(entryNames, zf.entries.map { |e| e.to_s })
514
490
  entries = zf.entries.sort_by { |e| e.name }.reverse
515
- entries.each {
516
- |e|
491
+ entries.each do |e|
517
492
  zf.remove e
518
- zf.get_output_stream(e) { |os| os.write "foo" }
519
- }
493
+ zf.get_output_stream(e) { |os| os.write 'foo' }
494
+ end
520
495
  entryNames = entries.map { |e| e.to_s }
521
- }
522
- ::Zip::File.open(TEST_ZIP.zip_name) {
523
- |zf|
496
+ end
497
+ ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
524
498
  assert_equal(entryNames, zf.entries.map { |e| e.to_s })
525
- }
499
+ end
526
500
  end
527
501
 
528
502
  def test_streaming
529
- fname = ::File.join(::File.expand_path(::File.dirname(__FILE__)), "../README.md")
530
- zname = "test/data/generated/README.zip"
503
+ fname = ::File.join(::File.expand_path(::File.dirname(__FILE__)), '../README.md')
504
+ zname = 'test/data/generated/README.zip'
531
505
  Zip::File.open(zname, Zip::File::CREATE) do |zipfile|
532
506
  zipfile.get_output_stream(File.basename(fname)) do |f|
533
507
  f.puts File.read(fname)
@@ -547,13 +521,43 @@ class ZipFileTest < MiniTest::Test
547
521
  assert data =~ /Simonov/
548
522
  end
549
523
 
524
+ def test_nonexistant_zip
525
+ assert_raises(::Zip::Error) do
526
+ ::Zip::File.open('fake.zip')
527
+ end
528
+ end
529
+
530
+ def test_empty_zip
531
+ puts `touch empty.zip`
532
+ assert_raises(::Zip::Error) do
533
+ ::Zip::File.open('empty.zip')
534
+ end
535
+ end
536
+
537
+ def test_odd_extra_field
538
+ entry_count = 0
539
+ File.open 'test/data/oddExtraField.zip', 'rb' do |zip_io|
540
+ Zip::File.open_buffer zip_io.read do |zip|
541
+ zip.each do |zip_entry|
542
+ entry_count += 1
543
+ end
544
+ end
545
+ end
546
+ assert_equal 13, entry_count
547
+ end
548
+
549
+ def test_open_xls_does_not_raise_type_error
550
+ ::Zip::File.open('test/data/test.xls')
551
+ end
552
+
550
553
  private
554
+
551
555
  def assert_contains(zf, entryName, filename = entryName)
552
556
  assert(zf.entries.detect { |e| e.name == entryName } != nil, "entry #{entryName} not in #{zf.entries.join(', ')} in zip file #{zf}")
553
- assert_entryContents(zf, entryName, filename) if File.exist?(filename)
557
+ assert_entry_contents(zf, entryName, filename) if File.exist?(filename)
554
558
  end
555
559
 
556
560
  def assert_not_contains(zf, entryName)
557
- assert(zf.entries.detect { |e| e.name == entryName } == nil, "entry #{entryName} in #{zf.entries.join(', ')} in zip file #{zf}")
561
+ assert(zf.entries.detect { |e| e.name == entryName }.nil?, "entry #{entryName} in #{zf.entries.join(', ')} in zip file #{zf}")
558
562
  end
559
563
  end