rubyzip 1.2.0 → 1.2.1

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4af5fd26173e16759a74f190b293f84cc02d605b
4
- data.tar.gz: 05666235e929fdb9bd6abe6807d3bf9583e65244
3
+ metadata.gz: 1b7ea085db9b27be420d541113214a73ee044c9f
4
+ data.tar.gz: ea28ff723bfd70f2e6f7a02f4fe28b805aa4a47e
5
5
  SHA512:
6
- metadata.gz: 2f4b82040f81e517ddb65660bea4a3368ec5e150bd094051d0ae3a515184c2eef55e32bcf5f49877bd432b3331a809402977e1c4b2a045695c8d2f45ab86f43c
7
- data.tar.gz: 31fdb0e8c66d737d341161d02faf343786d0a0d1beca058cff4532886a2cfe268b738c6307b042c22a3186909953cd6879656a7660ef607eea906f407f1aada1
6
+ metadata.gz: 121d7129aa37b72da82b32882401b7837c9cface1edf1b8bfb911cd20a55b2ecdacd308de9b7ed0cb6bc0b45d9d974faf28826efe191ddc36d3eb8431f8fe6f0
7
+ data.tar.gz: b1ef9770bcd133de33f61642665d511a11aff21aba880cf1226df0c8e1b3602833679384d76bf6877b19567406f7bd9a60de8bd78aded3f303660fbb80b31bb7
data/README.md CHANGED
@@ -62,20 +62,18 @@ end
62
62
  Copy from [here](https://github.com/rubyzip/rubyzip/blob/05916bf89181e1955118fd3ea059f18acac28cc8/samples/example_recursive.rb )
63
63
 
64
64
  ```ruby
65
- require 'rubygems'
66
65
  require 'zip'
66
+
67
67
  # This is a simple example which uses rubyzip to
68
68
  # recursively generate a zip file from the contents of
69
69
  # a specified directory. The directory itself is not
70
70
  # included in the archive, rather just its contents.
71
71
  #
72
72
  # Usage:
73
- # require /path/to/the/ZipFileGenerator/Class
74
- # directoryToZip = "/tmp/input"
75
- # outputFile = "/tmp/out.zip"
76
- # zf = ZipFileGenerator.new(directoryToZip, outputFile)
77
- # zf.write()
78
-
73
+ # directory_to_zip = "/tmp/input"
74
+ # output_file = "/tmp/out.zip"
75
+ # zf = ZipFileGenerator.new(directory_to_zip, output_file)
76
+ # zf.write()
79
77
  class ZipFileGenerator
80
78
  # Initialize with the directory to zip and the location of the output archive.
81
79
  def initialize(input_dir, output_file)
@@ -117,7 +115,7 @@ class ZipFileGenerator
117
115
 
118
116
  def put_into_archive(disk_file_path, io, zip_file_path)
119
117
  io.get_output_stream(zip_file_path) do |f|
120
- f.puts(File.open(disk_file_path, 'rb').read)
118
+ f.write(File.open(disk_file_path, 'rb').read)
121
119
  end
122
120
  end
123
121
  end
@@ -218,7 +216,7 @@ buffer = Zip::OutputStream.write_buffer do |out|
218
216
  out.write rels.to_xml(:indent => 0).gsub("\n","")
219
217
  end
220
218
 
221
- File.open(new_path, "w") {|f| f.write(buffer.string) }
219
+ File.open(new_path, "wb") {|f| f.write(buffer.string) }
222
220
  ```
223
221
 
224
222
  ## Configuration
@@ -7,6 +7,7 @@ module Zip
7
7
 
8
8
  attr_accessor :comment, :compressed_size, :crc, :extra, :compression_method,
9
9
  :name, :size, :local_header_offset, :zipfile, :fstype, :external_file_attributes,
10
+ :internal_file_attributes,
10
11
  :gp_flags, :header_signature, :follow_symlinks,
11
12
  :restore_times, :restore_permissions, :restore_ownership,
12
13
  :unix_uid, :unix_gid, :unix_perms,
@@ -149,6 +150,11 @@ module Zip
149
150
  def extract(dest_path = @name, &block)
150
151
  block ||= proc { ::Zip.on_exists_proc }
151
152
 
153
+ if @name.squeeze('/') =~ /\.{2}(?:\/|\z)/
154
+ puts "WARNING: skipped \"../\" path component(s) in #{@name}"
155
+ return self
156
+ end
157
+
152
158
  if directory? || file? || symlink?
153
159
  __send__("create_#{@ftype}", dest_path, &block)
154
160
  else
@@ -357,7 +363,7 @@ module Zip
357
363
  unpack_c_dir_entry(static_sized_fields_buf)
358
364
  check_c_dir_entry_signature
359
365
  set_time(@last_mod_date, @last_mod_time)
360
- @name = io.read(@name_length).tr('\\', '/')
366
+ @name = io.read(@name_length)
361
367
  read_c_dir_extra_field(io)
362
368
  @comment = io.read(@comment_length)
363
369
  check_c_dir_entry_comment_size
@@ -57,7 +57,7 @@ module Zip
57
57
  @entry_set[to_key(entry.parent_as_string)]
58
58
  end
59
59
 
60
- def glob(pattern, flags = ::File::FNM_PATHNAME | ::File::FNM_DOTMATCH)
60
+ def glob(pattern, flags = ::File::FNM_PATHNAME | ::File::FNM_DOTMATCH | ::File::FNM_EXTGLOB)
61
61
  entries.map do |entry|
62
62
  next nil unless ::File.fnmatch(pattern, entry.name.chomp('/'), flags)
63
63
  yield(entry) if block_given?
@@ -43,7 +43,7 @@ module Zip
43
43
  # interface for accessing the filesystem, ie. the File and Dir classes.
44
44
 
45
45
  class File < CentralDirectory
46
- CREATE = 1
46
+ CREATE = true
47
47
  SPLIT_SIGNATURE = 0x08074b50
48
48
  ZIP64_EOCD_SIGNATURE = 0x06064b50
49
49
  MAX_SEGMENT_SIZE = 3_221_225_472
@@ -64,20 +64,19 @@ module Zip
64
64
 
65
65
  # Opens a zip archive. Pass true as the second parameter to create
66
66
  # a new archive if it doesn't exist already.
67
- def initialize(file_name, create = nil, buffer = false, options = {})
67
+ def initialize(file_name, create = false, buffer = false, options = {})
68
68
  super()
69
69
  @name = file_name
70
70
  @comment = ''
71
- @create = create
71
+ @create = create ? true : false # allow any truthy value to mean true
72
72
  case
73
73
  when !buffer && ::File.size?(file_name)
74
- @create = nil
74
+ @create = false
75
75
  @file_permissions = ::File.stat(file_name).mode
76
76
  ::File.open(name, 'rb') do |f|
77
77
  read_from_stream(f)
78
78
  end
79
- when create
80
- @file_permissions = create_file_permissions
79
+ when @create
81
80
  @entry_set = EntrySet.new
82
81
  when ::File.zero?(file_name)
83
82
  raise Error, "File #{file_name} has zero size. Did you mean to pass the create flag?"
@@ -95,7 +94,7 @@ module Zip
95
94
  # Same as #new. If a block is passed the ZipFile object is passed
96
95
  # to the block and is automatically closed afterwards just as with
97
96
  # ruby's builtin File.open method.
98
- def open(file_name, create = nil)
97
+ def open(file_name, create = false)
99
98
  zf = ::Zip::File.new(file_name, create)
100
99
  return zf unless block_given?
101
100
  begin
@@ -130,6 +129,7 @@ module Zip
130
129
  end
131
130
  zf = ::Zip::File.new(io, true, true, options)
132
131
  zf.read_from_stream(io)
132
+ return zf unless block_given?
133
133
  yield zf
134
134
  begin
135
135
  zf.write_buffer(io)
@@ -340,7 +340,7 @@ module Zip
340
340
  @entry_set.each do |e|
341
341
  return true if e.dirty
342
342
  end
343
- @comment != @stored_comment || @entry_set != @stored_entries || @create == ::Zip::File::CREATE
343
+ @comment != @stored_comment || @entry_set != @stored_entries || @create
344
344
  end
345
345
 
346
346
  # Searches for entry with the specified name. Returns nil if
@@ -403,27 +403,18 @@ module Zip
403
403
  end
404
404
 
405
405
  def on_success_replace
406
- tmp_filename = create_tmpname
407
- if yield tmp_filename
408
- ::File.rename(tmp_filename, name)
409
- ::File.chmod(@file_permissions, name) if defined?(@file_permissions)
410
- end
411
- ensure
412
- ::File.unlink(tmp_filename) if ::File.exist?(tmp_filename)
413
- end
414
-
415
- def create_tmpname
416
406
  dirname, basename = ::File.split(name)
417
- ::Dir::Tmpname.create(basename, dirname) do |tmpname|
418
- opts = {perm: 0600, mode: ::File::CREAT | ::File::WRONLY | ::File::EXCL}
419
- f = File.open(tmpname, opts)
420
- f.close
407
+ ::Dir::Tmpname.create(basename, dirname) do |tmp_filename|
408
+ begin
409
+ if yield tmp_filename
410
+ ::File.rename(tmp_filename, name)
411
+ ::File.chmod(@file_permissions, name) unless @create
412
+ end
413
+ ensure
414
+ ::File.unlink(tmp_filename) if ::File.exist?(tmp_filename)
415
+ end
421
416
  end
422
417
  end
423
-
424
- def create_file_permissions
425
- ::Zip::RUNNING_ON_WINDOWS ? 0644 : 0666 - ::File.umask
426
- end
427
418
  end
428
419
  end
429
420
 
@@ -20,12 +20,12 @@ module Zip
20
20
 
21
21
  def putc(an_object)
22
22
  self << case an_object
23
- when Fixnum
23
+ when Integer
24
24
  an_object.chr
25
25
  when String
26
26
  an_object
27
27
  else
28
- raise TypeError, 'putc: Only Fixnum and String supported'
28
+ raise TypeError, 'putc: Only Integer and String supported'
29
29
  end
30
30
  an_object
31
31
  end
@@ -1,3 +1,3 @@
1
1
  module Zip
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
@@ -6,7 +6,7 @@ require 'zip'
6
6
  # included in the archive, rather just its contents.
7
7
  #
8
8
  # Usage:
9
- # directoryToZip = "/tmp/input"
9
+ # directory_to_zip = "/tmp/input"
10
10
  # output_file = "/tmp/out.zip"
11
11
  # zf = ZipFileGenerator.new(directory_to_zip, output_file)
12
12
  # zf.write()
@@ -50,8 +50,6 @@ class ZipFileGenerator
50
50
  end
51
51
 
52
52
  def put_into_archive(disk_file_path, io, zip_file_path)
53
- io.get_output_stream(zip_file_path) do |f|
54
- f.write(File.open(disk_file_path, 'rb').read)
55
- end
53
+ io.add(zip_file_path, disk_file_path)
56
54
  end
57
55
  end
@@ -37,7 +37,7 @@ class ZipCentralDirectoryEntryTest < MiniTest::Test
37
37
  assert_equal('', entry.comment)
38
38
 
39
39
  entry = ::Zip::Entry.read_c_dir_entry(file)
40
- assert_equal(nil, entry)
40
+ assert_nil(entry)
41
41
  # Fields that are not check by this test:
42
42
  # version made by 2 bytes
43
43
  # version needed to extract 2 bytes
@@ -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
@@ -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
@@ -76,7 +76,7 @@ class ZipEntrySetTest < MiniTest::Test
76
76
  ::Zip.case_insensitive_match = false
77
77
  zipEntrySet = ::Zip::EntrySet.new(entries)
78
78
  assert_equal(entries[0], zipEntrySet.find_entry('MiXeDcAsEnAmE'))
79
- assert_equal(nil, zipEntrySet.find_entry('mixedcasename'))
79
+ assert_nil(zipEntrySet.find_entry('mixedcasename'))
80
80
  end
81
81
 
82
82
  def test_entries_with_sort
@@ -123,7 +123,7 @@ class ZipEntrySetTest < MiniTest::Test
123
123
  ]
