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
@@ -18,7 +18,7 @@ class EncryptionTest < MiniTest::Test
18
18
 
19
19
  @rand = [250, 143, 107, 13, 143, 22, 155, 75, 228, 150, 12]
20
20
  @output = ::Zip::DOSTime.stub(:now, ::Zip::DOSTime.new(2014, 12, 17, 15, 56, 24)) do
21
- Random.stub(:rand, lambda { |range| @rand.shift }) do
21
+ Random.stub(:rand, ->(_range) { @rand.shift }) do
22
22
  Zip::OutputStream.write_buffer(::StringIO.new(''), Zip::TraditionalEncrypter.new('password')) do |zos|
23
23
  zos.put_next_entry('file1.txt')
24
24
  zos.write open(INPUT_FILE1).read
@@ -26,7 +26,7 @@ class EncryptionTest < MiniTest::Test
26
26
  end
27
27
  end
28
28
 
29
- @output.unpack("C*").each_with_index do |c, i|
29
+ @output.unpack('C*').each_with_index do |c, i|
30
30
  assert_equal test_file[i].ord, c
31
31
  end
32
32
  end
@@ -2,12 +2,12 @@ require 'test_helper'
2
2
 
3
3
  class ZipEntrySetTest < MiniTest::Test
4
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")
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
11
  ]
12
12
 
13
13
  def setup
@@ -20,20 +20,20 @@ class ZipEntrySetTest < MiniTest::Test
20
20
 
21
21
  def test_include
22
22
  assert(@zipEntrySet.include?(ZIP_ENTRIES.first))
23
- assert(!@zipEntrySet.include?(::Zip::Entry.new("different.zip", "different", "aComment")))
23
+ assert(!@zipEntrySet.include?(::Zip::Entry.new('different.zip', 'different', 'aComment')))
24
24
  end
25
25
 
26
26
  def test_size
27
27
  assert_equal(ZIP_ENTRIES.size, @zipEntrySet.size)
28
28
  assert_equal(ZIP_ENTRIES.size, @zipEntrySet.length)
29
- @zipEntrySet << ::Zip::Entry.new("a", "b", "c")
29
+ @zipEntrySet << ::Zip::Entry.new('a', 'b', 'c')
30
30
  assert_equal(ZIP_ENTRIES.size + 1, @zipEntrySet.length)
31
31
  end
32
32
 
33
33
  def test_add
34
34
  zes = ::Zip::EntrySet.new
35
- entry1 = ::Zip::Entry.new("zf.zip", "name1")
36
- entry2 = ::Zip::Entry.new("zf.zip", "name2")
35
+ entry1 = ::Zip::Entry.new('zf.zip', 'name1')
36
+ entry2 = ::Zip::Entry.new('zf.zip', 'name2')
37
37
  zes << entry1
38
38
  assert(zes.include?(entry1))
39
39
  zes.push(entry2)
@@ -65,6 +65,20 @@ class ZipEntrySetTest < MiniTest::Test
65
65
  assert_equal(ZIP_ENTRIES, @zipEntrySet.entries)
66
66
  end
67
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
+
68
82
  def test_entries_with_sort
69
83
  ::Zip.sort_entries = true
70
84
  assert_equal(ZIP_ENTRIES.sort, @zipEntrySet.entries)
@@ -82,7 +96,7 @@ class ZipEntrySetTest < MiniTest::Test
82
96
  end
83
97
 
84
98
  def test_compound
85
- newEntry = ::Zip::Entry.new("zf.zip", "new entry", "new entry's comment")
99
+ newEntry = ::Zip::Entry.new('zf.zip', 'new entry', "new entry's comment")
86
100
  assert_equal(ZIP_ENTRIES.size, @zipEntrySet.size)
87
101
  @zipEntrySet << newEntry
88
102
  assert_equal(ZIP_ENTRIES.size + 1, @zipEntrySet.size)
@@ -97,15 +111,15 @@ class ZipEntrySetTest < MiniTest::Test
97
111
  assert_equal(@zipEntrySet, copy)
98
112
 
99
113
  # demonstrate that this is a deep copy
100
- copy.entries[0].name = "a totally different name"
114
+ copy.entries[0].name = 'a totally different name'
101
115
  assert(@zipEntrySet != copy)
102
116
  end
103
117
 
104
118
  def test_parent
