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
@@ -5,7 +5,7 @@ class BasicZipFileTest < MiniTest::Test
5
5
 
6
6
  def setup
7
7
  @zip_file = ::Zip::File.new(TestZipFile::TEST_ZIP2.zip_name)
8
- @testEntryNameIndex=0
8
+ @testEntryNameIndex = 0
9
9
  end
10
10
 
11
11
  def test_entries
@@ -16,26 +16,24 @@ class BasicZipFileTest < MiniTest::Test
16
16
  def test_each
17
17
  count = 0
18
18
  visited = {}
19
- @zip_file.each {
20
- |entry|
19
+ @zip_file.each do |entry|
21
20
  assert(TestZipFile::TEST_ZIP2.entry_names.include?(entry.name))
22
21
  assert(!visited.include?(entry.name))
23
22
  visited[entry.name] = nil
24
23
  count = count.succ
25
- }
24
+ end
26
25
  assert_equal(TestZipFile::TEST_ZIP2.entry_names.length, count)
27
26
  end
28
27
 
29
28
  def test_foreach
30
29
  count = 0
31
30
  visited = {}
32
- ::Zip::File.foreach(TestZipFile::TEST_ZIP2.zip_name) {
33
- |entry|
31
+ ::Zip::File.foreach(TestZipFile::TEST_ZIP2.zip_name) do |entry|
34
32
  assert(TestZipFile::TEST_ZIP2.entry_names.include?(entry.name))
35
33
  assert(!visited.include?(entry.name))
36
34
  visited[entry.name] = nil
37
35
  count = count.succ
38
- }
36
+ end
39
37
  assert_equal(TestZipFile::TEST_ZIP2.entry_names.length, count)
40
38
  end
41
39
 
@@ -51,14 +49,12 @@ class BasicZipFileTest < MiniTest::Test
51
49
  assert_equal(TestZipFile::TEST_ZIP2.entry_names.length, count)
52
50
  end
53
51
 
54
- def test_get_input_streamBlock
52
+ def test_get_input_stream_block
55
53
  fileAndEntryName = @zip_file.entries.first.name
56
- @zip_file.get_input_stream(fileAndEntryName) {
57
- |zis|
58
- assert_entryContentsForStream(fileAndEntryName,
59
- zis,
60
- fileAndEntryName)
61
- }
54
+ @zip_file.get_input_stream(fileAndEntryName) do |zis|
55
+ assert_entry_contents_for_stream(fileAndEntryName,
56
+ zis,
57
+ fileAndEntryName)
58
+ end
62
59
  end
63
-
64
60
  end
