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
@@ -6,7 +6,7 @@ class AbstractInputStreamTest < MiniTest::Test
6
6
 
7
7
  TEST_LINES = ["Hello world#{$/}",
8
8
  "this is the second line#{$/}",
9
- "this is the last line"]
9
+ 'this is the last line']
10
10
  TEST_STRING = TEST_LINES.join
11
11
  class TestAbstractInputStream
12
12
  include ::Zip::IOExtras::AbstractInputStream
@@ -17,10 +17,10 @@ class AbstractInputStreamTest < MiniTest::Test
17
17
  @readPointer = 0
18
18
  end
19
19
 
20
- def sysread(charsToRead, buf = nil)
21
- retVal=@contents[@readPointer, charsToRead]
22
- @readPointer+=charsToRead
23
- return retVal
20
+ def sysread(charsToRead, _buf = nil)
21
+ retVal = @contents[@readPointer, charsToRead]
22
+ @readPointer += charsToRead
23
+ retVal
24
24
  end
25
25
 
26
26
  def produce_input
@@ -28,7 +28,7 @@ class AbstractInputStreamTest < MiniTest::Test
28
28
  end
29
29
 
30
30
  def input_finished?
31
- @contents[@readPointer] == nil
31
+ @contents[@readPointer].nil?
32
32
  end
33
33
  end
34
34
 
@@ -44,48 +44,47 @@ class AbstractInputStreamTest < MiniTest::Test
44
44
  assert_equal(2, @io.lineno)
45
45
  assert_equal(TEST_LINES[2], @io.gets)
46
46
  assert_equal(3, @io.lineno)
47
- assert_equal(nil, @io.gets)
47
+ assert_nil(@io.gets)
48
48
  assert_equal(4, @io.lineno)
49
49
  end
50
50
 
51
- def test_getsMultiCharSeperator
52
- assert_equal("Hell", @io.gets("ll"))
53
- assert_equal("o world#{$/}this is the second l", @io.gets("d l"))
51
+ def test_gets_multi_char_seperator
52
+ assert_equal('Hell', @io.gets('ll'))
53
+ assert_equal("o world#{$/}this is the second l", @io.gets('d l'))
54
54
  end
55
55
 
56
56
  LONG_LINES = [
57
- 'x'*48 + "\r\n",
58
- 'y'*49 + "\r\n",
59
- 'rest',
57
+ 'x' * 48 + "\r\n",
58
+ 'y' * 49 + "\r\n",
59
+ 'rest'
60
60
  ]
61
61
 
62
- def test_getsMulitCharSeperator_split
62
+ def test_gets_mulit_char_seperator_split
63
63
  io = TestAbstractInputStream.new(LONG_LINES.join)
64
64
  assert_equal(LONG_LINES[0], io.gets("\r\n"))
65
65
  assert_equal(LONG_LINES[1], io.gets("\r\n"))
66
66
  assert_equal(LONG_LINES[2], io.gets("\r\n"))
67
67
  end
68
68
 
69
- def test_getsWithSepAndIndex
69
+ def test_gets_with_sep_and_index
70
70
  io = TestAbstractInputStream.new(LONG_LINES.join)
71
71
  assert_equal('x', io.gets("\r\n", 1))
72
- assert_equal('x'*47 + "\r", io.gets("\r\n", 48))
72
+ assert_equal('x' * 47 + "\r", io.gets("\r\n", 48))
73
73
  assert_equal("\n", io.gets(nil, 1))
74
74
  assert_equal('yy', io.gets(nil, 2))
75
75
  end
76
76
 
77
- def test_getsWithIndex
77
+ def test_gets_with_index
78
78
  assert_equal(TEST_LINES[0], @io.gets(100))
79
79
  assert_equal('this', @io.gets(4))
80
80
  end
81
81
 
82
82
  def test_each_line
83
- lineNumber=0
84
- @io.each_line {
85
- |line|
83
+ lineNumber = 0
84
+ @io.each_line do |line|
86
85
  assert_equal(TEST_LINES[lineNumber], line)
87
- lineNumber+=1
88
- }
86
+ lineNumber += 1
87
+ end
89
88
  end
90
89
 
91
90
  def test_readlines
