rubyzip 1.1.7 → 1.2.4

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 (106) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +87 -45
  3. data/Rakefile +3 -4
  4. data/lib/zip.rb +11 -5
  5. data/lib/zip/central_directory.rb +8 -8
  6. data/lib/zip/compressor.rb +1 -2
  7. data/lib/zip/constants.rb +5 -5
  8. data/lib/zip/crypto/null_encryption.rb +4 -6
  9. data/lib/zip/crypto/traditional_encryption.rb +5 -5
  10. data/lib/zip/decompressor.rb +3 -3
  11. data/lib/zip/deflater.rb +8 -6
  12. data/lib/zip/dos_time.rb +5 -6
  13. data/lib/zip/entry.rb +120 -128
  14. data/lib/zip/entry_set.rb +14 -14
  15. data/lib/zip/errors.rb +1 -0
  16. data/lib/zip/extra_field.rb +8 -8
  17. data/lib/zip/extra_field/generic.rb +8 -8
  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 -2
  24. data/lib/zip/file.rb +81 -81
  25. data/lib/zip/filesystem.rb +144 -143
  26. data/lib/zip/inflater.rb +5 -5
  27. data/lib/zip/input_stream.rb +22 -13
  28. data/lib/zip/ioextras.rb +1 -3
  29. data/lib/zip/ioextras/abstract_input_stream.rb +6 -10
  30. data/lib/zip/ioextras/abstract_output_stream.rb +3 -5
  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 +13 -14
  35. data/lib/zip/pass_thru_compressor.rb +4 -4
  36. data/lib/zip/pass_thru_decompressor.rb +3 -4
  37. data/lib/zip/streamable_directory.rb +2 -2
  38. data/lib/zip/streamable_stream.rb +3 -3
  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 +31 -25
  43. data/samples/{gtkRubyzip.rb → gtk_ruby_zip.rb} +23 -25
  44. data/samples/qtzip.rb +18 -27
  45. data/samples/write_simple.rb +12 -13
  46. data/samples/zipfind.rb +26 -34
  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 +32 -36
  50. data/test/central_directory_test.rb +46 -50
  51. data/test/crypto/null_encryption_test.rb +8 -4
  52. data/test/crypto/traditional_encryption_test.rb +5 -5
  53. data/test/data/gpbit3stored.zip +0 -0
  54. data/test/data/notzippedruby.rb +1 -1
  55. data/test/data/oddExtraField.zip +0 -0
  56. data/test/data/path_traversal/Makefile +10 -0
  57. data/test/data/path_traversal/jwilk/README.md +5 -0
  58. data/test/data/path_traversal/jwilk/absolute1.zip +0 -0
  59. data/test/data/path_traversal/jwilk/absolute2.zip +0 -0
  60. data/test/data/path_traversal/jwilk/dirsymlink.zip +0 -0
  61. data/test/data/path_traversal/jwilk/dirsymlink2a.zip +0 -0
  62. data/test/data/path_traversal/jwilk/dirsymlink2b.zip +0 -0
  63. data/test/data/path_traversal/jwilk/relative0.zip +0 -0
  64. data/test/data/path_traversal/jwilk/relative2.zip +0 -0
  65. data/test/data/path_traversal/jwilk/symlink.zip +0 -0
  66. data/test/data/path_traversal/relative1.zip +0 -0
  67. data/test/data/path_traversal/tilde.zip +0 -0
  68. data/test/data/path_traversal/tuzovakaoff/README.md +3 -0
  69. data/test/data/path_traversal/tuzovakaoff/absolutepath.zip +0 -0
  70. data/test/data/path_traversal/tuzovakaoff/symlink.zip +0 -0
  71. data/test/data/rubycode.zip +0 -0
  72. data/test/data/test.xls +0 -0
  73. data/test/deflater_test.rb +10 -12
  74. data/test/encryption_test.rb +2 -2
  75. data/test/entry_set_test.rb +50 -25
  76. data/test/entry_test.rb +76 -87
  77. data/test/errors_test.rb +1 -2
  78. data/test/extra_field_test.rb +19 -21
  79. data/test/file_extract_directory_test.rb +12 -14
  80. data/test/file_extract_test.rb +33 -40
  81. data/test/file_permissions_test.rb +65 -0
  82. data/test/file_split_test.rb +24 -27
  83. data/test/file_test.rb +266 -179
  84. data/test/filesystem/dir_iterator_test.rb +13 -17
  85. data/test/filesystem/directory_test.rb +101 -93
  86. data/test/filesystem/file_mutating_test.rb +52 -65
  87. data/test/filesystem/file_nonmutating_test.rb +223 -229
  88. data/test/filesystem/file_stat_test.rb +17 -19
  89. data/test/gentestfiles.rb +54 -62
  90. data/test/inflater_test.rb +1 -1
  91. data/test/input_stream_test.rb +52 -40
  92. data/test/ioextras/abstract_input_stream_test.rb +22 -23
  93. data/test/ioextras/abstract_output_stream_test.rb +33 -33
  94. data/test/ioextras/fake_io_test.rb +1 -1
  95. data/test/local_entry_test.rb +36 -38
  96. data/test/output_stream_test.rb +20 -21
  97. data/test/pass_thru_compressor_test.rb +5 -6
  98. data/test/pass_thru_decompressor_test.rb +0 -1
  99. data/test/path_traversal_test.rb +141 -0
  100. data/test/samples/example_recursive_test.rb +37 -0
  101. data/test/settings_test.rb +18 -15
  102. data/test/test_helper.rb +52 -46
  103. data/test/unicode_file_names_and_comments_test.rb +17 -7
  104. data/test/zip64_full_test.rb +10 -12
  105. data/test/zip64_support_test.rb +0 -1
  106. metadata +94 -65