@@ -0,0 +1,69 @@
1
+ require 'test_helper'
2
+
3
+ class ZipCaseSensitivityTest < MiniTest::Test
4
+ include CommonZipFileFixture
5
+
6
+ SRC_FILES = [['test/data/file1.txt', 'testfile.rb'],
7
+ ['test/data/file2.txt', 'testFILE.rb']]
8
+
9
+ def teardown
10
+ ::Zip.case_insensitive_match = false
11
+ end
12
+
13
+ # Ensure that everything functions normally when +case_insensitive_match = false+
14
+ def test_add_case_sensitive
15
+ ::Zip.case_insensitive_match = false
16
+
17
+ SRC_FILES.each { |fn, _en| assert(::File.exist?(fn)) }
18
+ zf = ::Zip::File.new(EMPTY_FILENAME, ::Zip::File::CREATE)
19
+
20
+ SRC_FILES.each { |fn, en| zf.add(en, fn) }
21
+ zf.close
22
+
23
+ zfRead = ::Zip::File.new(EMPTY_FILENAME)
24
+ assert_equal(SRC_FILES.size, zfRead.entries.length)
25
+ SRC_FILES.each_with_index { |a, i|
26
+ assert_equal(a.last, zfRead.entries[i].name)
27
+ AssertEntry.assert_contents(a.first,
28
+ zfRead.get_input_stream(a.last) { |zis| zis.read })
29
+ }
30
+ end
31
+
32
+ # Ensure that names are treated case insensitively when adding files and +case_insensitive_match = false+
33
+ def test_add_case_insensitive
34
+ ::Zip.case_insensitive_match = true
35
+
36
+ SRC_FILES.each { |fn, _en| assert(::File.exist?(fn)) }
37
+ zf = ::Zip::File.new(EMPTY_FILENAME, ::Zip::File::CREATE)
38
+
39
+ assert_raises Zip::EntryExistsError do
40
+ SRC_FILES.each { |fn, en| zf.add(en, fn) }
41
+ end
42
+ end
43
+
44
+ # Ensure that names are treated case insensitively when reading files and +case_insensitive_match = true+
45
+ def test_add_case_sensitive_read_case_insensitive
46
+ ::Zip.case_insensitive_match = false
47
+
48
+ SRC_FILES.each { |fn, _en| assert(::File.exist?(fn)) }
49
+ zf = ::Zip::File.new(EMPTY_FILENAME, ::Zip::File::CREATE)
50
+
51
+ SRC_FILES.each { |fn, en| zf.add(en, fn) }
52
+ zf.close
53
+
54
+ ::Zip.case_insensitive_match = true
55
+
56
+ zfRead = ::Zip::File.new(EMPTY_FILENAME)
57
+ assert_equal(SRC_FILES.collect { |_fn, en| en.downcase }.uniq.size, zfRead.entries.length)
58
+ assert_equal(SRC_FILES.last.last.downcase, zfRead.entries.first.name.downcase)
59
+ AssertEntry.assert_contents(SRC_FILES.last.first,
60
+ zfRead.get_input_stream(SRC_FILES.last.last) { |zis| zis.read })
61
+ end
62
+
63
+ private
64
+
65
+ def assert_contains(zf, entryName, filename = entryName)
66
+ assert(zf.entries.detect { |e| e.name == entryName } != nil, "entry #{entryName} not in #{zf.entries.join(', ')} in zip file #{zf}")
67
+ assert_entry_contents(zf, entryName, filename) if File.exist?(filename)
68
+ end
69
+ end
@@ -1,73 +1,69 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class ZipCentralDirectoryEntryTest < MiniTest::Test
4
-
5
4
  def test_read_from_stream
6
- File.open("test/data/testDirectory.bin", "rb") {
7
- |file|
5
+ File.open('test/data/testDirectory.bin', 'rb') do |file|
8
6
  entry = ::Zip::Entry.read_c_dir_entry(file)
9
7
 
10
- assert_equal("longAscii.txt", entry.name)
8
+ assert_equal('longAscii.txt', entry.name)
11
9
  assert_equal(::Zip::Entry::DEFLATED, entry.compression_method)
12
- assert_equal(106490, entry.size)
10
+ assert_equal(106_490, entry.size)
13
11
  assert_equal(3784, entry.compressed_size)
14
12
  assert_equal(0xfcd1799c, entry.crc)
15
- assert_equal("", entry.comment)
13
+ assert_equal('', entry.comment)
16
14
 
17
15
  entry = ::Zip::Entry.read_c_dir_entry(file)
18
- assert_equal("empty.txt", entry.name)
16
+ assert_equal('empty.txt', entry.name)
19
17
  assert_equal(::Zip::Entry::STORED, entry.compression_method)
20
18
  assert_equal(0, entry.size)
21
19
  assert_equal(0, entry.compressed_size)
22
20
  assert_equal(0x0, entry.crc)
23
- assert_equal("", entry.comment)
21
+ assert_equal('', entry.comment)
24
22
 
25
23
  entry = ::Zip::Entry.read_c_dir_entry(file)
26
- assert_equal("short.txt", entry.name)
24
+ assert_equal('short.txt', entry.name)
27
25
  assert_equal(::Zip::Entry::STORED, entry.compression_method)
28
26
  assert_equal(6, entry.size)
29
27
  assert_equal(6, entry.compressed_size)
30
28
  assert_equal(0xbb76fe69, entry.crc)
31
- assert_equal("", entry.comment)
29
+ assert_equal('', entry.comment)
32
30
 
33
31
  entry = ::Zip::Entry.read_c_dir_entry(file)
34
- assert_equal("longBinary.bin", entry.name)
32
+ assert_equal('longBinary.bin', entry.name)
35
33
  assert_equal(::Zip::Entry::DEFLATED, entry.compression_method)
36
- assert_equal(1000024, entry.size)
37
- assert_equal(70847, entry.compressed_size)
34
+ assert_equal(1_000_024, entry.size)
35
+ assert_equal(70_847, entry.compressed_size)
38
36
  assert_equal(0x10da7d59, entry.crc)
39
37
  assert_equal('', entry.comment)
40
38
 
41
39
  entry = ::Zip::Entry.read_c_dir_entry(file)
42
- assert_equal(nil, entry)
43
- # Fields that are not check by this test:
44
- # version made by 2 bytes
45
- # version needed to extract 2 bytes
46
- # general purpose bit flag 2 bytes
47
- # last mod file time 2 bytes
48
- # last mod file date 2 bytes
49
- # compressed size 4 bytes
50
- # uncompressed size 4 bytes
51
- # disk number start 2 bytes
52
- # internal file attributes 2 bytes
53
- # external file attributes 4 bytes
54
- # relative offset of local header 4 bytes
55
-
56
- # file name (variable size)
57
- # extra field (variable size)
58
- # file comment (variable size)
40
+ assert_nil(entry)
41
+ # Fields that are not check by this test:
42
+ # version made by 2 bytes
43
+ # version needed to extract 2 bytes
44
+ # general purpose bit flag 2 bytes
45
+ # last mod file time 2 bytes
46
+ # last mod file date 2 bytes
47
+ # compressed size 4 bytes
48
+ # uncompressed size 4 bytes
49
+ # disk number start 2 bytes
50
+ # internal file attributes 2 bytes
51
+ # external file attributes 4 bytes
52
+ # relative offset of local header 4 bytes
59
53
 
60
- }
54
+ # file name (variable size)
55
+ # extra field (variable size)
56
+ # file comment (variable size)
57
+ end
61
58
  end