105
119
  entries = [
106
- ::Zip::Entry.new("zf.zip", "a/"),
107
- ::Zip::Entry.new("zf.zip", "a/b/"),
108
- ::Zip::Entry.new("zf.zip", "a/b/c/")
120
+ ::Zip::Entry.new('zf.zip', 'a/'),
121
+ ::Zip::Entry.new('zf.zip', 'a/b/'),
122
+ ::Zip::Entry.new('zf.zip', 'a/b/c/')
109
123
  ]
110
124
  entrySet = ::Zip::EntrySet.new(entries)
111
125
 
@@ -122,17 +136,17 @@ class ZipEntrySetTest < MiniTest::Test
122
136
 
123
137
  def test_glob2
124
138
  entries = [
125
- ::Zip::Entry.new("zf.zip", "a/"),
126
- ::Zip::Entry.new("zf.zip", "a/b/b1"),
127
- ::Zip::Entry.new("zf.zip", "a/b/c/"),
128
- ::Zip::Entry.new("zf.zip", "a/b/c/c1")
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')
129
143
  ]
130
144
  entrySet = ::Zip::EntrySet.new(entries)
131
145
 
132
- assert_equal(entries[0, 1], entrySet.glob("*"))
133
- # assert_equal(entries[FIXME], entrySet.glob("**"))
134
- # res = entrySet.glob('a*')
135
- # assert_equal(entries.size, res.size)
136
- # assert_equal(entrySet.map { |e| e.name }, res.map { |e| e.name })
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 })
137
151
  end
138
152
  end
@@ -1,18 +1,18 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class ZipEntryTest < MiniTest::Test
4
- TEST_ZIPFILE = "someZipFile.zip"
5
- TEST_COMMENT = "a comment"
4
+ TEST_ZIPFILE = 'someZipFile.zip'
5
+ TEST_COMMENT = 'a comment'
6
6
  TEST_COMPRESSED_SIZE = 1234
7
- TEST_CRC = 325324
8
- TEST_EXTRA = "Some data here"
7
+ TEST_CRC = 325_324
8
+ TEST_EXTRA = 'Some data here'
9
9
  TEST_COMPRESSIONMETHOD = ::Zip::Entry::DEFLATED
10
- TEST_NAME = "entry name"
10
+ TEST_NAME = 'entry name'
11
11
  TEST_SIZE = 8432
12
12
  TEST_ISDIRECTORY = false
13
13
  TEST_TIME = Time.now
14
14
 
15
- def test_constructorAndGetters
15
+ def test_constructor_and_getters
16
16
  entry = ::Zip::Entry.new(TEST_ZIPFILE,
17
17
  TEST_NAME,
18
18
  TEST_COMMENT,
@@ -33,45 +33,45 @@ class ZipEntryTest < MiniTest::Test
33
33
  assert_equal(TEST_TIME, entry.time)
34
34
  end
35
35
 
36
- def test_is_directoryAndIsFile
37
- assert(::Zip::Entry.new(TEST_ZIPFILE, "hello").file?)
38
- assert(!::Zip::Entry.new(TEST_ZIPFILE, "hello").directory?)
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
39
 
40
- assert(::Zip::Entry.new(TEST_ZIPFILE, "dir/hello").file?)
41
- assert(!::Zip::Entry.new(TEST_ZIPFILE, "dir/hello").directory?)
40
+ assert(::Zip::Entry.new(TEST_ZIPFILE, 'dir/hello').file?)
41
+ assert(!::Zip::Entry.new(TEST_ZIPFILE, 'dir/hello').directory?)
42
42
 
43
- assert(::Zip::Entry.new(TEST_ZIPFILE, "hello/").directory?)
44
- assert(!::Zip::Entry.new(TEST_ZIPFILE, "hello/").file?)
43
+ assert(::Zip::Entry.new(TEST_ZIPFILE, 'hello/').directory?)
44
+ assert(!::Zip::Entry.new(TEST_ZIPFILE, 'hello/').file?)
45
45
 
46
- assert(::Zip::Entry.new(TEST_ZIPFILE, "dir/hello/").directory?)
47
- assert(!::Zip::Entry.new(TEST_ZIPFILE, "dir/hello/").file?)
46
+ assert(::Zip::Entry.new(TEST_ZIPFILE, 'dir/hello/').directory?)
47
+ assert(!::Zip::Entry.new(TEST_ZIPFILE, 'dir/hello/').file?)
48
48
  end
49
49
 
50
50
  def test_equality
51
- entry1 = ::Zip::Entry.new("file.zip", "name", "isNotCompared",
52
- "something extra", 123, 1234,
53
- ::Zip::Entry::DEFLATED, 10000)
54
- entry2 = ::Zip::Entry.new("file.zip", "name", "isNotComparedXXX",
55
- "something extra", 123, 1234,
56
- ::Zip::Entry::DEFLATED, 10000)
57
- entry3 = ::Zip::Entry.new("file.zip", "name2", "isNotComparedXXX",
58
- "something extra", 123, 1234,
59
- ::Zip::Entry::DEFLATED, 10000)
60
- entry4 = ::Zip::Entry.new("file.zip", "name2", "isNotComparedXXX",
61
- "something extraXX", 123, 1234,
62
- ::Zip::Entry::DEFLATED, 10000)
63
- entry5 = ::Zip::Entry.new("file.zip", "name2", "isNotComparedXXX",
64
- "something extraXX", 12, 1234,
65
- ::Zip::Entry::DEFLATED, 10000)
66
- entry6 = ::Zip::Entry.new("file.zip", "name2", "isNotComparedXXX",
67
- "something extraXX", 12, 123,
68
- ::Zip::Entry::DEFLATED, 10000)
69
- entry7 = ::Zip::Entry.new("file.zip", "name2", "isNotComparedXXX",
70
- "something extraXX", 12, 123,
71
- ::Zip::Entry::STORED, 10000)
72
- entry8 = ::Zip::Entry.new("file.zip", "name2", "isNotComparedXXX",
73
- "something extraXX", 12, 123,
74
- ::Zip::Entry::STORED, 100000)
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
75
 
76
76
  assert_equal(entry1, entry1)
77
77
  assert_equal(entry1, entry2)
@@ -83,51 +83,51 @@ class ZipEntryTest < MiniTest::Test
83
83
  assert(entry6 != entry7)
84
84
  assert(entry7 != entry8)
85
85
 
86
- assert(entry7 != "hello")
86
+ assert(entry7 != 'hello')
87
87
  assert(entry7 != 12)
88
88
  end
89
89
 
90
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")))
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
94
 
95
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")
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
102
  ]