@@ -4,15 +4,14 @@ class PassThruCompressorTest < MiniTest::Test
4
4
  include CrcTest
5
5
 
6
6
  def test_size
7
- File.open("test/data/generated/dummy.txt", "wb") {
8
- |file|
7
+ File.open('test/data/generated/dummy.txt', 'wb') do |file|
9
8
  compressor = ::Zip::PassThruCompressor.new(file)
10
9
 
11
10
  assert_equal(0, compressor.size)
12
11
 
13
- t1 = "hello world"
14
- t2 = ""
15
- t3 = "bingo"
12
+ t1 = 'hello world'
13
+ t2 = ''
14
+ t3 = 'bingo'
16
15
 
17
16
  compressor << t1
18
17
  assert_equal(compressor.size, t1.size)
@@ -22,7 +21,7 @@ class PassThruCompressorTest < MiniTest::Test
22
21
 
23
22
  compressor << t3
24
23
  assert_equal(compressor.size, t1.size + t2.size + t3.size)
25
- }
24
+ end
26
25
  end
27
26
 
28
27
  def test_crc
@@ -12,4 +12,3 @@ class PassThruDecompressorTest < MiniTest::Test
12
12
  @file.close
13
13
  end
14
14
  end
15
-
@@ -0,0 +1,141 @@
1
+ class PathTraversalTest < MiniTest::Test
2
+ TEST_FILE_ROOT = File.absolute_path('test/data/path_traversal')
3
+
4
+ def setup
5
+ # With apologies to anyone using these files... but they are the files in
6
+ # the sample zips, so we don't have much choice here.
7
+ FileUtils.rm_f '/tmp/moo'
8
+ FileUtils.rm_f '/tmp/file.txt'
9
+ end
10
+
11
+ def extract_path_traversal_zip(name)
12
+ Zip::File.open(File.join(TEST_FILE_ROOT, name)) do |zip_file|
13
+ zip_file.each do |entry|
14
+ entry.extract
15
+ end
16
+ end
17
+ end
18
+
19
+ def in_tmpdir
20
+ Dir.mktmpdir do |tmp|
21
+ test_path = File.join(tmp, 'test')
22
+ Dir.mkdir test_path
23
+ Dir.chdir test_path do
24
+ yield test_path
25
+ end
26
+ end
27
+ end
28
+
29
+ def test_leading_slash
30
+ in_tmpdir do
31
+ extract_path_traversal_zip 'jwilk/absolute1.zip'
32
+ refute File.exist?('/tmp/moo')
33
+ end
34
+ end
35
+
36
+ def test_multiple_leading_slashes
37
+ in_tmpdir do
38
+ extract_path_traversal_zip 'jwilk/absolute2.zip'
39
+ refute File.exist?('/tmp/moo')
40
+ end
41
+ end
42
+
43
+ def test_leading_dot_dot
44
+ in_tmpdir do
45
+ extract_path_traversal_zip 'jwilk/relative0.zip'
46
+ refute File.exist?('../moo')
47
+ end
48
+ end
49
+
50
+ def test_non_leading_dot_dot_with_existing_folder
51
+ in_tmpdir do
52
+ extract_path_traversal_zip 'relative1.zip'
53
+ assert Dir.exist?('tmp')
54
+ refute File.exist?('../moo')
55
+ end
56
+ end
57
+
58
+ def test_non_leading_dot_dot_without_existing_folder
59
+ in_tmpdir do
60
+ extract_path_traversal_zip 'jwilk/relative2.zip'
61
+ refute File.exist?('../moo')
62
+ end
63
+ end
64
+
65
+ def test_file_symlink
66
+ in_tmpdir do
67
+ extract_path_traversal_zip 'jwilk/symlink.zip'
68
+ assert File.exist?('moo')
69
+ refute File.exist?('/tmp/moo')
70
+ end
71
+ end
72
+
73
+ def test_directory_symlink
74
+ in_tmpdir do
75
+ # Can't create tmp/moo, because the tmp symlink is skipped.
76
+ assert_raises Errno::ENOENT do
77
+ extract_path_traversal_zip 'jwilk/dirsymlink.zip'
78
+ end
79
+ refute File.exist?('/tmp/moo')
80
+ end
81
+ end
82
+
83
+ def test_two_directory_symlinks_a
84
+ in_tmpdir do
85
+ # Can't create par/moo because the symlinks are skipped.
86
+ assert_raises Errno::ENOENT do
87
+ extract_path_traversal_zip 'jwilk/dirsymlink2a.zip'
88
+ end
89
+ refute File.exist?('cur')
90
+ refute File.exist?('par')
91
+ refute File.exist?('par/moo')
92
+ end
93
+ end
94
+
95
+ def test_two_directory_symlinks_b
96
+ in_tmpdir do
97
+ # Can't create par/moo, because the symlinks are skipped.
98
+ assert_raises Errno::ENOENT do
99
+ extract_path_traversal_zip 'jwilk/dirsymlink2b.zip'
100
+ end
101
+ refute File.exist?('cur')
102
+ refute File.exist?('../moo')
103
+ end
104
+ end
105
+
106
+ def test_entry_name_with_absolute_path_does_not_extract
107
+ in_tmpdir do
108
+ extract_path_traversal_zip 'tuzovakaoff/absolutepath.zip'
109
+ refute File.exist?('/tmp/file.txt')
110
+ end
111
+ end
112
+
113
+ def test_entry_name_with_absolute_path_extract_when_given_different_path
114
+ in_tmpdir do |test_path|
115
+ zip_path = File.join(TEST_FILE_ROOT, 'tuzovakaoff/absolutepath.zip')
116
+ Zip::File.open(zip_path) do |zip_file|
117
+ zip_file.each do |entry|
118
+ entry.extract(File.join(test_path, entry.name))
119
+ end
120
+ end
121
+ refute File.exist?('/tmp/file.txt')
122
+ end
123
+ end
124
+
125
+ def test_entry_name_with_relative_symlink
126
+ in_tmpdir do
127
+ # Doesn't create the symlink path, so can't create path/file.txt.
128
+ assert_raises Errno::ENOENT do
129
+ extract_path_traversal_zip 'tuzovakaoff/symlink.zip'
130
+ end
131
+ refute File.exist?('/tmp/file.txt')
132
+ end
133
+ end
134
+
135
+ def test_entry_name_with_tilde
136
+ in_tmpdir do
137
+ extract_path_traversal_zip 'tilde.zip'
138
+ assert File.exist?('~tilde~')
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+ require 'fileutils'
3
+ require_relative '../../samples/example_recursive'
4
+
5
+ class ExampleRecursiveTest < MiniTest::Test
6
+ DIRECTORY_TO_ZIP = 'test/data/globTest'
7
+ OUTPUT_DIRECTORY = 'test/data/example_recursive.zip'
8
+ TEMP_DIRECTORY = 'test/data/tmp'
9
+
10
+ def setup
11
+ @generator = ::ZipFileGenerator.new(DIRECTORY_TO_ZIP, OUTPUT_DIRECTORY)
12
+ end
13
+
14
+ def teardown
15
+ FileUtils.rm_rf TEMP_DIRECTORY
16
+ FileUtils.rm_f OUTPUT_DIRECTORY
17
+ end
18
+
19
+ def test_write
20
+ @generator.write
21
+ unzip
22
+ assert_equal Dir.entries(DIRECTORY_TO_ZIP).sort, Dir.entries(TEMP_DIRECTORY).sort
23
+ end
24
+
25
+ private
26
+
27
+ def unzip(file = OUTPUT_DIRECTORY)
28
+ Zip::File.open(file) do |zip_file|
29
+ zip_file.each do |f|
30
+ file_path = File.join(TEMP_DIRECTORY, f.name)
31
+ FileUtils.mkdir_p(File.dirname(file_path))
32
+
33
+ zip_file.extract(f, file_path) unless File.exist?(file_path)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,10 +1,10 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class ZipSettingsTest < MiniTest::Test
4
- # TODO Refactor out into common test module
4
+ # TODO: Refactor out into common test module
5
5
  include CommonZipFileFixture
