rubyzip 2.3.2 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +549 -0
  3. data/LICENSE.md +24 -0
  4. data/README.md +263 -49
  5. data/Rakefile +15 -13
  6. data/lib/rubyzip.rb +3 -0
  7. data/lib/zip/central_directory.rb +194 -125
  8. data/lib/zip/compressor.rb +3 -1
  9. data/lib/zip/constants.rb +30 -21
  10. data/lib/zip/crypto/aes_encryption.rb +213 -0
  11. data/lib/zip/crypto/decrypted_io.rb +27 -15
  12. data/lib/zip/crypto/encryption.rb +13 -2
  13. data/lib/zip/crypto/null_encryption.rb +5 -13
  14. data/lib/zip/crypto/traditional_encryption.rb +13 -7
  15. data/lib/zip/decompressor.rb +4 -3
  16. data/lib/zip/deflater.rb +12 -8
  17. data/lib/zip/dirtyable.rb +32 -0
  18. data/lib/zip/dos_time.rb +72 -7
  19. data/lib/zip/entry.rb +445 -244
  20. data/lib/zip/entry_set.rb +11 -9
  21. data/lib/zip/errors.rb +152 -16
  22. data/lib/zip/extra_field/aes.rb +50 -0
  23. data/lib/zip/extra_field/generic.rb +10 -11
  24. data/lib/zip/extra_field/ntfs.rb +6 -4
  25. data/lib/zip/extra_field/old_unix.rb +5 -3
  26. data/lib/zip/extra_field/universal_time.rb +3 -1
  27. data/lib/zip/extra_field/unix.rb +7 -5
  28. data/lib/zip/extra_field/unknown.rb +35 -0
  29. data/lib/zip/extra_field/zip64.rb +19 -5
  30. data/lib/zip/extra_field.rb +25 -23
  31. data/lib/zip/file.rb +272 -221
  32. data/lib/zip/file_split.rb +91 -0
  33. data/lib/zip/filesystem/dir.rb +86 -0
  34. data/lib/zip/filesystem/directory_iterator.rb +48 -0
  35. data/lib/zip/filesystem/file.rb +263 -0
  36. data/lib/zip/filesystem/file_stat.rb +110 -0
  37. data/lib/zip/filesystem/zip_file_name_mapper.rb +81 -0
  38. data/lib/zip/filesystem.rb +27 -596
  39. data/lib/zip/inflater.rb +13 -10
  40. data/lib/zip/input_stream.rb +102 -48
  41. data/lib/zip/ioextras/abstract_input_stream.rb +156 -58
  42. data/lib/zip/ioextras/abstract_output_stream.rb +15 -3
  43. data/lib/zip/ioextras/fake_io.rb +39 -0
  44. data/lib/zip/ioextras.rb +12 -16
  45. data/lib/zip/null_compressor.rb +3 -1
  46. data/lib/zip/null_decompressor.rb +6 -3
  47. data/lib/zip/null_input_stream.rb +3 -1
  48. data/lib/zip/output_stream.rb +74 -55
  49. data/lib/zip/pass_thru_compressor.rb +6 -3
  50. data/lib/zip/pass_thru_decompressor.rb +12 -9
  51. data/lib/zip/streamable_directory.rb +3 -1
  52. data/lib/zip/streamable_stream.rb +4 -1
  53. data/lib/zip/version.rb +4 -1
  54. data/lib/zip.rb +28 -4
  55. data/rubyzip.gemspec +39 -0
  56. data/samples/example.rb +8 -3
  57. data/samples/example_filesystem.rb +3 -2
  58. data/samples/example_recursive.rb +3 -1
  59. data/samples/gtk_ruby_zip.rb +5 -3
  60. data/samples/qtzip.rb +7 -6
  61. data/samples/write_simple.rb +2 -1
  62. data/samples/zipfind.rb +1 -0
  63. metadata +83 -49
  64. data/TODO +0 -15
  65. data/lib/zip/extra_field/zip64_placeholder.rb +0 -15