103
103
 
104
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)
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
111
  end
112
112
 
113
- def test_parentAsString
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/")
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
120
 
121
121
  assert_equal(nil, entry1.parent_as_string)
122
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)
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
127
  end
128
128
 
129
129
  def test_entry_name_cannot_start_with_slash
130
- assert_raises(::Zip::EntryNameError) { ::Zip::Entry.new("zf.zip", "/hej/der") }
130
+ assert_raises(::Zip::EntryNameError) { ::Zip::Entry.new('zf.zip', '/hej/der') }
131
131
  end
132
132
 
133
133
  def test_store_file_without_compression
@@ -139,27 +139,25 @@ class ZipEntryTest < MiniTest::Test
139
139
  end
140
140
 
141
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
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
149
 
150
150
  zipfile.add(mimetype_entry, 'test/data/mimetype')
151
151
 
152
152
  files.each do |file|
153
- zipfile.add(file.sub("test/data/globTest/", ''), file)
153
+ zipfile.add(file.sub('test/data/globTest/', ''), file)
154
154
  end
155
155
  zipfile.close
156
156
 
157
- f= File.open('/tmp/no_compress.zip', 'rb')
157
+ f = File.open('/tmp/no_compress.zip', 'rb')
158
158
  first_100_bytes = f.read(100)
159
159
  f.close
160
160
 
161
161
  assert_match(/mimetypeapplication\/epub\+zip/, first_100_bytes)
162
162
  end
163
-
164
-
165
163
  end
@@ -2,7 +2,6 @@
2
2
  require 'test_helper'
3
3
 
4
4
  class ErrorsTest < MiniTest::Test
5
-
6
5
  def test_rescue_legacy_zip_error
7
6
  raise ::Zip::Error
8
7
  rescue ::Zip::ZipError
@@ -32,5 +31,4 @@ class ErrorsTest < MiniTest::Test
32
31
  raise ::Zip::InternalError
33
32
  rescue ::Zip::ZipInternalError
34
33
  end
35
-
36
34
  end
@@ -2,26 +2,26 @@ require 'test_helper'
2
2
 
3
3
  class ZipExtraFieldTest < MiniTest::Test
4
4
  def test_new
5
- extra_pure = ::Zip::ExtraField.new("")
6
- extra_withstr = ::Zip::ExtraField.new("foo")
5
+ extra_pure = ::Zip::ExtraField.new('')
6
+ extra_withstr = ::Zip::ExtraField.new('foo')
7
7
  assert_instance_of(::Zip::ExtraField, extra_pure)