6
6
 
7
- TEST_OUT_NAME = "test/data/generated/emptyOutDir"
7
+ TEST_OUT_NAME = 'test/data/generated/emptyOutDir'
8
8
 
9
9
  def setup
10
10
  super
@@ -18,27 +18,26 @@ class ZipSettingsTest < MiniTest::Test
18
18
  end
19
19
 
20
20
  def open_zip(&aProc)
21
- assert(aProc != nil)
21
+ assert(!aProc.nil?)
22
22
  ::Zip::File.open(TestZipFile::TEST_ZIP4.zip_name, &aProc)
23
23
  end
24
24
 
25
25
  def extract_test_dir(&aProc)
26
- open_zip {
27
- |zf|
26
+ open_zip do |zf|
28
27
  zf.extract(TestFiles::EMPTY_TEST_DIR, TEST_OUT_NAME, &aProc)
29
- }
28
+ end
30
29
  end
31
30
 
32
31
  def test_true_on_exists_proc
33
32
  Zip.on_exists_proc = true
34
- File.open(TEST_OUT_NAME, "w") { |f| f.puts "something" }
33
+ File.open(TEST_OUT_NAME, 'w') { |f| f.puts 'something' }
35
34
  extract_test_dir
36
35
  assert(File.directory?(TEST_OUT_NAME))