124
124
  entrySet = ::Zip::EntrySet.new(entries)
125
125
 
126
- assert_equal(nil, entrySet.parent(entries[0]))
126
+ assert_nil(entrySet.parent(entries[0]))
127
127
  assert_equal(entries[0], entrySet.parent(entries[1]))
128
128
  assert_equal(entries[1], entrySet.parent(entries[2]))
129
129
  end
@@ -149,4 +149,15 @@ class ZipEntrySetTest < MiniTest::Test
149
149
  # assert_equal(entries.size, res.size)
150
150
  # assert_equal(entrySet.map { |e| e.name }, res.map { |e| e.name })
151
151
  end
152
+
153
+ def test_glob3
154
+ entries = [
155
+ ::Zip::Entry.new('zf.zip', 'a/a'),
156
+ ::Zip::Entry.new('zf.zip', 'a/b'),
157
+ ::Zip::Entry.new('zf.zip', 'a/c')
158
+ ]
159
+ entrySet = ::Zip::EntrySet.new(entries)
160
+
161
+ assert_equal(entries[0, 2].sort, entrySet.glob('a/{a,b}').sort)
162
+ end
152
163
  end
@@ -1,16 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class ZipEntryTest < MiniTest::Test
4
- TEST_ZIPFILE = 'someZipFile.zip'
5
- TEST_COMMENT = 'a comment'
6
- TEST_COMPRESSED_SIZE = 1234
7
- TEST_CRC = 325_324
8
- TEST_EXTRA = 'Some data here'
9
- TEST_COMPRESSIONMETHOD = ::Zip::Entry::DEFLATED
10
- TEST_NAME = 'entry name'
11
- TEST_SIZE = 8432
12
- TEST_ISDIRECTORY = false
13
- TEST_TIME = Time.now
4
+ include ZipEntryData
14
5
 