62
59
 
63
- def test_ReadEntryFromTruncatedZipFile
64
- fragment=""
65
- File.open("test/data/testDirectory.bin") { |f| fragment = f.read(12) } # cdir entry header is at least 46 bytes
60
+ def test_read_entry_from_truncated_zip_file
61
+ fragment = ''
62
+ File.open('test/data/testDirectory.bin') { |f| fragment = f.read(12) } # cdir entry header is at least 46 bytes
66
63
  fragment.extend(IOizeString)
67
64
  entry = ::Zip::Entry.new
68
65
  entry.read_c_dir_entry(fragment)
69
- fail "ZipError expected"
66
+ fail 'ZipError expected'
70
67
  rescue ::Zip::Error
71
68
  end
72
-
73
69
  end
@@ -1,96 +1,92 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class ZipCentralDirectoryTest < MiniTest::Test
4
-
5
4
  def teardown
6
5
  ::Zip.reset!
7
6
  end
8
7
 
9
8
  def test_read_from_stream
10
- ::File.open(TestZipFile::TEST_ZIP2.zip_name, "rb") {
11
- |zipFile|
9
+ ::File.open(TestZipFile::TEST_ZIP2.zip_name, 'rb') do |zipFile|
12
10
  cdir = ::Zip::CentralDirectory.read_from_stream(zipFile)
13
11
 
14
12
  assert_equal(TestZipFile::TEST_ZIP2.entry_names.size, cdir.size)
15
- assert(cdir.entries.sort.compare_enumerables(TestZipFile::TEST_ZIP2.entry_names.sort) {
16
- |cdirEntry, testEntryName|
13
+ assert(cdir.entries.sort.compare_enumerables(TestZipFile::TEST_ZIP2.entry_names.sort) do |cdirEntry, testEntryName|
17
14
  cdirEntry.name == testEntryName
18
- })
15
+ end)
19
16
  assert_equal(TestZipFile::TEST_ZIP2.comment, cdir.comment)
20
- }
17
+ end
21
18
  end
22
19
 
23
- def test_readFromInvalidStream
24
- File.open("test/data/file2.txt", "rb") {
25
- |zipFile|
20
+ def test_read_from_invalid_stream
21
+ File.open('test/data/file2.txt', 'rb') do |zipFile|
26
22
  cdir = ::Zip::CentralDirectory.new
27
23
  cdir.read_from_stream(zipFile)
28
- }
29
- fail "ZipError expected!"
24
+ end
25
+ fail 'ZipError expected!'
30
26
  rescue ::Zip::Error
31
27
  end
32
28
 