37
36
  end
38
37
 
39
38
  def test_false_on_exists_proc
40
39
  Zip.on_exists_proc = false
41
- File.open(TEST_OUT_NAME, "w") { |f| f.puts "something" }
40
+ File.open(TEST_OUT_NAME, 'w') { |f| f.puts 'something' }
42
41
  assert_raises(Zip::DestinationFileExistsError) { extract_test_dir }
43
42
  end
44
43
 
@@ -47,7 +46,7 @@ class ZipSettingsTest < MiniTest::Test
47
46
 
48
47
  assert_raises(::Zip::EntryExistsError) do
49
48
  ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
50
- zf.add(zf.entries.first.name, "test/data/file2.txt")
49
+ zf.add(zf.entries.first.name, 'test/data/file2.txt')
51
50
  end
52
51
  end
53
52
  end
@@ -59,11 +58,11 @@ class ZipSettingsTest < MiniTest::Test
59
58
 
60
59
  ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
61
60
  replacedEntry = zf.entries.first.name
62
- zf.add(replacedEntry, "test/data/file2.txt")
61
+ zf.add(replacedEntry, 'test/data/file2.txt')
63
62
  end
64
63
 
65
64
  ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
66
- assert_contains(zf, replacedEntry, "test/data/file2.txt")
65
+ assert_contains(zf, replacedEntry, 'test/data/file2.txt')
67
66
  end