15
6
  def test_constructor_and_getters
16
7
  entry = ::Zip::Entry.new(TEST_ZIPFILE,
@@ -118,8 +109,8 @@ class ZipEntryTest < MiniTest::Test
118
109
  entry5 = ::Zip::Entry.new('zf.zip', 'aa/bb/cc')
119
110
  entry6 = ::Zip::Entry.new('zf.zip', 'aa/bb/cc/')
120
111
 
121
- assert_equal(nil, entry1.parent_as_string)
122
- assert_equal(nil, entry2.parent_as_string)
112
+ assert_nil(entry1.parent_as_string)
113
+ assert_nil(entry2.parent_as_string)
123
114
  assert_equal('aa/', entry3.parent_as_string)
124
115
  assert_equal('aa/', entry4.parent_as_string)
125
116
  assert_equal('aa/bb/', entry5.parent_as_string)
@@ -2,58 +2,58 @@ require 'test_helper'
2
2
 
3
3
  class FilePermissionsTest < MiniTest::Test
4
4
 
5
- FILENAME = File.join(File.dirname(__FILE__), "umask.zip")
5
+ ZIPNAME = File.join(File.dirname(__FILE__), "umask.zip")
6
+ FILENAME = File.join(File.dirname(__FILE__), "umask.txt")
6
7
 
7
8
  def teardown
9
+ ::File.unlink(ZIPNAME)
8
10
  ::File.unlink(FILENAME)
9
11
  end
10
12
 
11
- if ::Zip::RUNNING_ON_WINDOWS
12
- # Windows tests
13
-
14
- DEFAULT_PERMS = 0644
15
-
16
- def test_windows_perms
17
- create_file
13
+ def test_current_umask
14
+ create_files
15
+ assert_matching_permissions FILENAME, ZIPNAME
16
+ end
18
17
 
19
- assert_equal DEFAULT_PERMS, ::File.stat(FILENAME).mode
18
+ def test_umask_000
19
+ set_umask(0000) do
20
+ create_files
20
21
  end
21
22
 
22
- else
23
- # Unix tests
24
-
25
- DEFAULT_PERMS = 0100666
26
-
27
- def test_current_umask
28
- umask = DEFAULT_PERMS - ::File.umask
29
- create_file
23
+ assert_matching_permissions FILENAME, ZIPNAME
24
+ end
30
25
 
31
- assert_equal umask, ::File.stat(FILENAME).mode
26
+ def test_umask_066
27
+ set_umask(0066) do
28
+ create_files
32
29
  end
33
30
 
34
- def test_umask_000
35
- set_umask(0000) do
36
- create_file
37
- end
31
+ assert_matching_permissions FILENAME, ZIPNAME
32
+ end
38
33
 
39
- assert_equal DEFAULT_PERMS, ::File.stat(FILENAME).mode
34
+ def test_umask_027
35
+ set_umask(0027) do
36
+ create_files
40
37
  end
41
38
 
42
- def test_umask_066
43
- umask = 0066
44
- set_umask(umask) do
45
- create_file
46
- end
47
-
48
- assert_equal((DEFAULT_PERMS - umask), ::File.stat(FILENAME).mode)
49
- end
39
+ assert_matching_permissions FILENAME, ZIPNAME
40
+ end
50
41
 
42
+ def assert_matching_permissions(expected_file, actual_file)
43
+ assert_equal(
44
+ ::File.stat(expected_file).mode.to_s(8).rjust(4, '0'),
45
+ ::File.stat(actual_file).mode.to_s(8).rjust(4, '0')
46
+ )
51
47
  end
52
48
 
53
- def create_file
54
- ::Zip::File.open(FILENAME, ::Zip::File::CREATE) do |zip|
49
+ def create_files
50
+ ::Zip::File.open(ZIPNAME, ::Zip::File::CREATE) do |zip|
55
51
  zip.comment = "test"
56
52
  end
53
+
54
+ ::File.open(FILENAME, 'w') do |file|
55
+ file << 'test'
56
+ end
57
57
  end
58
58
 
59
59
  # If anything goes wrong, make sure the umask is restored.
@@ -2,6 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class ZipFileTest < MiniTest::Test
4
4
  include CommonZipFileFixture
5
+ include ZipEntryData
5
6
 
6
7
  OK_DELETE_FILE = 'test/data/generated/okToDelete.txt'
7
8
  OK_DELETE_MOVED_FILE = 'test/data/generated/okToDeleteMoved.txt'
@@ -40,6 +41,20 @@ class ZipFileTest < MiniTest::Test
40
41
  assert_equal(2, zfRead.entries.length)
41
42
  end
42
43
 
44
+ def test_create_from_scratch_with_old_create_parameter
45
+ comment = 'a short comment'
46
+
47
+ zf = ::Zip::File.new(EMPTY_FILENAME, 1)
48
+ zf.get_output_stream('myFile') { |os| os.write 'myFile contains just this' }
49
+ zf.mkdir('dir1')
50
+ zf.comment = comment
51
+ zf.close
52
+
53
+ zfRead = ::Zip::File.new(EMPTY_FILENAME)
54
+ assert_equal(comment, zfRead.comment)
55
+ assert_equal(2, zfRead.entries.length)
56
+ end
57
+
43
58
  def test_get_output_stream
44
59
  entryCount = nil
45
60
  ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
@@ -56,7 +71,7 @@ class ZipFileTest < MiniTest::Test
56
71
  assert_equal(entryCount + 1, zf.size)
57
72
  assert_equal('Putting stuff in data/generated/empty.txt', zf.read('test/data/generated/empty.txt'))
58
73
 
59
- custom_entry_args = [ZipEntryTest::TEST_COMMENT, ZipEntryTest::TEST_EXTRA, ZipEntryTest::TEST_COMPRESSED_SIZE, ZipEntryTest::TEST_CRC, ::Zip::Entry::STORED, ZipEntryTest::TEST_SIZE, ZipEntryTest::TEST_TIME]
74
+ custom_entry_args = [TEST_COMMENT, TEST_EXTRA, TEST_COMPRESSED_SIZE, TEST_CRC, ::Zip::Entry::STORED, TEST_SIZE, TEST_TIME]
60
75
  zf.get_output_stream('entry_with_custom_args.txt', nil, *custom_entry_args) do |os|
61
76
  os.write 'Some data'
62
77
  end
@@ -89,6 +104,12 @@ class ZipFileTest < MiniTest::Test
89
104
  end
90
105
  end
91
106
 
107
+ def test_open_buffer_without_block
108
+ string_io = StringIO.new File.read('test/data/rubycode.zip')
109
+ zf = ::Zip::File.open_buffer string_io
110
+ assert zf.entries.map { |e| e.name }.include?('zippedruby1.rb')
111
+ end
112
+
92
113
  def test_cleans_up_tempfiles_after_close
93
114
  zf = ::Zip::File.new(EMPTY_FILENAME, ::Zip::File::CREATE)
94
115
  zf.get_output_stream('myFile') do |os|
@@ -528,9 +549,8 @@ class ZipFileTest < MiniTest::Test
528
549
  end
529
550
 
530
551
  def test_empty_zip
531
- puts `touch empty.zip`
532
552
  assert_raises(::Zip::Error) do
533
- ::Zip::File.open('empty.zip')
553
+ ::Zip::File.open(TestFiles::NULL_FILE)
534
554
  end
535
555
  end
536
556
 
@@ -103,12 +103,12 @@ class ZipFsFileNonmutatingTest < MiniTest::Test
103
103
  end
104
104
 
105
105
  def test_size?
106
- assert_equal(nil, @zip_file.file.size?('notAFile'))
106
+ assert_nil(@zip_file.file.size?('notAFile'))
107
107
  assert_equal(72, @zip_file.file.size?('file1'))
108
- assert_equal(nil, @zip_file.file.size?('dir2/dir21'))
108
+ assert_nil(@zip_file.file.size?('dir2/dir21'))
109
109
 
110
110
  assert_equal(72, @zip_file.file.stat('file1').size?)
111
- assert_equal(nil, @zip_file.file.stat('dir2/dir21').size?)
111
+ assert_nil(@zip_file.file.stat('dir2/dir21').size?)
112
112
  end
113
113
 
114
114
  def test_file?
@@ -11,7 +11,7 @@ class ZipFsFileStatTest < MiniTest::Test
11
11
  end
12
12
 
13
13
  def test_blocks
14
- assert_equal(nil, @zip_file.file.stat('file1').blocks)
14
+ assert_nil(@zip_file.file.stat('file1').blocks)
15
15
  end
16
16
 
17
17
  def test_ino
@@ -9,6 +9,8 @@ class TestFiles
9
9
  RANDOM_BINARY_FILE1 = 'test/data/generated/randomBinary1.bin'
10
10
  RANDOM_BINARY_FILE2 = 'test/data/generated/randomBinary2.bin'
11
11
 
12
+ NULL_FILE = 'test/data/generated/null.zip' # Zero length, so not a zip file.
13
+
12
14
  EMPTY_TEST_DIR = 'test/data/generated/emptytestdir'
13
15
 
14
16
  ASCII_TEST_FILES = [RANDOM_ASCII_FILE1, RANDOM_ASCII_FILE2, RANDOM_ASCII_FILE3]
@@ -28,6 +30,8 @@ class TestFiles
28
30
  create_random_binary(filename, 1E4 * (index + 1))
29
31
  end
30
32
 
33
+ system("touch #{NULL_FILE}")
34
+
31
35
  ensure_dir(EMPTY_TEST_DIR)
32
36
  end
33
37
 
@@ -75,12 +75,12 @@ class ZipInputStreamTest < MiniTest::Test
75
75
  entry = zis.get_next_entry # empty.txt
76
76
  assert_equal(TestZipFile::TEST_ZIP2.entry_names[1], entry.name)
77
77
  assert_equal(0, entry.size)
78
- assert_equal(nil, zis.gets)
78
+ assert_nil(zis.gets)
79
79
  assert_equal(true, zis.eof?)
80
80
  entry = zis.get_next_entry # empty_chmod640.txt
81
81
  assert_equal(TestZipFile::TEST_ZIP2.entry_names[2], entry.name)
82
82
  assert_equal(0, entry.size)
83
- assert_equal(nil, zis.gets)
83
+ assert_nil(zis.gets)
84
84
  assert_equal(true, zis.eof?)
85
85
  entry = zis.get_next_entry # short.txt
86
86
  assert_equal(TestZipFile::TEST_ZIP2.entry_names[3], entry.name)
@@ -102,12 +102,12 @@ class ZipInputStreamTest < MiniTest::Test
102
102
  entry = zis.get_next_entry # empty.txt
103
103
  assert_equal(TestZipFile::TEST_ZIP2.entry_names[1], entry.name)
104
104
  assert_equal(0, entry.size)
105
- assert_equal(nil, zis.gets)
105
+ assert_nil(zis.gets)
106
106
  assert_equal(true, zis.eof?)
107
107
  entry = zis.get_next_entry # empty_chmod640.txt
108
108
  assert_equal(TestZipFile::TEST_ZIP2.entry_names[2], entry.name)
109
109
  assert_equal(0, entry.size)
110
- assert_equal(nil, zis.gets)
110
+ assert_nil(zis.gets)
111
111
  assert_equal(true, zis.eof?)
112
112
  entry = zis.get_next_entry # short.txt
113
113
  assert_equal(TestZipFile::TEST_ZIP2.entry_names[3], entry.name)
@@ -44,7 +44,7 @@ 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
 
@@ -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
@@ -36,7 +36,7 @@ class ZipLocalEntryTest < MiniTest::Test
36
36
 
37
37
  def test_read_local_entry_from_non_zip_file
38
38
  ::File.open('test/data/file2.txt') do |file|
39
- assert_equal(nil, ::Zip::Entry.read_local_entry(file))
39
+ assert_nil(::Zip::Entry.read_local_entry(file))
40
40
  end
41
41
  end
42
42
 
@@ -134,7 +134,7 @@ module AssertEntry
134
134
  testZipFile.entry_names.each do |entryName|
135
135
  assert_next_entry(entryName, zis)
136
136
  end
137
- assert_equal(nil, zis.get_next_entry)
137
+ assert_nil(zis.get_next_entry)
138
138
  end
139
139
 
140
140
  def assert_test_zip_contents(testZipFile)
@@ -219,3 +219,16 @@ module ExtraAssertions
219
219
  anObject.instance_eval "undef #{method}; alias #{method} #{method}_org"
220
220
  end
221
221
  end
222
+
223
+ module ZipEntryData
224
+ TEST_ZIPFILE = 'someZipFile.zip'
225
+ TEST_COMMENT = 'a comment'
226
+ TEST_COMPRESSED_SIZE = 1234
227
+ TEST_CRC = 325_324
228
+ TEST_EXTRA = 'Some data here'
229
+ TEST_COMPRESSIONMETHOD = ::Zip::Entry::DEFLATED
230
+ TEST_NAME = 'entry name'
231
+ TEST_SIZE = 8432
232
+ TEST_ISDIRECTORY = false
233
+ TEST_TIME = Time.now
234
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyzip
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Simonov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-19 00:00:00.000000000 Z
11
+ date: 2017-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  version: '0'
198
198
  requirements: []
199
199
  rubyforge_project:
200
- rubygems_version: 2.4.8
200
+ rubygems_version: 2.5.1
201
201
  signing_key:
202
202
  specification_version: 4
203
203
  summary: rubyzip is a ruby module for reading and writing zip files