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
@@ -2,9 +2,8 @@ require 'test_helper'
2
2
  require 'zip/filesystem'
3
3
 
4
4
  class ZipFsFileStatTest < MiniTest::Test
5
-
6
5
  def setup
7
- @zip_file = ::Zip::File.new("test/data/zipWithDirs.zip")
6
+ @zip_file = ::Zip::File.new('test/data/zipWithDirs.zip')
8
7
  end
9
8
 
10
9
  def teardown
@@ -12,55 +11,54 @@ class ZipFsFileStatTest < MiniTest::Test
12
11
  end
13
12
 
14
13
  def test_blocks
15
- assert_equal(nil, @zip_file.file.stat("file1").blocks)
14
+ assert_equal(nil, @zip_file.file.stat('file1').blocks)
16
15
  end
17
16
 
18
17
  def test_ino
19
- assert_equal(0, @zip_file.file.stat("file1").ino)
18
+ assert_equal(0, @zip_file.file.stat('file1').ino)
20
19
  end
21
20
 
22
21
  def test_uid
23
- assert_equal(0, @zip_file.file.stat("file1").uid)
22
+ assert_equal(0, @zip_file.file.stat('file1').uid)
24
23
  end
25
24
 
26
25
  def test_gid
27
- assert_equal(0, @zip_file.file.stat("file1").gid)
26
+ assert_equal(0, @zip_file.file.stat('file1').gid)
28
27
  end
29
28
 
30
29
  def test_ftype
31
- assert_equal("file", @zip_file.file.stat("file1").ftype)
32
- assert_equal("directory", @zip_file.file.stat("dir1").ftype)
30
+ assert_equal('file', @zip_file.file.stat('file1').ftype)
31
+ assert_equal('directory', @zip_file.file.stat('dir1').ftype)
33
32
  end
34
33
 
35
34
  def test_mode
36
- assert_equal(0600, @zip_file.file.stat("file1").mode & 0777)
37
- assert_equal(0600, @zip_file.file.stat("file1").mode & 0777)
38
- assert_equal(0755, @zip_file.file.stat("dir1").mode & 0777)
39
- assert_equal(0755, @zip_file.file.stat("dir1").mode & 0777)
35
+ assert_equal(0600, @zip_file.file.stat('file1').mode & 0777)
36
+ assert_equal(0600, @zip_file.file.stat('file1').mode & 0777)
37
+ assert_equal(0755, @zip_file.file.stat('dir1').mode & 0777)
38
+ assert_equal(0755, @zip_file.file.stat('dir1').mode & 0777)
40
39
  end
41
40
 
42
41
  def test_dev
43
- assert_equal(0, @zip_file.file.stat("file1").dev)
42
+ assert_equal(0, @zip_file.file.stat('file1').dev)
44
43
  end
45
44
 
46
45
  def test_rdev
47
- assert_equal(0, @zip_file.file.stat("file1").rdev)
46
+ assert_equal(0, @zip_file.file.stat('file1').rdev)
48
47
  end
49
48
 
50
49
  def test_rdev_major
51
- assert_equal(0, @zip_file.file.stat("file1").rdev_major)
50
+ assert_equal(0, @zip_file.file.stat('file1').rdev_major)
52
51
  end
53
52
 
54
53
  def test_rdev_minor
55
- assert_equal(0, @zip_file.file.stat("file1").rdev_minor)
54
+ assert_equal(0, @zip_file.file.stat('file1').rdev_minor)
56
55
  end
57
56
 
58
57
  def test_nlink
59
- assert_equal(1, @zip_file.file.stat("file1").nlink)
58
+ assert_equal(1, @zip_file.file.stat('file1').nlink)
60
59
  end
61
60
 
62
61
  def test_blksize
63
- assert_nil(@zip_file.file.stat("file1").blksize)
62
+ assert_nil(@zip_file.file.stat('file1').blksize)
64
63
  end
65
-
66
64
  end
@@ -3,13 +3,13 @@
3
3
  $VERBOSE = true
4
4
 
5
5
  class TestFiles