68
67
  end
69
68
 
@@ -71,7 +70,9 @@ class ZipSettingsTest < MiniTest::Test
71
70
  test_file = File.join(File.dirname(__FILE__), 'data', 'WarnInvalidDate.zip')
72
71
  Zip.warn_invalid_date = false
73
72
 
74
- ::Zip::File.open(test_file) do |zf|
73
+ assert_output('', '') do
74
+ ::Zip::File.open(test_file) do |_zf|
75
+ end
75
76
  end
76
77
  end
77
78
 
@@ -79,14 +80,16 @@ class ZipSettingsTest < MiniTest::Test
79
80
  test_file = File.join(File.dirname(__FILE__), 'data', 'WarnInvalidDate.zip')
80
81
  Zip.warn_invalid_date = true
81
82
 
82
- ::Zip::File.open(test_file) do |zf|
83
+ assert_output('', /Invalid date\/time in zip entry/) do
84
+ ::Zip::File.open(test_file) do |_zf|
85
+ end
83
86
  end
84
87
  end
85
88
 
86
-
87
89
  private
90
+
88
91
  def assert_contains(zf, entryName, filename = entryName)
89
92
  assert(zf.entries.detect { |e| e.name == entryName } != nil, "entry #{entryName} not in #{zf.entries.join(', ')} in zip file #{zf}")
90
- assert_entryContents(zf, entryName, filename) if File.exist?(filename)
93
+ assert_entry_contents(zf, entryName, filename) if File.exist?(filename)
91
94
  end
92
95
  end
@@ -9,6 +9,11 @@ require 'gentestfiles'
9
9
  TestFiles.create_test_files
10
10
  TestZipFile.create_test_zips
11
11
 
12
+ if defined? JRUBY_VERSION
13
+ require 'jruby'
14
+ JRuby.objectspace = true
15
+ end
16
+
12
17
  ::MiniTest.after_run do
13
18
  FileUtils.rm_rf('test/data/generated')
14
19
  end
@@ -21,7 +26,7 @@ module IOizeString
21
26
  count = size unless count
22
27
  retVal = slice(@tell, count)
23
28
  @tell += count
24
- return retVal
29
+ retVal
25
30
  end
26
31
 
27
32
  def seek(index, offset)
@@ -34,12 +39,12 @@ module IOizeString
34
39
  when IO::SEEK_CUR
35
40
  newPos = @tell + index
36
41
  else
37
- raise "Error in test method IOizeString::seek"
42
+ raise 'Error in test method IOizeString::seek'
38
43
  end
39
- if (newPos < 0 || newPos >= size)
44
+ if newPos < 0 || newPos >= size
40
45
  raise Errno::EINVAL
41
46
  else
42
- @tell=newPos
47
+ @tell = newPos
43
48
  end
44
49
  end
45
50
 
@@ -51,7 +56,7 @@ end
51
56
  module DecompressorTests
52
57
  # expects @refText, @refLines and @decompressor
53
58
 
54
- TEST_FILE = "test/data/file1.txt"
59
+ TEST_FILE = 'test/data/file1.txt'
55
60
 
56
61
  def setup
57
62
  @refText = ''