33
- def test_ReadFromTruncatedZipFile
34
- fragment=""
35
- File.open("test/data/testDirectory.bin", "rb") { |f| fragment = f.read }
29
+ def test_read_from_truncated_zip_file
30
+ fragment = ''
31
+ File.open('test/data/testDirectory.bin', 'rb') { |f| fragment = f.read }
36
32
  fragment.slice!(12) # removed part of first cdir entry. eocd structure still complete
37
33
  fragment.extend(IOizeString)
38
34
  entry = ::Zip::CentralDirectory.new
39
35
  entry.read_from_stream(fragment)
40
- fail "ZipError expected"
36
+ fail 'ZipError expected'
41
37
  rescue ::Zip::Error
42
38
  end
43
39
 
44
40
  def test_write_to_stream
45
- entries = [::Zip::Entry.new("file.zip", "flimse", "myComment", "somethingExtra"),
46
- ::Zip::Entry.new("file.zip", "secondEntryName"),
47
- ::Zip::Entry.new("file.zip", "lastEntry.txt", "Has a comment too")]
48
- cdir = ::Zip::CentralDirectory.new(entries, "my zip comment")
49
- File.open("test/data/generated/cdirtest.bin", "wb") { |f| cdir.write_to_stream(f) }
41
+ entries = [::Zip::Entry.new('file.zip', 'flimse', 'myComment', 'somethingExtra'),
42
+ ::Zip::Entry.new('file.zip', 'secondEntryName'),
43
+ ::Zip::Entry.new('file.zip', 'lastEntry.txt', 'Has a comment too')]
44
+ cdir = ::Zip::CentralDirectory.new(entries, 'my zip comment')
45
+ File.open('test/data/generated/cdirtest.bin', 'wb') { |f| cdir.write_to_stream(f) }
50
46
  cdirReadback = ::Zip::CentralDirectory.new
51
- File.open("test/data/generated/cdirtest.bin", "rb") { |f| cdirReadback.read_from_stream(f) }
47
+ File.open('test/data/generated/cdirtest.bin', 'rb') { |f| cdirReadback.read_from_stream(f) }
52
48
 
53
49
  assert_equal(cdir.entries.sort, cdirReadback.entries.sort)
54
50
  end
55
51
 
56
52
  def test_write64_to_stream
57
53
  ::Zip.write_zip64_support = true
58
- entries = [::Zip::Entry.new("file.zip", "file1-little", "comment1", "", 200, 101, ::Zip::Entry::STORED, 200),
59
- ::Zip::Entry.new("file.zip", "file2-big", "comment2", "", 18000000000, 102, ::Zip::Entry::DEFLATED, 20000000000),
60
- ::Zip::Entry.new("file.zip", "file3-alsobig", "comment3", "", 15000000000, 103, ::Zip::Entry::DEFLATED, 21000000000),
61
- ::Zip::Entry.new("file.zip", "file4-little", "comment4", "", 100, 104, ::Zip::Entry::DEFLATED, 121)]
62
- [0, 250, 18000000300, 33000000350].each_with_index do |offset, index|
54
+ entries = [::Zip::Entry.new('file.zip', 'file1-little', 'comment1', '', 200, 101, ::Zip::Entry::STORED, 200),
55
+ ::Zip::Entry.new('file.zip', 'file2-big', 'comment2', '', 18_000_000_000, 102, ::Zip::Entry::DEFLATED, 20_000_000_000),
56
+ ::Zip::Entry.new('file.zip', 'file3-alsobig', 'comment3', '', 15_000_000_000, 103, ::Zip::Entry::DEFLATED, 21_000_000_000),
57
+ ::Zip::Entry.new('file.zip', 'file4-little', 'comment4', '', 100, 104, ::Zip::Entry::DEFLATED, 121)]
58
+ [0, 250, 18_000_000_300, 33_000_000_350].each_with_index do |offset, index|
63
59
  entries[index].local_header_offset = offset
64
60
  end
65
- cdir = ::Zip::CentralDirectory.new(entries, "zip comment")
66
- File.open("test/data/generated/cdir64test.bin", "wb") { |f| cdir.write_to_stream(f) }
61
+ cdir = ::Zip::CentralDirectory.new(entries, 'zip comment')
62
+ File.open('test/data/generated/cdir64test.bin', 'wb') { |f| cdir.write_to_stream(f) }
67
63
  cdirReadback = ::Zip::CentralDirectory.new