data/README.md CHANGED
@@ -1,26 +1,37 @@
1
1
  # rubyzip
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/rubyzip.svg)](http://badge.fury.io/rb/rubyzip)
4
- [![Build Status](https://secure.travis-ci.org/rubyzip/rubyzip.svg)](http://travis-ci.org/rubyzip/rubyzip)
5
- [![Code Climate](https://codeclimate.com/github/rubyzip/rubyzip.svg)](https://codeclimate.com/github/rubyzip/rubyzip)
4
+ [![Tests](https://github.com/rubyzip/rubyzip/actions/workflows/tests.yml/badge.svg)](https://github.com/rubyzip/rubyzip/actions/workflows/tests.yml)
5
+ [![Linter](https://github.com/rubyzip/rubyzip/actions/workflows/lint.yml/badge.svg)](https://github.com/rubyzip/rubyzip/actions/workflows/lint.yml)
6
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
7
+ [![Maintainability](https://qlty.sh/gh/rubyzip/projects/rubyzip/maintainability.svg)](https://qlty.sh/gh/rubyzip/projects/rubyzip)
6
8
  [![Coverage Status](https://img.shields.io/coveralls/rubyzip/rubyzip.svg)](https://coveralls.io/r/rubyzip/rubyzip?branch=master)
7
9
 
8
10
  Rubyzip is a ruby library for reading and writing zip files.
9
11
 
10
- ## Important note
12
+ ## Important notes
11
13
 
12
- The Rubyzip interface has changed!!! No need to do `require "zip/zip"` and `Zip` prefix in class names removed.
14
+ ### Reporting security issues with this library
13
15
 
14
- If you have issues with any third-party gems that require an old version of rubyzip, you can use this workaround:
16
+ If you think you have found a security issue with this library, please don't submit a public issue or PR. Email me directly at hainesr@gmail.com with as much information as you can provide - steps for replication are particularly helpful if you can - and we'll get it sorted ASAP. Thank you.
15
17
 
16
- ```ruby
17
- gem 'rubyzip', '>= 1.0.0' # will load new rubyzip version
18
- gem 'zip-zip' # will load compatibility for old rubyzip API.
19
- ```
18
+ ### Updating to version 3.0
19
+
20
+ The public API of some classes has been modernized to use named parameters for optional arguments. Please check your usage of the following Rubyzip classes:
21
+ * `File`
22
+ * `Entry`
23
+ * `InputStream`
24
+ * `OutputStream`
25
+
26
+ **Please see [Updating to version 3.x](https://github.com/rubyzip/rubyzip/wiki/Updating-to-version-3.x) in the wiki for details.**
20
27
 
21
28
  ## Requirements
22
29
 
23
- - Ruby 2.4 or greater (for rubyzip 2.0; use 1.x for older rubies)
30
+ Version 3.x requires at least Ruby 3.0.
31
+
32
+ Version 2.x requires at least Ruby 2.4, and is known to work on Ruby 3.x.
33
+
34
+ It is not recommended to use any versions of Rubyzip earlier than 2.3 due to security issues.
24
35
 
25
36
  ## Installation
26
37
 
@@ -33,9 +44,12 @@ gem install rubyzip
33
44
  Or in your Gemfile:
34
45
 
35
46
  ```ruby
36
- gem 'rubyzip'
47
+ gem 'rubyzip', require: 'zip' # For versions before 3.4.
48
+ gem 'rubyzip' # For version 3.4 and after.
37
49
  ```
38
50
 
51
+ From version 3.4 onwards, you can `require` either 'zip' or 'rubyzip' to use this library. Before version 3.4 you need to `require 'zip'` explicitly.
52
+
39
53
  ## Usage
40
54
 
41
55
  ### Basic zip archive creation
@@ -49,7 +63,7 @@ input_filenames = ['image.jpg', 'description.txt', 'stats.csv']
49
63
 
50
64
  zipfile_name = "/Users/me/Desktop/archive.zip"
51
65
 
52
- Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
66
+ Zip::File.open(zipfile_name, create: true) do |zipfile|
53
67
  input_filenames.each do |filename|
54
68
  # Two arguments:
55
69
  # - The name of the file as it will appear in the archive
@@ -60,9 +74,61 @@ Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
60
74
  end
61
75
  ```
62
76
 
77
+ ### Creating a Zip file with `Zip::OutputStream`
78
+
79
+ ```ruby
80
+ require 'rubygems'
81
+ require 'zip'
82
+
83
+ Zip::OutputStream.open('archive.zip') do |zos|
84
+ # Quick.
85
+ zos.put_next_entry('greeting.txt')
86
+ zos << 'Hello, World!'
87
+
88
+ # More control.
89
+ # You MUST NOT make any calls on your `Entry` after calling `put_next_entry`.
90
+ entry = Zip::Entry.new(nil, 'parting.txt')
91
+ entry.atime = Time.now
92
+ zos.put_next_entry(entry)
93
+ zos.write('TTFN')
94
+ end
95
+ ```
96
+
97
+ You can generate a Zip archive in memory using `Zip::OutputStream.write_buffer`.
98
+
99
+ ### Suppressing extra fields
100
+
101
+ If you wish to suppress extra fields from being added to your entries, you can do so by passing the `suppress_extra_fields` parameter to any of the archive opening calls within `Zip::File` or `Zip::OutputStream`, e.g.:
102
+
103
+ ```ruby
104
+ # Suppress all extra fields.
105
+ Zip::File.open('archive.zip', create: true, suppress_extra_fields: true)
106
+ Zip::OutputStream.open('archive.zip', suppress_extra_fields: true)
107
+
108
+ # Suppress an individual extra field.
109
+ Zip::File.open('archive.zip', create: true, suppress_extra_fields: :zip64)
110
+ Zip::OutputStream.open('archive.zip', suppress_extra_fields: :zip64)
111
+
112
+ # Suppress multiple extra fields.
113
+ Zip::File.open('archive.zip', create: true, suppress_extra_fields: [:ntfs, :zip64])
114
+ Zip::OutputStream.open('archive.zip', suppress_extra_fields: [:ntfs, :zip64])
115
+ ```
116
+
117
+ Note that there are some extra fields that cannot be suppressed at all (e.g. `:aes`), and some which will only be suppressed if it is safe to do so (e.g. `:zip64`).
118
+
63
119
  ### Zipping a directory recursively
64
120
 
65
- Copy from [here](https://github.com/rubyzip/rubyzip/blob/9d891f7353e66052283562d3e252fe380bb4b199/samples/example_recursive.rb)
121
+ `Zip::File#add_recursive` adds the contents of a directory (not the directory itself) to an archive, recursing into subdirectories:
122
+
123
+ ```ruby
124
+ Zip::File.open('archive.zip', create: true) do |zipfile|
125
+ zipfile.add_recursive('/path/to/directory')
126
+ end
127
+ ```
128
+
129
+ Pass `prefix:` (default `''`) to nest the contents under a prefix inside the archive, and `max_depth:` (default `16`) to limit how many directory levels are walked. Symlinks are always skipped (ignored, with a warning), rather than followed or added.
130
+
131
+ For more manual control, here is a hand-rolled version of the same thing:
66
132
 
67
133
  ```ruby
68
134
  require 'zip'
@@ -88,7 +154,7 @@ class ZipFileGenerator
88
154
  def write
89
155
  entries = Dir.entries(@input_dir) - %w[. ..]
90
156
 
91
- ::Zip::File.open(@output_file, ::Zip::File::CREATE) do |zipfile|
157
+ ::Zip::File.open(@output_file, create: true) do |zipfile|
92
158
  write_entries entries, '', zipfile
93
159
  end
94
160
  end
@@ -121,9 +187,9 @@ class ZipFileGenerator
121
187
  end
122
188
  ```
123
189
 
124
- ### Save zip archive entries in sorted by name state
190
+ ### Save zip archive entries sorted by name
125
191
 
126
- To save zip archives in sorted order like below, you need to set `::Zip.sort_entries` to `true`
192
+ To save zip archives with their entries sorted by name (see below), set `::Zip.sort_entries` to `true`
127
193
 
128
194
  ```
129
195
  Vegetable/
@@ -137,7 +203,7 @@ fruit/mango
137
203
  fruit/orange
138
204
  ```
139
205
 
140
- After this, entries in the zip archive will be saved in ordered state.
206
+ Opening an existing zip file with this option set will not change the order of the entries automatically. Altering the zip file - adding an entry, renaming an entry, adding or changing the archive comment, etc - will cause the ordering to be applied when closing the file.
141
207
 
142
208
  ### Default permissions of zip archives
143
209
 
@@ -145,7 +211,7 @@ On Posix file systems the default file permissions applied to a new archive
145
211
  are (0666 - umask), which mimics the behavior of standard tools such as `touch`.
146
212
 
147
213
  On Windows the default file permissions are set to 0644 as suggested by the
148
- [Ruby File documentation](http://ruby-doc.org/core-2.2.2/File.html).
214
+ [Ruby File documentation](https://docs.ruby-lang.org/en/master/File.html#class-file-file-permissions).
149
215
 
150
216
  When modifying a zip archive the file permissions of the archive are preserved.
151
217
 
@@ -173,28 +239,115 @@ Zip::File.open('foo.zip') do |zip_file|
173
239
  end
174
240
  ```
175
241
 
176
- #### Notice about ::Zip::InputStream
242
+ To extract every entry in an archive at once, preserving its directory structure, use `Zip::File#extract_all`:
177
243
 
178
- `::Zip::InputStream` usable for fast reading zip file content because it not read Central directory.
244
+ ```ruby
245
+ Zip::File.open('foo.zip') do |zip_file|
246
+ zip_file.extract_all('/path/to/destination')
247
+ end
248
+ ```
249
+
250
+ As with `extract`, existing files at the destination will raise `Zip::DestinationExistsError` unless a block is passed to resolve the conflict (see [Existing Files](#existing-files) below). Symlink entries are always skipped (ignored, with a warning), rather than extracted.
179
251
 
180
- But there is one exception when it is not working - General Purpose Flag Bit 3.
252
+ ### Reading a Zip file with `Zip::InputStream`
181
253
 
182
- > If bit 3 (0x08) of the general-purpose flags field is set, then the CRC-32 and file sizes are not known when the header is written. The fields in the local header are filled with zero, and the CRC-32 and size are appended in a 12-byte structure (optionally preceded by a 4-byte signature) immediately after the compressed data
254
+ `Zip::InputStream` can be used for faster reading of zip file content because it does not read the Central directory up front.
183
255
 
184
- If `::Zip::InputStream` finds such entry in the zip archive it will raise an exception.
256
+ There is one exception where it can not work however, and this is if the file does not contain enough information in the local entry headers to extract an entry. This is indicated in an entry by the General Purpose Flag bit 3 being set.
185
257
 
186
- ### Password Protection (Experimental)
258
+ > If bit 3 (0x08) of the general-purpose flags field is set, then the CRC-32 and file sizes are not known when the header is written. The fields in the local header are filled with zero, and the CRC-32 and size are appended in a 12-byte structure (optionally preceded by a 4-byte signature) immediately after the compressed data.
187
259
 
188
- Rubyzip supports reading/writing zip files with traditional zip encryption (a.k.a. "ZipCrypto"). AES encryption is not yet supported. It can be used with buffer streams, e.g.:
260
+ If `Zip::InputStream` finds such an entry in the zip archive it will raise an exception (`Zip::StreamingError`).
261
+
262
+ `Zip::InputStream` is not designed to be used for random access in a zip file. When performing any operations on an entry that you are accessing via `Zip::InputStream#get_next_entry` then you should complete any such operations before the next call to `get_next_entry`.
189
263
 
190
264
  ```ruby
191
- Zip::OutputStream.write_buffer(::StringIO.new(''), Zip::TraditionalEncrypter.new('password')) do |out|
192
- out.put_next_entry("my_file.txt")
193
- out.write my_data
194
- end.string
265
+ Zip::InputStream.open('file.zip') do |zip_stream|
266
+ while entry = zip_stream.get_next_entry
267
+ # All required operations on `entry` go here.
268
+ end
269
+ end # The `InputStream` is closed at the end of the block.
195
270
  ```
196
271
 
197
- This is an experimental feature and the interface for encryption may change in future versions.
272
+ Any attempt to move about in a zip file opened with `Zip::InputStream` could result in the incorrect entry being accessed and/or Zlib buffer errors. If you need random access in a zip file, use `Zip::File`.
273
+
274
+ ### Encryption and Password Protection (experimental)
275
+
276
+ Rubyzip supports reading and writing zip files with AES encryption (reading: version 3.1 and later; writing: version 3.7 and later), and reading and writing zip files with traditional zip encryption (a.k.a. "ZipCrypto"). Encryption is currently only available with the stream API, with either files or buffers, e.g.:
277
+
278
+ #### Version 2.x (ZipCrypto only)
279
+
280
+ ```ruby
281
+ # Writing.
282
+ enc = Zip::TraditionalEncrypter.new('password')
283
+ buffer = Zip::OutputStream.write_buffer(::StringIO.new(''), enc) do |output|
284
+ output.put_next_entry("my_file.txt")
285
+ output.write my_data
286
+ end
287
+
288
+ # Reading.
289
+ dec = Zip::TraditionalDecrypter.new('password')
290
+ Zip::InputStream.open(buffer, 0, dec) do |input|
291
+ entry = input.get_next_entry
292
+ puts "Contents of '#{entry.name}':"
293
+ puts input.read
294
+ end
295
+ ```
296
+
297
+ #### Version 3.x (AES and ZipCrypto)
298
+
299
+ ```ruby
300
+ # Writing AES, version 3.7 and later.
301
+ enc = Zip::AESEncrypter.new('password', Zip::AESEncryption::STRENGTH_256_BIT)
302
+ Zip::OutputStream.open('aes-encrypted-file.zip', encrypter: enc) do |output|
303
+ output.put_next_entry('my_file.txt')
304
+ output.write my_data
305
+ end
306
+
307
+ # Reading AES, version 3.1 and later.
308
+ dec = Zip::AESDecrypter.new('password', Zip::AESEncryption::STRENGTH_256_BIT)
309
+ Zip::InputStream.open('aes-encrypted-file.zip', decrypter: dec) do |input|
310
+ entry = input.get_next_entry
311
+ puts "Contents of '#{entry.name}':"
312
+ puts input.read
313
+ end
314
+
315
+ # Writing ZipCrypto.
316
+ enc = Zip::TraditionalEncrypter.new('password')
317
+ buffer = Zip::OutputStream.write_buffer(encrypter: enc) do |output|
318
+ output.put_next_entry("my_file.txt")
319
+ output.write my_data
320
+ end
321
+
322
+ # Reading ZipCrypto.
323
+ dec = Zip::TraditionalDecrypter.new('password')
324
+ Zip::InputStream.open(buffer, decrypter: dec) do |input|
325
+ entry = input.get_next_entry
326
+ puts "Contents of '#{entry.name}':"
327
+ puts input.read
328
+ end
329
+ ```
330
+
331
+ #### Passing a decrypter to an individual `Entry`
332
+
333
+ You can also decrypt an `Entry` by passing a decrypter into `Zip::Entry#get_input_stream`. This allows you to decrypt files from a Zip file with different passwords.
334
+
335
+ ```ruby
336
+ Zip::File.open('aes-encrypted-file.zip') do |zip|
337
+ entries = [['file1.txt', 'password1'], ['file2.txt', 'password2']]
338
+
339
+ entries.each do |entry_name, password|
340
+ entry = zip.find_entry(entry_name)
341
+ dec = Zip::AESDecrypter.new(password, Zip::AESEncryption::STRENGTH_256_BIT)
342
+ zis = entry.get_input_stream(decrypter: dec)
343
+
344
+ puts "Contents of '#{entry.name}':"
345
+ puts zis.read
346
+ end
347
+ end
348
+ ```
349
+
350
+ _This is an evolving feature and the interface for encryption may change in future versions._
198
351
 
199
352
  ## Known issues
200
353
 
@@ -208,7 +361,7 @@ buffer = Zip::OutputStream.write_buffer do |out|
208
361
  unless [DOCUMENT_FILE_PATH, RELS_FILE_PATH].include?(e.name)
209
362
  out.put_next_entry(e.name)
210
363
  out.write e.get_input_stream.read
211
- end
364
+ end
212
365
  end
213
366
 
214
367
  out.put_next_entry(DOCUMENT_FILE_PATH)
@@ -241,7 +394,7 @@ Zip.continue_on_exists_proc = true
241
394
 
242
395
  ### Non-ASCII Names
243
396
 
244
- If you want to store non-english names and want to open them on Windows(pre 7) you need to set this option:
397
+ To store non-English filenames as UTF-8 (decoded correctly by Windows 7 or later and other modern tools), set this option:
245
398
 
246
399
  ```ruby
247
400
  Zip.unicode_names = true
@@ -263,7 +416,19 @@ Some zip files might have an invalid date format, which will raise a warning. Yo
263
416
  Zip.warn_invalid_date = false
264
417
  ```
265
418
 
266
- ### Size Validation
419
+ ### Validating Declared Number of Entries
420
+
421
+ When reading a zip file it is potentially dangerous to trust what it tells you about how many entries it contains. A malformed zip file could claim a high number of entries in an attempt to waste internal resources, or crash the processing application.
422
+
423
+ By default rubyzip will warn if the number of declared entries is impossible based on the actual size of the Central Directory headers. You can set this check to raise an error:
424
+
425
+ ```ruby
426
+ Zip.validate_declared_number_of_entries = true
427
+ ```
428
+
429
+ It is likely that the default behaviour for this check will be changed to raise an error in version 4.
430
+
431
+ ### Entry Size Validation
267
432
 
268
433
  By default (in rubyzip >= 2.0), rubyzip's `extract` method checks that an entry's reported uncompressed size is not (significantly) smaller than its actual size. This is to help you protect your application against [zip bombs](https://en.wikipedia.org/wiki/Zip_bomb). Before `extract`ing an entry, you should check that its size is in the range you expect. For example, if your application supports processing up to 100 files at once, each up to 10MiB, your zip extraction code might look like:
269
434
 
@@ -288,25 +453,37 @@ Zip.validate_entry_sizes = false
288
453
 
289
454
  Note that if you use the lower level `Zip::InputStream` interface, `rubyzip` does *not* check the entry `size`s. In this case, the caller is responsible for making sure it does not read more data than expected from the input stream.
290
455
 
291
- ### Default Compression
456
+ ### Compression level
292
457
 
293
- You can set the default compression level like so:
458
+ When adding entries to a zip archive you can set the compression level to trade-off compressed size against compression speed. By default this is set to the same as the underlying Zlib library's default (`Zlib::DEFAULT_COMPRESSION`), which is somewhere in the middle.
459
+
460
+ You can configure the default compression level with:
294
461
 
295
462
  ```ruby
296
- Zip.default_compression = Zlib::DEFAULT_COMPRESSION
463
+ Zip.default_compression = X
297
464
  ```
298
465
 
299
- It defaults to `Zlib::DEFAULT_COMPRESSION`. Possible values are `Zlib::BEST_COMPRESSION`, `Zlib::DEFAULT_COMPRESSION` and `Zlib::NO_COMPRESSION`
466
+ Where X is an integer between 0 and 9, inclusive. If this option is set to 0 (`Zlib::NO_COMPRESSION`) then entries will be stored in the zip archive uncompressed. A value of 1 (`Zlib::BEST_SPEED`) gives the fastest compression and 9 (`Zlib::BEST_COMPRESSION`) gives the smallest compressed file size.
467
+
468
+ This can also be set for each archive as an option to `Zip::File`:
469
+
470
+ ```ruby
471
+ Zip::File.open('foo.zip', create:true, compression_level: 9) do |zip|
472
+ zip.add ...
473
+ end
474
+ ```
300
475
 
301
476
  ### Zip64 Support
302
477
 
303
- By default, Zip64 support is disabled for writing. To enable it do this:
478
+ Since version 3.0, Zip64 support is enabled for writing by default. To disable it do this:
304
479
 
305
480
  ```ruby
306
- Zip.write_zip64_support = true
481
+ Zip.write_zip64_support = false
307
482
  ```
308
483
 
309
- _NOTE_: If you will enable Zip64 writing then you will need zip extractor with Zip64 support to extract archive.
484
+ Prior to version 3.0, Zip64 support is disabled for writing by default.
485
+
486
+ _NOTE_: If Zip64 write support is enabled then any extractor subsequently used may also require Zip64 support to read from the resultant archive.
310
487
 
311
488
  ### Block Form
312
489
 
@@ -321,15 +498,51 @@ You can set multiple settings at the same time by using a block:
321
498
  end
322
499
  ```
323
500
 
501
+ ## Compatibility
502
+
503
+ Rubyzip is known to run on a number of platforms and under a number of different Ruby versions.
504
+
505
+ ### Version 2.4.x
506
+
507
+ Rubyzip 2.4 is known to work on MRI 2.4 to 3.4 on Linux and Mac, and JRuby and Truffleruby on Linux. There are known issues with Windows which have been fixed on the development branch. Please [let us know](https://github.com/rubyzip/rubyzip/pulls) if you know Rubyzip 2.4 works on a platform/Ruby combination not listed here, or [raise an issue](https://github.com/rubyzip/rubyzip/issues) if you see a failure where we think it should work.
508
+
509
+ ### Version 3.x
510
+
511
+ Please see the table below for what we think the current situation is. Note: an empty cell means "unknown", not "does not work".
512
+
513
+ | OS/Ruby | 3.0 | 3.1 | 3.2 | 3.3 | 3.4 | 4.0 | Head | JRuby 10.0.1.0 | JRuby Head | Truffleruby 34.0.1 | Truffleruby Head |
514
+ |---------|-----|-----|-----|-----|-----|-----|------|----------------|------------|-------------------|------------------|
515
+ |Ubuntu 24.04| CI | CI | CI | CI | CI | CI | ci | CI | ci | CI | ci |
516
+ |Mac OS 15.7.7| CI | x | x | CI | CI | CI | ci | x | | x | |
517
+ |Windows Server 2022| CI | | | | | | | | | | |
518
+ |Windows Server 2025| | | | CI | | CI | CI&nbsp;mswin</br>CI&nbsp;ucrt | | | | |
519
+
520
+ Key: `CI` - tested in CI, should work; `ci` - tested in CI, might fail; `x` - known working; `o` - known failing.
521
+
522
+ Rubies 3.1+ are also tested separately with YJIT turned on (Ubuntu and Mac OS).
523
+
524
+ See [the Actions tab](https://github.com/rubyzip/rubyzip/actions) in GitHub for full details.
525
+
526
+ Please [raise a PR](https://github.com/rubyzip/rubyzip/pulls) if you know Rubyzip works on a platform/Ruby combination not listed here, or [raise an issue](https://github.com/rubyzip/rubyzip/issues) if you see a failure where we think it should work.
527
+
324
528
  ## Developing
325
529
 
326
- To run the test you need to do this:
530
+ Install the dependencies:
327
531
 
328
- ```
532
+ ```shell
329
533
  bundle install
534
+ ```
535
+
536
+ Run the tests with `rake`:
537
+
538
+ ```shell
330
539
  rake
331
540
  ```
332
541
 
542
+ Please also run `rubocop` over your changes.
543
+
544
+ Our CI runs on [GitHub Actions](https://github.com/rubyzip/rubyzip/actions). Please note that `rubocop` is run as part of the CI configuration and will fail a build if errors are found.
545
+
333
546
  ## Website and Project Home
334
547
 
335
548
  http://github.com/rubyzip/rubyzip
@@ -338,17 +551,18 @@ http://rdoc.info/github/rubyzip/rubyzip/master/frames
338
551
 
339
552
  ## Authors
340
553
 
341
- Alexander Simonov ( alex at simonov.me)
554
+ See https://github.com/rubyzip/rubyzip/graphs/contributors for a comprehensive list.
342
555
 
343
- Alan Harper ( alan at aussiegeek.net)
556
+ ### Current maintainers
344
557
 
345
- Thomas Sondergaard (thomas at sondergaard.cc)
558
+ * Robert Haines (@hainesr)
559
+ * John Lees-Miller (@jdleesmiller)
560
+ * Oleksandr Simonov (@simonoff)
346
561
 
347
- Technorama Ltd. (oss-ruby-zip at technorama.net)
562
+ ### Original author
348
563
 
349
- extra-field support contributed by Tatsuki Sugiura (sugi at nemui.org)
564
+ * Thomas Sondergaard
350
565
 
351
566
  ## License
352
567
 
353
- Rubyzip is distributed under the same license as ruby. See
354
- http://www.ruby-lang.org/en/LICENSE.txt
568
+ Rubyzip is distributed under the same license as Ruby. In practice this means you can use it under the terms of the Ruby License or the 2-Clause BSD License. See https://www.ruby-lang.org/en/about/license.txt and LICENSE.md for details.
data/Rakefile CHANGED
@@ -1,21 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
- require 'rake/testtask'
4
+ require 'minitest/test_task'
5
+ require 'rdoc/task'
3
6
  require 'rubocop/rake_task'
4
7
 
5
8
  task default: :test
6
9
 
7
- Rake::TestTask.new(:test) do |test|
8
- test.libs << 'lib'
9
- test.libs << 'test'
10
- test.pattern = 'test/**/*_test.rb'
11
- test.verbose = true
10
+ Minitest::TestTask.create do |test|
11
+ test.framework = 'require "simplecov"'
12
+ test.test_globs = 'test/**/*_test.rb'
12
13
  end
13
14
 
14
- RuboCop::RakeTask.new
15
+ RDoc::Task.new do |rdoc|
16
+ rdoc.main = 'README.md'
17
+ rdoc.rdoc_files.include('README.md', 'lib/**/*.rb')
18
+ rdoc.options << '--markup=markdown'
19
+ rdoc.options << '--tab-width=2'
20
+ rdoc.options << "-t Rubyzip version #{Zip::VERSION}"
21
+ end
15
22
 
16
- # Rake::TestTask.new(:zip64_full_test) do |test|
17
- # test.libs << File.join(File.dirname(__FILE__), 'lib')
18
- # test.libs << File.join(File.dirname(__FILE__), 'test')
19
- # test.pattern = File.join(File.dirname(__FILE__), 'test/zip64_full_test.rb')
20
- # test.verbose = true
21
- # end
23
+ RuboCop::RakeTask.new
data/lib/rubyzip.rb ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'zip'