6
- RANDOM_ASCII_FILE1 = "test/data/generated/randomAscii1.txt"
7
- RANDOM_ASCII_FILE2 = "test/data/generated/randomAscii2.txt"
8
- RANDOM_ASCII_FILE3 = "test/data/generated/randomAscii3.txt"
9
- RANDOM_BINARY_FILE1 = "test/data/generated/randomBinary1.bin"
10
- RANDOM_BINARY_FILE2 = "test/data/generated/randomBinary2.bin"
6
+ RANDOM_ASCII_FILE1 = 'test/data/generated/randomAscii1.txt'
7
+ RANDOM_ASCII_FILE2 = 'test/data/generated/randomAscii2.txt'
8
+ RANDOM_ASCII_FILE3 = 'test/data/generated/randomAscii3.txt'
9
+ RANDOM_BINARY_FILE1 = 'test/data/generated/randomBinary1.bin'
10
+ RANDOM_BINARY_FILE2 = 'test/data/generated/randomBinary2.bin'
11
11
 
12
- EMPTY_TEST_DIR = "test/data/generated/emptytestdir"
12
+ EMPTY_TEST_DIR = 'test/data/generated/emptytestdir'
13
13
 
14
14
  ASCII_TEST_FILES = [RANDOM_ASCII_FILE1, RANDOM_ASCII_FILE2, RANDOM_ASCII_FILE3]
15
15
  BINARY_TEST_FILES = [RANDOM_BINARY_FILE1, RANDOM_BINARY_FILE2]
@@ -18,34 +18,30 @@ class TestFiles
18
18
 
19
19
  class << self
20
20
  def create_test_files
21
- Dir.mkdir "test/data/generated" unless Dir.exist?('test/data/generated')
21
+ Dir.mkdir 'test/data/generated' unless Dir.exist?('test/data/generated')
22
22
 
23
- ASCII_TEST_FILES.each_with_index do |filename, index|
24
- create_random_ascii(filename, 1E4 * (index+1))
25
- end
23
+ ASCII_TEST_FILES.each_with_index do |filename, index|
24
+ create_random_ascii(filename, 1E4 * (index + 1))
25
+ end
26
26
 
27
- BINARY_TEST_FILES.each_with_index do |filename, index|
28
- create_random_binary(filename, 1E4 * (index+1))
29
- end
27
+ BINARY_TEST_FILES.each_with_index do |filename, index|
28
+ create_random_binary(filename, 1E4 * (index + 1))
29
+ end
30
30
 
31
- ensure_dir(EMPTY_TEST_DIR)
31
+ ensure_dir(EMPTY_TEST_DIR)
32
32
  end
33
33
 
34
34
  private
35
35
 
36
36
  def create_random_ascii(filename, size)
37
- File.open(filename, "wb") do |file|
38
- while (file.tell < size)
39
- file << rand
40
- end
37
+ File.open(filename, 'wb') do |file|
38
+ file << rand while file.tell < size
41
39
  end
42
40
  end
43
41
 
44
42
  def create_random_binary(filename, size)
45
- File.open(filename, "wb") do |file|
46
- while (file.tell < size)
47
- file << [rand].pack("V")
48
- end
43
+ File.open(filename, 'wb') do |file|
44
+ file << [rand].pack('V') while file.tell < size
49
45
  end
50
46
  end
51
47
 
@@ -56,47 +52,41 @@ class TestFiles
56
52
  end
57
53
  Dir.mkdir(name)
58
54
  end
59
-
60
55
  end
61
56
  end
62
57
 
63
-
64
58
  # For representation and creation of
65
59
  # test data
66
60
  class TestZipFile
67
61
  attr_accessor :zip_name, :entry_names, :comment
68
62
 
69
- def initialize(zip_name, entry_names, comment = "")
70
- @zip_name=zip_name
71
- @entry_names=entry_names
63
+ def initialize(zip_name, entry_names, comment = '')
64
+ @zip_name = zip_name
65
+ @entry_names = entry_names
72
66
  @comment = comment
73
67
  end
74
68
 
75
- def TestZipFile.create_test_zips
69
+ def self.create_test_zips
76
70
  raise "failed to create test zip '#{TEST_ZIP1.zip_name}'" unless system("/usr/bin/zip #{TEST_ZIP1.zip_name} test/data/file2.txt")