@@ -96,7 +95,7 @@ class AbstractInputStreamTest < MiniTest::Test
96
95
  test_gets
97
96
  begin
98
97
  @io.readline
99
- fail "EOFError expected"
98
+ fail 'EOFError expected'
100
99
  rescue EOFError
101
100
  end
102
101
  end
@@ -8,10 +8,10 @@ class AbstractOutputStreamTest < MiniTest::Test
8
8
  attr_accessor :buffer
9
9
 
10
10
  def initialize
11
- @buffer = ""
11
+ @buffer = ''
12
12
  end
13
13
 
14
- def << (data)
14
+ def <<(data)
15
15
  @buffer << data
16
16
  self
17
17
  end
@@ -30,77 +30,77 @@ class AbstractOutputStreamTest < MiniTest::Test
30
30
  end
31
31
 
32
32
  def test_write
33
- count = @output_stream.write("a little string")
34
- assert_equal("a little string", @output_stream.buffer)
35
- assert_equal("a little string".length, count)
33
+ count = @output_stream.write('a little string')
34
+ assert_equal('a little string', @output_stream.buffer)
35
+ assert_equal('a little string'.length, count)
36
36
 
37
- count = @output_stream.write(". a little more")
38
- assert_equal("a little string. a little more", @output_stream.buffer)
39
- assert_equal(". a little more".length, count)
37
+ count = @output_stream.write('. a little more')
38
+ assert_equal('a little string. a little more', @output_stream.buffer)
39
+ assert_equal('. a little more'.length, count)
40
40
  end
41
41
 
42
42
  def test_print
43
43
  $\ = nil # record separator set to nil
44
- @output_stream.print("hello")
45
- assert_equal("hello", @output_stream.buffer)
44
+ @output_stream.print('hello')
45
+ assert_equal('hello', @output_stream.buffer)
46
46
 
47
- @output_stream.print(" world.")
48
- assert_equal("hello world.", @output_stream.buffer)
47
+ @output_stream.print(' world.')
48
+ assert_equal('hello world.', @output_stream.buffer)
49
49
 
50
- @output_stream.print(" You ok ", "out ", "there?")
51
- assert_equal("hello world. You ok out there?", @output_stream.buffer)
50
+ @output_stream.print(' You ok ', 'out ', 'there?')
51
+ assert_equal('hello world. You ok out there?', @output_stream.buffer)
52
52
 
53
53
  $\ = "\n"
54
54
  @output_stream.print
55
55
  assert_equal("hello world. You ok out there?\n", @output_stream.buffer)
56
56
 
57
- @output_stream.print("I sure hope so!")
57
+ @output_stream.print('I sure hope so!')
58
58
  assert_equal("hello world. You ok out there?\nI sure hope so!\n", @output_stream.buffer)
59
59
 
60
- $, = "X"
61
- @output_stream.buffer = ""
62
- @output_stream.print("monkey", "duck", "zebra")
60
+ $, = 'X'
61
+ @output_stream.buffer = ''
62
+ @output_stream.print('monkey', 'duck', 'zebra')
63
63
  assert_equal("monkeyXduckXzebra\n", @output_stream.buffer)
64
64
 
65
65
  $\ = nil
66
- @output_stream.buffer = ""
66
+ @output_stream.buffer = ''
67
67
  @output_stream.print(20)
68
- assert_equal("20", @output_stream.buffer)
68
+ assert_equal('20', @output_stream.buffer)
69
69
  end
70
70
 
71
71
  def test_printf
72
- @output_stream.printf("%d %04x", 123, 123)
73
- assert_equal("123 007b", @output_stream.buffer)
72
+ @output_stream.printf('%d %04x', 123, 123)
73
+ assert_equal('123 007b', @output_stream.buffer)
74
74
  end
75
75
 
76
76
  def test_putc
77
- @output_stream.putc("A")
78
- assert_equal("A", @output_stream.buffer)
77
+ @output_stream.putc('A')
78
+ assert_equal('A', @output_stream.buffer)
79
79
  @output_stream.putc(65)
80
- assert_equal("AA", @output_stream.buffer)
80
+ assert_equal('AA', @output_stream.buffer)
81
81
  end
82
82
 
83
83
  def test_puts