@@ -59,11 +64,11 @@ module DecompressorTests
59
64
  @refLines = @refText.split($/)
60
65
  end
61
66
 
62
- def test_readEverything
67
+ def test_read_everything
63
68
  assert_equal(@refText, @decompressor.sysread)
64
69
  end
65
70
 
66
- def test_readInChunks
71
+ def test_read_in_chunks
67
72
  chunkSize = 5
68
73
  while (decompressedChunk = @decompressor.sysread(chunkSize))
69
74
  assert_equal(@refText.slice!(0, chunkSize), decompressedChunk)
@@ -71,22 +76,19 @@ module DecompressorTests
71
76
  assert_equal(0, @refText.size)
72
77
  end
73
78
 
74
- def test_mixingReadsAndProduceInput
79
+ def test_mixing_reads_and_produce_input
75
80
  # Just some preconditions to make sure we have enough data for this test
76
81
  assert(@refText.length > 1000)
77
82
  assert(@refLines.length > 40)
78
83
 
79
-
80
84
  assert_equal(@refText[0...100], @decompressor.sysread(100))
81
85
 
82
86
  assert(!@decompressor.input_finished?)
83
87
  buf = @decompressor.produce_input
84
- assert_equal(@refText[100...(100+buf.length)], buf)
88
+ assert_equal(@refText[100...(100 + buf.length)], buf)
85
89
  end
86
90
  end
87
91
 
88
-
89
-
90
92
  module AssertEntry
91
93
  def assert_next_entry(filename, zis)
92
94
  assert_entry(filename, zis, zis.get_next_entry.name)
@@ -94,33 +96,32 @@ module AssertEntry
94
96
 
95
97
  def assert_entry(filename, zis, entryName)
96
98
  assert_equal(filename, entryName)
97
- assert_entryContentsForStream(filename, zis, entryName)
99
+ assert_entry_contents_for_stream(filename, zis, entryName)
98
100
  end
99
101
 
100
- def assert_entryContentsForStream(filename, zis, entryName)
101
- File.open(filename, "rb") {
102
- |file|
102
+ def assert_entry_contents_for_stream(filename, zis, entryName)
103
+ File.open(filename, 'rb') do |file|
103
104
  expected = file.read
104
105
  actual = zis.read
105
- if (expected != actual)
106
- if ((expected && actual) && (expected.length > 400 || actual.length > 400))
107
- zipEntryFilename=entryName+".zipEntry"
108
- File.open(zipEntryFilename, "wb") { |entryfile| entryfile << actual }
106
+ if expected != actual
107
+ if (expected && actual) && (expected.length > 400 || actual.length > 400)
108
+ zipEntryFilename = entryName + '.zipEntry'
109
+ File.open(zipEntryFilename, 'wb') { |entryfile| entryfile << actual }
109
110
  fail("File '#{filename}' is different from '#{zipEntryFilename}'")
110
111
  else
111
112
  assert_equal(expected, actual)
112
113
  end
113
114
  end
114
- }
115
+ end
115
116
  end
116
117
 
117
- def AssertEntry.assert_contents(filename, aString)
118
- fileContents = ""
119
- File.open(filename, "rb") { |f| fileContents = f.read }
120
- if (fileContents != aString)
121
- if (fileContents.length > 400 || aString.length > 400)
122
- stringFile = filename + ".other"
123
- File.open(stringFile, "wb") { |f| f << aString }
118
+ def self.assert_contents(filename, aString)
119
+ fileContents = ''
120
+ File.open(filename, 'rb') { |f| fileContents = f.read }
121
+ if fileContents != aString
122
+ if fileContents.length > 400 || aString.length > 400
123
+ stringFile = filename + '.other'
124
+ File.open(stringFile, 'wb') { |f| f << aString }
124
125
  fail("File '#{filename}' is different from contents of string stored in '#{stringFile}'")
125
126
  else
126
127
  assert_equal(fileContents, aString)
@@ -129,11 +130,11 @@ module AssertEntry
129
130
  end
130
131
 