77
71
  raise "failed to remove entry from '#{TEST_ZIP1.zip_name}'" unless system("/usr/bin/zip #{TEST_ZIP1.zip_name} -d test/data/file2.txt")
78
72
 
79
- File.open("test/data/generated/empty.txt", "w") {}
80
- File.open("test/data/generated/empty_chmod640.txt", "w") {}
81
- ::File.chmod(0640, "test/data/generated/empty_chmod640.txt")
73
+ File.open('test/data/generated/empty.txt', 'w') {}
74
+ File.open('test/data/generated/empty_chmod640.txt', 'w') {}
75
+ ::File.chmod(0640, 'test/data/generated/empty_chmod640.txt')
82
76
 
83
- File.open("test/data/generated/short.txt", "w") { |file| file << "ABCDEF" }
84
- ziptestTxt=""
85
- File.open("test/data/file2.txt") { |file| ziptestTxt=file.read }
86
- File.open("test/data/generated/longAscii.txt", "w") do |file|
87
- while (file.tell < 1E5)
88
- file << ziptestTxt
89
- end
77
+ File.open('test/data/generated/short.txt', 'w') { |file| file << 'ABCDEF' }
78
+ ziptestTxt = ''
79
+ File.open('test/data/file2.txt') { |file| ziptestTxt = file.read }
80
+ File.open('test/data/generated/longAscii.txt', 'w') do |file|
81
+ file << ziptestTxt while file.tell < 1E5
90
82
  end
91
83
 
92
- testBinaryPattern=""
93
- File.open("test/data/generated/empty.zip") { |file| testBinaryPattern=file.read }
84
+ testBinaryPattern = ''
85
+ File.open('test/data/generated/empty.zip') { |file| testBinaryPattern = file.read }
94
86
  testBinaryPattern *= 4
95
87
 
96
- File.open("test/data/generated/longBinary.bin", "wb") do |file|
97
- while (file.tell < 6E5)
98
- file << testBinaryPattern << rand << "\0"
99
- end
88
+ File.open('test/data/generated/longBinary.bin', 'wb') do |file|
89
+ file << testBinaryPattern << rand << "\0" while file.tell < 6E5
100
90
  end
101
91
 
102
92
  raise "failed to create test zip '#{TEST_ZIP2.zip_name}'" unless system("/usr/bin/zip #{TEST_ZIP2.zip_name} #{TEST_ZIP2.entry_names.join(' ')}")
@@ -118,17 +108,15 @@ class TestZipFile
118
108
  # http://stahlworks.com/dev/index.php?tool=zipunzip
119
109
  # that works with the above code
120
110
  raise $!.to_s +
121
- "\n\nziptest.rb requires the Info-ZIP program 'zip' in the path\n" +
122
- "to create test data. If you don't have it you can download\n" +
123
- "the necessary test files at http://sf.net/projects/rubyzip."
111
+ "\n\nziptest.rb requires the Info-ZIP program 'zip' in the path\n" \
112
+ "to create test data. If you don't have it you can download\n" \
113
+ 'the necessary test files at http://sf.net/projects/rubyzip.'
124
114
  end
125
115
 
126
- TEST_ZIP1 = TestZipFile.new("test/data/generated/empty.zip", [])
127
- TEST_ZIP2 = TestZipFile.new("test/data/generated/5entry.zip", %w{ test/data/generated/longAscii.txt test/data/generated/empty.txt test/data/generated/empty_chmod640.txt test/data/generated/short.txt test/data/generated/longBinary.bin},
128
- "my zip comment")
129
- TEST_ZIP3 = TestZipFile.new("test/data/generated/test1.zip", %w{ test/data/file1.txt })
130
- TEST_ZIP4 = TestZipFile.new("test/data/generated/zipWithDir.zip", ["test/data/file1.txt",
131
- TestFiles::EMPTY_TEST_DIR])
116
+ TEST_ZIP1 = TestZipFile.new('test/data/generated/empty.zip', [])
117
+ TEST_ZIP2 = TestZipFile.new('test/data/generated/5entry.zip', %w(test/data/generated/longAscii.txt test/data/generated/empty.txt test/data/generated/empty_chmod640.txt test/data/generated/short.txt test/data/generated/longBinary.bin),
118
+ 'my zip comment')
119
+ TEST_ZIP3 = TestZipFile.new('test/data/generated/test1.zip', %w(test/data/file1.txt))
120
+ TEST_ZIP4 = TestZipFile.new('test/data/generated/zipWithDir.zip', ['test/data/file1.txt',
121
+ TestFiles::EMPTY_TEST_DIR])
132
122
  end