84
84
  @output_stream.puts
85
85
  assert_equal("\n", @output_stream.buffer)
86
86
 
87
- @output_stream.puts("hello", "world")
87
+ @output_stream.puts('hello', 'world')
88
88
  assert_equal("\nhello\nworld\n", @output_stream.buffer)
89
89
 
90
- @output_stream.buffer = ""
90
+ @output_stream.buffer = ''
91
91
  @output_stream.puts("hello\n", "world\n")
92
92
  assert_equal("hello\nworld\n", @output_stream.buffer)
93
93
 
94
- @output_stream.buffer = ""
95
- @output_stream.puts(["hello\n", "world\n"])
94
+ @output_stream.buffer = ''
95
+ @output_stream.puts(%W[hello\n world\n])
96
96
  assert_equal("hello\nworld\n", @output_stream.buffer)
97
97
 
98
- @output_stream.buffer = ""
99
- @output_stream.puts(["hello\n", "world\n"], "bingo")
98
+ @output_stream.buffer = ''
99
+ @output_stream.puts(%W[hello\n world\n], 'bingo')
100
100
  assert_equal("hello\nworld\nbingo\n", @output_stream.buffer)
101
101
 
102
- @output_stream.buffer = ""
103
- @output_stream.puts(16, 20, 50, "hello")
102
+ @output_stream.buffer = ''
103
+ @output_stream.puts(16, 20, 50, 'hello')
104
104
  assert_equal("16\n20\n50\nhello\n", @output_stream.buffer)
105
105
  end
106
106
  end
@@ -12,7 +12,7 @@ class FakeIOTest < MiniTest::Test
12
12
  assert(obj.kind_of?(Object))
13
13
  assert(obj.kind_of?(FakeIOUsingClass))
14
14
  assert(obj.kind_of?(IO))
15
- assert(!obj.kind_of?(Fixnum))
15
+ assert(!obj.kind_of?(Integer))
16
16
  assert(!obj.kind_of?(String))
17
17
  end
18
18
  end
@@ -1,7 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class ZipLocalEntryTest < MiniTest::Test
4
-
5
4
  CEH_FILE = 'test/data/generated/centralEntryHeader.bin'
6
5
  LEH_FILE = 'test/data/generated/localEntryHeader.bin'
7
6
 
@@ -9,8 +8,8 @@ class ZipLocalEntryTest < MiniTest::Test
9
8
  ::Zip.write_zip64_support = false
10
9
  end
11
10
 
12
- def test_read_local_entryHeaderOfFirstTestZipEntry
13
- ::File.open(TestZipFile::TEST_ZIP3.zip_name, "rb") do |file|
11
+ def test_read_local_entry_header_of_first_test_zip_entry
12
+ ::File.open(TestZipFile::TEST_ZIP3.zip_name, 'rb') do |file|
14
13
  entry = ::Zip::Entry.read_local_entry(file)
15
14
 
16
15
  assert_equal('', entry.comment)
@@ -27,35 +26,33 @@ class ZipLocalEntryTest < MiniTest::Test
27
26
  end
28
27
  end
29
28
 
30
- def test_readDateTime
31
- ::File.open("test/data/rubycode.zip", "rb") {
32
- |file|
29
+ def test_read_date_time
30
+ ::File.open('test/data/rubycode.zip', 'rb') do |file|
33
31
  entry = ::Zip::Entry.read_local_entry(file)
34
- assert_equal("zippedruby1.rb", entry.name)
35
- assert_equal(::Zip::DOSTime.at(1019261638), entry.time)
36
- }
32
+ assert_equal('zippedruby1.rb', entry.name)
33
+ assert_equal(::Zip::DOSTime.at(1_019_261_638), entry.time)
34
+ end
37
35
  end
38
36
 
39
- def test_read_local_entryFromNonZipFile
40
- ::File.open("test/data/file2.txt") {
41
- |file|
42
- assert_equal(nil, ::Zip::Entry.read_local_entry(file))
43
- }
37
+ def test_read_local_entry_from_non_zip_file
38
+ ::File.open('test/data/file2.txt') do |file|
39
+ assert_nil(::Zip::Entry.read_local_entry(file))
40
+ end
44
41
  end