131
132
  def assert_stream_contents(zis, testZipFile)
132
- assert(zis != nil)
133
+ assert(!zis.nil?)
133
134
  testZipFile.entry_names.each do |entryName|
134
135
  assert_next_entry(entryName, zis)
135
136
  end
136
- assert_equal(nil, zis.get_next_entry)
137
+ assert_nil(zis.get_next_entry)
137
138
  end
138
139
 
139
140
  def assert_test_zip_contents(testZipFile)
@@ -142,27 +143,25 @@ module AssertEntry
142
143
  end
143
144
  end
144
145
 
145
- def assert_entryContents(zipFile, entryName, filename = entryName.to_s)
146
+ def assert_entry_contents(zipFile, entryName, filename = entryName.to_s)
146
147
  zis = zipFile.get_input_stream(entryName)
147
- assert_entryContentsForStream(filename, zis, entryName)
148
+ assert_entry_contents_for_stream(filename, zis, entryName)
148
149
  ensure
149
150
  zis.close if zis
150
151
  end
151
152
  end
152
153
 
153
-
154
154
  module CrcTest
155
-
156
155
  class TestOutputStream
157
156
  include ::Zip::IOExtras::AbstractOutputStream
158
157
 
159
158
  attr_accessor :buffer
160
159
 
161
160
  def initialize
162
- @buffer = ""
161
+ @buffer = ''
163
162
  end
164
163
 
165
- def << (data)
164
+ def <<(data)
166
165
  @buffer << data
167
166
  self
168
167
  end
@@ -178,26 +177,23 @@ module CrcTest
178
177
  end
179
178
  end
180
179
 
181
-
182
180
  module Enumerable
183
181
  def compare_enumerables(otherEnumerable)
184
182
  otherAsArray = otherEnumerable.to_a
185
- each_with_index {
186
- |element, index|
183
+ each_with_index do |element, index|
187
184
  return false unless yield(element, otherAsArray[index])
188
- }
189
- return self.size == otherAsArray.size
185
+ end
186
+ size == otherAsArray.size
190
187
  end
191
188
  end
192
189
 
193
-
194
190
  module CommonZipFileFixture
195
191
  include AssertEntry
196
192
 
197
- EMPTY_FILENAME = "emptyZipFile.zip"
193
+ EMPTY_FILENAME = 'emptyZipFile.zip'
198
194
 
199
195
  TEST_ZIP = TestZipFile::TEST_ZIP2.clone
200
- TEST_ZIP.zip_name = "test/data/generated/5entry_copy.zip"
196
+ TEST_ZIP.zip_name = 'test/data/generated/5entry_copy.zip'
201
197
 
202
198
  def setup
203
199
  File.delete(EMPTY_FILENAME) if File.exist?(EMPTY_FILENAME)
@@ -205,9 +201,7 @@ module CommonZipFileFixture
205
201
  end
206
202
  end
207
203
 
208
-
209
204
  module ExtraAssertions
210
-
211
205
  def assert_forwarded(anObject, method, retVal, *expectedArgs)
212
206
  callArgs = nil
213
207
  setCallArgsProc = proc { |args| callArgs = args }
@@ -224,5 +218,17 @@ module ExtraAssertions
224
218
  ensure
225
219
  anObject.instance_eval "undef #{method}; alias #{method} #{method}_org"
226
220
  end
221
+ end
227
222
 
223
+ module ZipEntryData
224
+ TEST_ZIPFILE = 'someZipFile.zip'
225
+ TEST_COMMENT = 'a comment'
226
+ TEST_COMPRESSED_SIZE = 1234
227
+ TEST_CRC = 325_324
228
+ TEST_EXTRA = 'Some data here'
229
+ TEST_COMPRESSIONMETHOD = ::Zip::Entry::DEFLATED
230
+ TEST_NAME = 'entry name'
231
+ TEST_SIZE = 8432
232
+ TEST_ISDIRECTORY = false
233
+ TEST_TIME = Time.now
228
234
  end