133
-
134
-
@@ -4,7 +4,7 @@ class InflaterTest < MiniTest::Test
4
4
 
5
5
  def setup
6
6
  super
7
- @file = File.new("test/data/file1.txt.deflatedData", "rb")
7
+ @file = File.new('test/data/file1.txt.deflatedData', 'rb')
8
8
  @decompressor = ::Zip::Inflater.new(@file)
9
9
  end
10
10
 
@@ -3,6 +3,16 @@ require 'test_helper'
3
3
  class ZipInputStreamTest < MiniTest::Test
4
4
  include AssertEntry
5
5
 
6
+ class IOLike
7
+ extend Forwardable
8
+
9
+ def initialize(path, mode)
10
+ @file = File.new(path, mode)
11
+ end
12
+
13
+ delegate ::Zip::File::IO_METHODS => :@file
14
+ end
15
+
6
16
  def test_new
7
17
  zis = ::Zip::InputStream.new(TestZipFile::TEST_ZIP2.zip_name)
8
18
  assert_stream_contents(zis, TestZipFile::TEST_ZIP2)
@@ -10,21 +20,20 @@ class ZipInputStreamTest < MiniTest::Test
10
20
  zis.close
11
21
  end
12
22
 
13
- def test_openWithBlock
14
- ::Zip::InputStream.open(TestZipFile::TEST_ZIP2.zip_name) {
15
- |zis|
23
+ def test_open_with_block
24
+ ::Zip::InputStream.open(TestZipFile::TEST_ZIP2.zip_name) do |zis|
16
25
  assert_stream_contents(zis, TestZipFile::TEST_ZIP2)
17
26
  assert_equal(true, zis.eof?)
18
- }
27
+ end
19
28
  end
20
29
 
21
- def test_openWithoutBlock
22
- zis = ::Zip::InputStream.open(File.new(TestZipFile::TEST_ZIP2.zip_name, "rb"))
30
+ def test_open_without_block
31
+ zis = ::Zip::InputStream.open(File.new(TestZipFile::TEST_ZIP2.zip_name, 'rb'))
23
32
  assert_stream_contents(zis, TestZipFile::TEST_ZIP2)
24
33
  end
25
34
 
26
- def test_openBufferWithBlock
27
- ::Zip::InputStream.open(File.new(TestZipFile::TEST_ZIP2.zip_name, "rb")) do |zis|
35
+ def test_open_buffer_with_block
36
+ ::Zip::InputStream.open(File.new(TestZipFile::TEST_ZIP2.zip_name, 'rb')) do |zis|
28
37
  assert_stream_contents(zis, TestZipFile::TEST_ZIP2)
29
38
  assert_equal(true, zis.eof?)
30
39
  end
@@ -44,14 +53,20 @@ class ZipInputStreamTest < MiniTest::Test
44
53
  end
45
54
  end
46
55
 
47
- def test_openBufferWithoutBlock
56
+ def test_open_buffer_without_block
48
57
  zis = ::Zip::InputStream.open(TestZipFile::TEST_ZIP2.zip_name)
49
58
  assert_stream_contents(zis, TestZipFile::TEST_ZIP2)
50
59
  end
51
60
 