45
42
 
46
- def test_read_local_entryFromTruncatedZipFile
47
- zipFragment=""
43
+ def test_read_local_entry_from_truncated_zip_file
44
+ zipFragment = ''
48
45
  ::File.open(TestZipFile::TEST_ZIP2.zip_name) { |f| zipFragment = f.read(12) } # local header is at least 30 bytes
49
46
  zipFragment.extend(IOizeString).reset
50
47
  entry = ::Zip::Entry.new
51
48
  entry.read_local_entry(zipFragment)
52
- fail "ZipError expected"
49
+ fail 'ZipError expected'
53
50
  rescue ::Zip::Error
54
51
  end
55
52
 
56
- def test_writeEntry
57
- entry = ::Zip::Entry.new("file.zip", "entryName", "my little comment",
58
- "thisIsSomeExtraInformation", 100, 987654,
53
+ def test_write_entry
54
+ entry = ::Zip::Entry.new('file.zip', 'entryName', 'my little comment',
55
+ 'thisIsSomeExtraInformation', 100, 987_654,
59
56
  ::Zip::Entry::DEFLATED, 400)
60
57
  write_to_file(LEH_FILE, CEH_FILE, entry)
61
58
  entryReadLocal, entryReadCentral = read_from_file(LEH_FILE, CEH_FILE)
@@ -64,10 +61,10 @@ class ZipLocalEntryTest < MiniTest::Test
64
61
  compare_c_dir_entry_headers(entry, entryReadCentral)
65
62
  end
66
63
 
67
- def test_writeEntryWithZip64
64
+ def test_write_entry_with_zip64
68
65
  ::Zip.write_zip64_support = true
69
- entry = ::Zip::Entry.new("file.zip", "entryName", "my little comment",
70
- "thisIsSomeExtraInformation", 100, 987654,
66
+ entry = ::Zip::Entry.new('file.zip', 'entryName', 'my little comment',
67
+ 'thisIsSomeExtraInformation', 100, 987_654,
71
68
  ::Zip::Entry::DEFLATED, 400)
72
69
  write_to_file(LEH_FILE, CEH_FILE, entry)
73
70
  entryReadLocal, entryReadCentral = read_from_file(LEH_FILE, CEH_FILE)
@@ -78,10 +75,10 @@ class ZipLocalEntryTest < MiniTest::Test
78
75
  compare_c_dir_entry_headers(entry, entryReadCentral)
79
76
  end
80
77
 
81
- def test_write64Entry
78
+ def test_write_64entry
82
79
  ::Zip.write_zip64_support = true
83
- entry = ::Zip::Entry.new("bigfile.zip", "entryName", "my little equine",
84
- "malformed extra field because why not",
80
+ entry = ::Zip::Entry.new('bigfile.zip', 'entryName', 'my little equine',
81
+ 'malformed extra field because why not',
85
82
  0x7766554433221100, 0xDEADBEEF, ::Zip::Entry::DEFLATED,
86
83
  0x9988776655443322)
87
84
  write_to_file(LEH_FILE, CEH_FILE, entry)
@@ -90,12 +87,12 @@ class ZipLocalEntryTest < MiniTest::Test
90
87
  compare_c_dir_entry_headers(entry, entryReadCentral)
91
88
  end
92
89
 
93
- def test_rewriteLocalHeader64
90
+ def test_rewrite_local_header64
94
91
  ::Zip.write_zip64_support = true
95
92
  buf1 = StringIO.new
96
- entry = ::Zip::Entry.new("file.zip", "entryName")
93
+ entry = ::Zip::Entry.new('file.zip', 'entryName')
97
94
  entry.write_local_entry(buf1)
98
- assert(entry.extra['Zip64'].nil?, "zip64 extra is unnecessarily present")
95
+ assert(entry.extra['Zip64'].nil?, 'zip64 extra is unnecessarily present')
99
96
 
100
97
  buf2 = StringIO.new
101
98
  entry.size = 0x123456789ABCDEF0
@@ -106,18 +103,18 @@ class ZipLocalEntryTest < MiniTest::Test
106
103
  assert_equal(buf1.size, buf2.size) # it can't grow, or we'd clobber file data
107
104
  end
108
105
 
109
- def test_readLocalOffset
110
- entry = ::Zip::Entry.new("file.zip", "entryName")
111
- entry.local_header_offset = 12345
106
+ def test_read_local_offset
107
+ entry = ::Zip::Entry.new('file.zip', 'entryName')
108
+ entry.local_header_offset = 12_345
112
109
  ::File.open(CEH_FILE, 'wb') { |f| entry.write_c_dir_entry(f) }
113
110
  read_entry = nil
114
111
  ::File.open(CEH_FILE, 'rb') { |f| read_entry = ::Zip::Entry.read_c_dir_entry(f) }
115
112
  compare_c_dir_entry_headers(entry, read_entry)
116
113
  end
117
114
 
118
- def test_read64LocalOffset
115
+ def test_read64_local_offset
119
116
  ::Zip.write_zip64_support = true
120
- entry = ::Zip::Entry.new("file.zip", "entryName")
117
+ entry = ::Zip::Entry.new('file.zip', 'entryName')
121
118
  entry.local_header_offset = 0x0123456789ABCDEF
122
119
  ::File.open(CEH_FILE, 'wb') { |f| entry.write_c_dir_entry(f) }
123
120
  read_entry = nil
@@ -126,6 +123,7 @@ class ZipLocalEntryTest < MiniTest::Test
126
123
  end
127
124
 
128
125
  private
126
+
129
127
  def compare_local_entry_headers(entry1, entry2)
130
128
  assert_equal(entry1.compressed_size, entry2.compressed_size)
131
129
  assert_equal(entry1.crc, entry2.crc)
@@ -142,15 +140,15 @@ class ZipLocalEntryTest < MiniTest::Test
142
140
  end
143
141
 
144
142
  def write_to_file(localFileName, centralFileName, entry)
145
- ::File.open(localFileName, "wb") { |f| entry.write_local_entry(f) }
146
- ::File.open(centralFileName, "wb") { |f| entry.write_c_dir_entry(f) }
143
+ ::File.open(localFileName, 'wb') { |f| entry.write_local_entry(f) }
144
+ ::File.open(centralFileName, 'wb') { |f| entry.write_c_dir_entry(f) }
147
145
  end
148
146
 
149
147
  def read_from_file(localFileName, centralFileName)
150
148
  localEntry = nil
151
149
  cdirEntry = nil
152
- ::File.open(localFileName, "rb") { |f| localEntry = ::Zip::Entry.read_local_entry(f) }
153
- ::File.open(centralFileName, "rb") { |f| cdirEntry = ::Zip::Entry.read_c_dir_entry(f) }
150
+ ::File.open(localFileName, 'rb') { |f| localEntry = ::Zip::Entry.read_local_entry(f) }
151
+ ::File.open(centralFileName, 'rb') { |f| cdirEntry = ::Zip::Entry.read_c_dir_entry(f) }
154
152
  [localEntry, cdirEntry]
155
153
  end
156
154
  end
@@ -4,7 +4,7 @@ class ZipOutputStreamTest < MiniTest::Test
4
4
  include AssertEntry
5
5
 
6
6
  TEST_ZIP = TestZipFile::TEST_ZIP2.clone
7
- TEST_ZIP.zip_name = "test/data/generated/output.zip"
7
+ TEST_ZIP.zip_name = 'test/data/generated/output.zip'
8
8
 
9
9
  def test_new
10
10
  zos = ::Zip::OutputStream.new(TEST_ZIP.zip_name)
@@ -47,13 +47,13 @@ class ZipOutputStreamTest < MiniTest::Test
47
47
  assert_test_zip_contents(TEST_ZIP)
48
48
  end
49
49
 
50
- def test_writingToClosedStream
51
- assert_i_o_error_in_closed_stream { |zos| zos << "hello world" }
52
- assert_i_o_error_in_closed_stream { |zos| zos.puts "hello world" }
53
- assert_i_o_error_in_closed_stream { |zos| zos.write "hello world" }
50
+ def test_writing_to_closed_stream
51
+ assert_i_o_error_in_closed_stream { |zos| zos << 'hello world' }
52
+ assert_i_o_error_in_closed_stream { |zos| zos.puts 'hello world' }
53
+ assert_i_o_error_in_closed_stream { |zos| zos.write 'hello world' }
54
54
  end
55
55
 
56
- def test_cannotOpenFile
56
+ def test_cannot_open_file
57
57
  name = TestFiles::EMPTY_TEST_DIR
58
58
  begin
59
59
  ::Zip::OutputStream.open(name)
@@ -66,9 +66,9 @@ class ZipOutputStreamTest < MiniTest::Test
66
66
  end
67
67
 
68
68
  def test_put_next_entry
69
- stored_text = "hello world in stored text"
70
- entry_name = "file1"
71
- comment = "my comment"
69
+ stored_text = 'hello world in stored text'
70
+ entry_name = 'file1'
71
+ comment = 'my comment'
72
72
  ::Zip::OutputStream.open(TEST_ZIP.zip_name) do |zos|
73
73
  zos.put_next_entry(entry_name, comment, nil, ::Zip::Entry::STORED)
74
74
  zos << stored_text
@@ -81,14 +81,14 @@ class ZipOutputStreamTest < MiniTest::Test
81
81
  end
82
82
 
83
83
  def test_put_next_entry_using_zip_entry_creates_entries_with_correct_timestamps
84
- file = ::File.open("test/data/file2.txt", "rb")
84
+ file = ::File.open('test/data/file2.txt', 'rb')
85
85
  ::Zip::OutputStream.open(TEST_ZIP.zip_name) do |zos|
86
- zip_entry = ::Zip::Entry.new(zos, file.path, "", "", 0, 0, ::Zip::Entry::DEFLATED, 0, ::Zip::DOSTime.at(file.mtime))
86
+ zip_entry = ::Zip::Entry.new(zos, file.path, '', '', 0, 0, ::Zip::Entry::DEFLATED, 0, ::Zip::DOSTime.at(file.mtime))
87
87
  zos.put_next_entry(zip_entry)
88
88
  zos << file.read
89
89
  end
90
90
 
91
- ::Zip::InputStream::open(TEST_ZIP.zip_name) do |io|
91
+ ::Zip::InputStream.open(TEST_ZIP.zip_name) do |io|
92
92
  while (entry = io.get_next_entry)
93
93
  assert(::Zip::DOSTime.at(file.mtime).dos_equals(::Zip::DOSTime.at(entry.mtime))) # Compare DOS Times, since they are stored with two seconds accuracy
94
94
  end
@@ -96,10 +96,10 @@ class ZipOutputStreamTest < MiniTest::Test
96
96
  end
97
97
 
98
98
  def test_chained_put_into_next_entry
99
- stored_text = "hello world in stored text"
100
- stored_text2 = "with chain"
101
- entry_name = "file1"
102
- comment = "my comment"
99
+ stored_text = 'hello world in stored text'
100
+ stored_text2 = 'with chain'
101
+ entry_name = 'file1'
102
+ comment = 'my comment'
103
103
  ::Zip::OutputStream.open(TEST_ZIP.zip_name) do |zos|
104
104
  zos.put_next_entry(entry_name, comment, nil, ::Zip::Entry::STORED)
105
105
  zos << stored_text << stored_text2
@@ -109,21 +109,20 @@ class ZipOutputStreamTest < MiniTest::Test
109
109
  ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
110
110
  assert_equal(stored_text + stored_text2, zf.read(entry_name))
111
111
  end
112
-
113
112
  end
114
113
 
115
114
  def assert_i_o_error_in_closed_stream
116
- assert_raises(IOError) {
117
- zos = ::Zip::OutputStream.new("test/data/generated/test_putOnClosedStream.zip")
115
+ assert_raises(IOError) do
116
+ zos = ::Zip::OutputStream.new('test/data/generated/test_putOnClosedStream.zip')
118
117
  zos.close
119
118
  yield zos
120
- }
119
+ end
121
120
  end
122
121
 
123
122
  def write_test_zip(zos)
124
123
  TEST_ZIP.entry_names.each do |entryName|
125
124
  zos.put_next_entry(entryName)
126
- File.open(entryName, "rb") { |f| zos.write(f.read) }
125
+ File.open(entryName, 'rb') { |f| zos.write(f.read) }
127
126
  end
128
127
  end
129
128
  end