68
- File.open("test/data/generated/cdir64test.bin", "rb") { |f| cdirReadback.read_from_stream(f) }
64
+ File.open('test/data/generated/cdir64test.bin', 'rb') { |f| cdirReadback.read_from_stream(f) }
69
65
 
70
66
  assert_equal(cdir.entries.sort, cdirReadback.entries.sort)
71
67
  assert_equal(::Zip::VERSION_NEEDED_TO_EXTRACT_ZIP64, cdirReadback.instance_variable_get(:@version_needed_for_extract))
72
68
  end
73
69
 
74
70
  def test_equality
75
- cdir1 = ::Zip::CentralDirectory.new([::Zip::Entry.new("file.zip", "flimse", nil,
76
- "somethingExtra"),
77
- ::Zip::Entry.new("file.zip", "secondEntryName"),
78
- ::Zip::Entry.new("file.zip", "lastEntry.txt")],
79
- "my zip comment")
80
- cdir2 = ::Zip::CentralDirectory.new([::Zip::Entry.new("file.zip", "flimse", nil,
81
- "somethingExtra"),
82
- ::Zip::Entry.new("file.zip", "secondEntryName"),
83
- ::Zip::Entry.new("file.zip", "lastEntry.txt")],
84
- "my zip comment")
85
- cdir3 = ::Zip::CentralDirectory.new([::Zip::Entry.new("file.zip", "flimse", nil,
86
- "somethingExtra"),
87
- ::Zip::Entry.new("file.zip", "secondEntryName"),
88
- ::Zip::Entry.new("file.zip", "lastEntry.txt")],
89
- "comment?")
90
- cdir4 = ::Zip::CentralDirectory.new([::Zip::Entry.new("file.zip", "flimse", nil,
91
- "somethingExtra"),
92
- ::Zip::Entry.new("file.zip", "lastEntry.txt")],
93
- "comment?")
71
+ cdir1 = ::Zip::CentralDirectory.new([::Zip::Entry.new('file.zip', 'flimse', nil,
72
+ 'somethingExtra'),
73
+ ::Zip::Entry.new('file.zip', 'secondEntryName'),
74
+ ::Zip::Entry.new('file.zip', 'lastEntry.txt')],
75
+ 'my zip comment')
76
+ cdir2 = ::Zip::CentralDirectory.new([::Zip::Entry.new('file.zip', 'flimse', nil,
77
+ 'somethingExtra'),
78
+ ::Zip::Entry.new('file.zip', 'secondEntryName'),
79
+ ::Zip::Entry.new('file.zip', 'lastEntry.txt')],
80
+ 'my zip comment')
81
+ cdir3 = ::Zip::CentralDirectory.new([::Zip::Entry.new('file.zip', 'flimse', nil,
82
+ 'somethingExtra'),
83
+ ::Zip::Entry.new('file.zip', 'secondEntryName'),
84
+ ::Zip::Entry.new('file.zip', 'lastEntry.txt')],
85
+ 'comment?')
86
+ cdir4 = ::Zip::CentralDirectory.new([::Zip::Entry.new('file.zip', 'flimse', nil,
87
+ 'somethingExtra'),
88
+ ::Zip::Entry.new('file.zip', 'lastEntry.txt')],
89
+ 'comment?')
94
90
  assert_equal(cdir1, cdir1)
95
91
  assert_equal(cdir1, cdir2)
96
92
 
@@ -99,6 +95,6 @@ class ZipCentralDirectoryTest < MiniTest::Test
99
95
  assert(cdir2 != cdir3)
100
96
  assert(cdir3 != cdir4)
101
97
 
102
- assert(cdir3 != "hello")
98
+ assert(cdir3 != 'hello')
103
99
  end
104
100
  end
@@ -4,7 +4,7 @@ class NullEncrypterTest < MiniTest::Test
4
4
  def setup
5
5
  @encrypter = ::Zip::NullEncrypter.new
6
6
  end
7
-
7
+
8
8
  def test_header_bytesize
9
9
  assert_equal 0, @encrypter.header_bytesize
10
10
  end
@@ -18,7 +18,9 @@ class NullEncrypterTest < MiniTest::Test
18
18
  end