52
- def test_incompleteReads
53
- ::Zip::InputStream.open(TestZipFile::TEST_ZIP2.zip_name) {
54
- |zis|
61
+ def test_open_io_like_with_block
62
+ ::Zip::InputStream.open(IOLike.new(TestZipFile::TEST_ZIP2.zip_name, 'rb')) do |zis|
63
+ assert_stream_contents(zis, TestZipFile::TEST_ZIP2)
64
+ assert_equal(true, zis.eof?)
65
+ end
66
+ end
67
+
68
+ def test_incomplete_reads
69
+ ::Zip::InputStream.open(TestZipFile::TEST_ZIP2.zip_name) do |zis|
55
70
  entry = zis.get_next_entry # longAscii.txt
56
71
  assert_equal(false, zis.eof?)
57
72
  assert_equal(TestZipFile::TEST_ZIP2.entry_names[0], entry.name)
@@ -73,7 +88,7 @@ class ZipInputStreamTest < MiniTest::Test
73
88
  entry = zis.get_next_entry # longBinary.bin
74
89
  assert_equal(TestZipFile::TEST_ZIP2.entry_names[4], entry.name)
75
90
  assert zis.gets.length > 0
76
- }
91
+ end
77
92
  end
78
93
 
79
94
  def test_incomplete_reads_from_string_io
@@ -114,25 +129,24 @@ class ZipInputStreamTest < MiniTest::Test
114
129
  end
115
130
 
116
131
  def test_rewind
117
- ::Zip::InputStream.open(TestZipFile::TEST_ZIP2.zip_name) {
118
- |zis|
132
+ ::Zip::InputStream.open(TestZipFile::TEST_ZIP2.zip_name) do |zis|
119
133
  e = zis.get_next_entry
120
134
  assert_equal(TestZipFile::TEST_ZIP2.entry_names[0], e.name)
121
135
 
122
136
  # Do a little reading
123
- buf = ""
137
+ buf = ''
124
138
  buf << zis.read(100)
125
139
  assert_equal(100, zis.pos)
126
- buf << (zis.gets || "")
127
- buf << (zis.gets || "")
140
+ buf << (zis.gets || '')
141
+ buf << (zis.gets || '')
128
142
  assert_equal(false, zis.eof?)
129
143
 
130
144
  zis.rewind
131
145
 
132
- buf2 = ""
146
+ buf2 = ''
133
147
  buf2 << zis.read(100)
134
- buf2 << (zis.gets || "")
135
- buf2 << (zis.gets || "")
148
+ buf2 << (zis.gets || '')
149
+ buf2 << (zis.gets || '')
136
150
 
137
151
  assert_equal(buf, buf2)
138
152
 
@@ -141,20 +155,19 @@ class ZipInputStreamTest < MiniTest::Test
141
155
  assert_equal(0, zis.pos)
142
156
 
143
157
  assert_entry(e.name, zis, e.name)
144
- }
158
+ end
145
159
  end
146
160
 
147
161
  def test_mix_read_and_gets
148
- ::Zip::InputStream.open(TestZipFile::TEST_ZIP2.zip_name) {
149
- |zis|
162
+ ::Zip::InputStream.open(TestZipFile::TEST_ZIP2.zip_name) do |zis|
150
163
  zis.get_next_entry
151
- assert_equal("#!/usr/bin/env ruby", zis.gets.chomp)
164
+ assert_equal('#!/usr/bin/env ruby', zis.gets.chomp)
152
165
  assert_equal(false, zis.eof?)
153
- assert_equal("", zis.gets.chomp)
166
+ assert_equal('', zis.gets.chomp)
154
167
  assert_equal(false, zis.eof?)
155
- assert_equal("$VERBOSE =", zis.read(10))
168
+ assert_equal('$VERBOSE =', zis.read(10))
156
169
  assert_equal(false, zis.eof?)
157
- }
170
+ end
158
171
  end
159
172
 
160
173
  def test_ungetc
@@ -163,8 +176,7 @@ class ZipInputStreamTest < MiniTest::Test
163
176
  first_line = zis.gets.chomp
164
177
  first_line.reverse.bytes.each { |b| zis.ungetc(b) }
165
178
  assert_equal('#!/usr/bin/env ruby', zis.gets.chomp)
166
- assert_equal("$VERBOSE =", zis.read(10))
179
+ assert_equal('$VERBOSE =', zis.read(10))
167
180
  end
168
181
  end
169
-
170
182
  end
@@ -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
 
@@ -48,44 +48,43 @@ class AbstractInputStreamTest < MiniTest::Test
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