8
8
  assert_instance_of(::Zip::ExtraField, extra_withstr)
9
9
  end
10
10
 
11
11
  def test_unknownfield
12
- extra = ::Zip::ExtraField.new("foo")
13
- assert_equal(extra["Unknown"], "foo")
14
- extra.merge("a")
15
- assert_equal(extra["Unknown"], "fooa")
16
- extra.merge("barbaz")
17
- assert_equal(extra.to_s, "fooabarbaz")
12
+ extra = ::Zip::ExtraField.new('foo')
13
+ assert_equal(extra['Unknown'], 'foo')
14
+ extra.merge('a')
15
+ assert_equal(extra['Unknown'], 'fooa')
16
+ extra.merge('barbaz')
17
+ assert_equal(extra.to_s, 'fooabarbaz')
18
18
  end
19
19
 
20
20
  def test_ntfs
21
21
  str = "\x0A\x00 \x00\x00\x00\x00\x00\x01\x00\x18\x00\xC0\x81\x17\xE8B\xCE\xCF\x01\xC0\x81\x17\xE8B\xCE\xCF\x01\xC0\x81\x17\xE8B\xCE\xCF\x01"
22
22
  extra = ::Zip::ExtraField.new(str)
23
- assert(extra.member?("NTFS"))
24
- t = ::Zip::DOSTime.at(1410496497.405178)
23
+ assert(extra.member?('NTFS'))
24
+ t = ::Zip::DOSTime.at(1_410_496_497.405178)
25
25
  assert_equal(t, extra['NTFS'].mtime)
26
26
  assert_equal(t, extra['NTFS'].atime)
27
27
  assert_equal(t, extra['NTFS'].ctime)
@@ -29,12 +29,12 @@ class ZipExtraFieldTest < MiniTest::Test
29
29
 
30
30
  def test_merge
31
31
  str = "UT\x5\0\x3\250$\r@Ux\0\0"
32
- extra1 = ::Zip::ExtraField.new("")
32
+ extra1 = ::Zip::ExtraField.new('')
33
33
  extra2 = ::Zip::ExtraField.new(str)
34
- assert(!extra1.member?("UniversalTime"))
35
- assert(extra2.member?("UniversalTime"))
34
+ assert(!extra1.member?('UniversalTime'))
35
+ assert(extra2.member?('UniversalTime'))
36
36
  extra1.merge(str)
37
- assert_equal(extra1["UniversalTime"].mtime, extra2["UniversalTime"].mtime)
37
+ assert_equal(extra1['UniversalTime'].mtime, extra2['UniversalTime'].mtime)
38
38
  end
39
39
 
40
40
  def test_length
@@ -42,19 +42,18 @@ class ZipExtraFieldTest < MiniTest::Test
42
42
  extra = ::Zip::ExtraField.new(str)
43
43
  assert_equal(extra.local_size, extra.to_local_bin.size)
44
44
  assert_equal(extra.c_dir_size, extra.to_c_dir_bin.size)
45
- extra.merge("foo")
45
+ extra.merge('foo')
46
46
  assert_equal(extra.local_size, extra.to_local_bin.size)
47
47
  assert_equal(extra.c_dir_size, extra.to_c_dir_bin.size)
48
48
  end
49
49
 
50
-
51
50
  def test_to_s
52
51
  str = "UT\x5\0\x3\250$\r@Ux\0\0Te\0\0testit"
53
52
  extra = ::Zip::ExtraField.new(str)
54
53
  assert_instance_of(String, extra.to_s)
55
54
 
56
55
  s = extra.to_s
57
- extra.merge("foo")
56
+ extra.merge('foo')
58
57
  assert_equal(s.length + 3, extra.to_s.length)
59
58
  end
60
59
 
@@ -65,14 +64,13 @@ class ZipExtraFieldTest < MiniTest::Test
65
64
  extra3 = ::Zip::ExtraField.new(str)
66
65
  assert_equal(extra1, extra2)
67
66
 
68
- extra2["UniversalTime"].mtime = ::Zip::DOSTime.now
67
+ extra2['UniversalTime'].mtime = ::Zip::DOSTime.now
69
68
  assert(extra1 != extra2)
70
69
 
71
- extra3.create("IUnix")
70
+ extra3.create('IUnix')
72
71
  assert(extra1 != extra3)
73
72
 
74
- extra1.create("IUnix")
73
+ extra1.create('IUnix')
75
74
  assert_equal(extra1, extra3)
76
75
  end
77
-
78
76
  end