19
19
 
20
20
  def test_encrypt
21
- [nil, '', 'a' * 10, 0xffffffff].each do |data|
21
+ assert_nil @encrypter.encrypt(nil)
22
+
23
+ ['', 'a' * 10, 0xffffffff].each do |data|
22
24
  assert_equal data, @encrypter.encrypt(data)
23
25
  end
24
26
  end
@@ -32,7 +34,7 @@ class NullDecrypterTest < MiniTest::Test
32
34
  def setup
33
35
  @decrypter = ::Zip::NullDecrypter.new
34
36
  end
35
-
37
+
36
38
  def test_header_bytesize
37
39
  assert_equal 0, @decrypter.header_bytesize
38
40
  end
@@ -42,7 +44,9 @@ class NullDecrypterTest < MiniTest::Test
42
44
  end
43
45
 
44
46
  def test_decrypt
45
- [nil, '', 'a' * 10, 0xffffffff].each do |data|
47
+ assert_nil @decrypter.decrypt(nil)
48
+
49
+ ['', 'a' * 10, 0xffffffff].each do |data|
46
50
  assert_equal data, @decrypter.decrypt(data)
47
51
  end
48
52
  end
@@ -16,7 +16,7 @@ class TraditionalEncrypterTest < MiniTest::Test
16
16
 
17
17
  def test_header
18
18
  @encrypter.reset!
19
- exepected = [239, 57, 234, 154, 246, 80, 83, 221, 74, 200, 121, 91].pack("C*")
19
+ exepected = [239, 57, 234, 154, 246, 80, 83, 221, 74, 200, 121, 91].pack('C*')
20
20
  Random.stub(:rand, 1) do
21
21
  assert_equal exepected, @encrypter.header(@mtime)
22
22
  end
@@ -28,7 +28,7 @@ class TraditionalEncrypterTest < MiniTest::Test
28
28
  assert_raises(NoMethodError) { @encrypter.encrypt(nil) }
29
29
  assert_raises(NoMethodError) { @encrypter.encrypt(1) }
30
30
  assert_equal '', @encrypter.encrypt('')
31
- assert_equal [100, 218, 7, 114, 226, 82, 62, 93, 224, 62].pack("C*"), @encrypter.encrypt('a' * 10)
31
+ assert_equal [100, 218, 7, 114, 226, 82, 62, 93, 224, 62].pack('C*'), @encrypter.encrypt('a' * 10)
32
32
  end
33
33
 
34
34
  def test_reset!
@@ -60,19 +60,19 @@ class TraditionalDecrypterTest < MiniTest::Test
60
60
  end
61
61
 
62
62
  def test_decrypt
63
- @decrypter.reset!([239, 57, 234, 154, 246, 80, 83, 221, 74, 200, 121, 91].pack("C*"))
63
+ @decrypter.reset!([239, 57, 234, 154, 246, 80, 83, 221, 74, 200, 121, 91].pack('C*'))
64
64
  [100, 218, 7, 114, 226, 82, 62, 93, 224, 62].map(&:chr).each do |c|
65
65
  assert_equal 'a', @decrypter.decrypt(c)
66
66
  end
67
67
  end
68
68
 
69
69
  def test_reset!
70
- @decrypter.reset!([239, 57, 234, 154, 246, 80, 83, 221, 74, 200, 121, 91].pack("C*"))
70
+ @decrypter.reset!([239, 57, 234, 154, 246, 80, 83, 221, 74, 200, 121, 91].pack('C*'))
71
71
  [100, 218, 7, 114, 226, 82, 62, 93, 224, 62].map(&:chr).each do |c|
72
72
  assert_equal 'a', @decrypter.decrypt(c)
73
73
  end
74
74
  assert_equal 91.chr, @decrypter.decrypt(2.chr)
75
- @decrypter.reset!([239, 57, 234, 154, 246, 80, 83, 221, 74, 200, 121, 91].pack("C*"))
75
+ @decrypter.reset!([239, 57, 234, 154, 246, 80, 83, 221, 74, 200, 121, 91].pack('C*'))
76
76
  [100, 218, 7, 114, 226, 82, 62, 93, 224, 62].map(&:chr).each do |c|
77
77
  assert_equal 'a', @decrypter.decrypt(c)
78
78
  end