rubyzip 2.0.0 → 2.4.1

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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -9
  3. data/Rakefile +3 -0
  4. data/lib/zip/central_directory.rb +9 -5
  5. data/lib/zip/constants.rb +52 -0
  6. data/lib/zip/crypto/decrypted_io.rb +40 -0
  7. data/lib/zip/crypto/traditional_encryption.rb +9 -9
  8. data/lib/zip/decompressor.rb +19 -1
  9. data/lib/zip/dos_time.rb +24 -12
  10. data/lib/zip/entry.rb +107 -49
  11. data/lib/zip/entry_set.rb +2 -0
  12. data/lib/zip/errors.rb +1 -0
  13. data/lib/zip/extra_field/generic.rb +10 -9
  14. data/lib/zip/extra_field/ntfs.rb +5 -1
  15. data/lib/zip/extra_field/old_unix.rb +3 -1
  16. data/lib/zip/extra_field/universal_time.rb +42 -12
  17. data/lib/zip/extra_field/unix.rb +3 -1
  18. data/lib/zip/extra_field/zip64.rb +5 -3
  19. data/lib/zip/extra_field.rb +11 -9
  20. data/lib/zip/file.rb +142 -65
  21. data/lib/zip/filesystem.rb +193 -177
  22. data/lib/zip/inflater.rb +24 -36
  23. data/lib/zip/input_stream.rb +50 -30
  24. data/lib/zip/ioextras/abstract_input_stream.rb +23 -12
  25. data/lib/zip/ioextras/abstract_output_stream.rb +1 -1
  26. data/lib/zip/ioextras.rb +3 -3
  27. data/lib/zip/null_decompressor.rb +1 -9
  28. data/lib/zip/output_stream.rb +28 -12
  29. data/lib/zip/pass_thru_compressor.rb +2 -2
  30. data/lib/zip/pass_thru_decompressor.rb +13 -22
  31. data/lib/zip/streamable_directory.rb +3 -3
  32. data/lib/zip/streamable_stream.rb +6 -10
  33. data/lib/zip/version.rb +1 -1
  34. data/lib/zip.rb +22 -2
  35. data/samples/example.rb +2 -2
  36. data/samples/example_filesystem.rb +1 -1
  37. data/samples/gtk_ruby_zip.rb +19 -19
  38. data/samples/qtzip.rb +6 -6
  39. data/samples/write_simple.rb +2 -4
  40. data/samples/zipfind.rb +23 -22
  41. metadata +52 -31
data/lib/zip.rb CHANGED
@@ -1,10 +1,11 @@
1
+ require 'English'
1
2
  require 'delegate'
2
3
  require 'singleton'
3
4
  require 'tempfile'
4
- require 'tmpdir'
5
5
  require 'fileutils'
6
6
  require 'stringio'
7
7
  require 'zlib'
8
+ require 'zip/constants'
8
9
  require 'zip/dos_time'
9
10
  require 'zip/ioextras'
10
11
  require 'rbconfig'
@@ -22,6 +23,7 @@ require 'zip/null_compressor'
22
23
  require 'zip/null_input_stream'
23
24
  require 'zip/pass_thru_compressor'
24
25
  require 'zip/pass_thru_decompressor'
26
+ require 'zip/crypto/decrypted_io'
25
27
  require 'zip/crypto/encryption'
26
28
  require 'zip/crypto/null_encryption'
27
29
  require 'zip/crypto/traditional_encryption'
@@ -29,10 +31,28 @@ require 'zip/inflater'
29
31
  require 'zip/deflater'
30
32
  require 'zip/streamable_stream'
31
33
  require 'zip/streamable_directory'
32
- require 'zip/constants'
33
34
  require 'zip/errors'
34
35
 
35
36
  module Zip
37
+ V3_API_WARNING_MSG = <<~END_MSG
38
+ You have called '%s' (from %s).
39
+ This method is changing or deprecated in version 3.0.0. Please see
40
+ https://github.com/rubyzip/rubyzip/wiki/Updating-to-version-3.x
41
+ for more information.
42
+ END_MSG
43
+
44
+ def self.warn_about_v3_api(method)
45
+ return unless ENV['RUBYZIP_V3_API_WARN']
46
+
47
+ loc = caller_locations(2, 1)[0]
48
+ from = "#{loc.path.split('/').last}:#{loc.lineno}"
49
+ warn format(V3_API_WARNING_MSG, method, from)
50
+ end
51
+
52
+ if ENV['RUBYZIP_V3_API_WARN'] && RUBY_VERSION < '3.0'
53
+ warn 'RubyZip 3.0 will require Ruby 3.0 or later.'
54
+ end
55
+
36
56
  extend self
37
57
  attr_accessor :unicode_names,
38
58
  :on_exists_proc,
data/samples/example.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $: << '../lib'
3
+ $LOAD_PATH << '../lib'
4
4
  system('zip example.zip example.rb gtk_ruby_zip.rb')
5
5
 
6
6
  require 'zip'
@@ -71,7 +71,7 @@ puts "Zip file splitted in #{part_zips_count} parts"
71
71
 
72
72
  # Track splitting an archive
73
73
  Zip::File.split('large_zip_file.zip', 1_048_576, true, 'part_zip_file') do |part_count, part_index, chunk_bytes, segment_bytes|
74
- puts "#{part_index} of #{part_count} part splitting: #{(chunk_bytes.to_f / segment_bytes.to_f * 100).to_i}%"
74
+ puts "#{part_index} of #{part_count} part splitting: #{(chunk_bytes.to_f / segment_bytes * 100).to_i}%"
75
75
  end
76
76
 
77
77
  # For other examples, look at zip.rb and ziptest.rb
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $: << '../lib'
3
+ $LOAD_PATH << '../lib'
4
4
 
5
5
  require 'zip/filesystem'
6
6
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $: << '../lib'
3
+ $LOAD_PATH << '../lib'
4
4
 
5
5
  $VERBOSE = true
6
6
 
@@ -18,14 +18,14 @@ class MainApp < Gtk::Window
18
18
  add(box)
19
19
 
20
20
  @zipfile = nil
21
- @buttonPanel = ButtonPanel.new
22
- @buttonPanel.openButton.signal_connect(Gtk::Button::SIGNAL_CLICKED) do
21
+ @button_panel = ButtonPanel.new
22
+ @button_panel.open_button.signal_connect(Gtk::Button::SIGNAL_CLICKED) do
23
23
  show_file_selector
24
24
  end
25
- @buttonPanel.extractButton.signal_connect(Gtk::Button::SIGNAL_CLICKED) do
25
+ @button_panel.extract_button.signal_connect(Gtk::Button::SIGNAL_CLICKED) do
26
26
  puts 'Not implemented!'
27
27
  end
28
- box.pack_start(@buttonPanel, false, false, 0)
28
+ box.pack_start(@button_panel, false, false, 0)
29
29
 
30
30
  sw = Gtk::ScrolledWindow.new
31
31
  sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
@@ -42,27 +42,27 @@ class MainApp < Gtk::Window
42
42
  end
43
43
 
44
44
  class ButtonPanel < Gtk::HButtonBox
45
- attr_reader :openButton, :extractButton
45
+ attr_reader :open_button, :extract_button
46
46
  def initialize
47
47
  super
48
48
  set_layout(Gtk::BUTTONBOX_START)
49
49
  set_spacing(0)
50
- @openButton = Gtk::Button.new('Open archive')
51
- @extractButton = Gtk::Button.new('Extract entry')
52
- pack_start(@openButton)
53
- pack_start(@extractButton)
50
+ @open_button = Gtk::Button.new('Open archive')
51
+ @extract_button = Gtk::Button.new('Extract entry')
52
+ pack_start(@open_button)
53
+ pack_start(@extract_button)
54
54
  end
55
55
  end
56
56
 
57
57
  def show_file_selector
58
- @fileSelector = Gtk::FileSelection.new('Open zip file')
59
- @fileSelector.show
60
- @fileSelector.ok_button.signal_connect(Gtk::Button::SIGNAL_CLICKED) do
61
- open_zip(@fileSelector.filename)
62
- @fileSelector.destroy
58
+ @file_selector = Gtk::FileSelection.new('Open zip file')
59
+ @file_selector.show
60
+ @file_selector.ok_button.signal_connect(Gtk::Button::SIGNAL_CLICKED) do
61
+ open_zip(@file_selector.filename)
62
+ @file_selector.destroy
63
63
  end
64
- @fileSelector.cancel_button.signal_connect(Gtk::Button::SIGNAL_CLICKED) do
65
- @fileSelector.destroy
64
+ @file_selector.cancel_button.signal_connect(Gtk::Button::SIGNAL_CLICKED) do
65
+ @file_selector.destroy
66
66
  end
67
67
  end
68
68
 
@@ -77,8 +77,8 @@ class MainApp < Gtk::Window
77
77
  end
78
78
  end
79
79
 
80
- mainApp = MainApp.new
80
+ main_app = MainApp.new
81
81
 
82
- mainApp.show_all
82
+ main_app.show_all
83
83
 
84
84
  Gtk.main
data/samples/qtzip.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  $VERBOSE = true
4
4
 
5
- $: << '../lib'
5
+ $LOAD_PATH << '../lib'
6
6
 
7
7
  require 'Qt'
8
8
  system('rbuic -o zipdialogui.rb zipdialogui.ui')
@@ -20,12 +20,12 @@ class ZipDialog < ZipDialogUI
20
20
  self, SLOT('extract_files()'))
21
21
  end
22
22
 
23
- def zipfile(&proc)
24
- Zip::File.open(@zip_filename, &proc)
23
+ def zipfile(&a_proc)
24
+ Zip::File.open(@zip_filename, &a_proc)
25
25
  end
26
26
 
27
- def each(&proc)
28
- Zip::File.foreach(@zip_filename, &proc)
27
+ def each(&a_proc)
28
+ Zip::File.foreach(@zip_filename, &a_proc)
29
29
  end
30
30
 
31
31
  def refresh
@@ -80,7 +80,7 @@ class ZipDialog < ZipDialogUI
80
80
  end
81
81
 
82
82
  unless ARGV[0]
83
- puts "usage: #{$0} zipname"
83
+ puts "usage: #{$PROGRAM_NAME} zipname"
84
84
  exit
85
85
  end
86
86
 
@@ -1,12 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $: << '../lib'
3
+ $LOAD_PATH << '../lib'
4
4
 
5
5
  require 'zip'
6
6
 
7
- include Zip
8
-
9
- OutputStream.open('simple.zip') do |zos|
7
+ ::Zip::OutputStream.open('simple.zip') do |zos|
10
8
  zos.put_next_entry 'entry.txt'
11
9
  zos.puts 'Hello world'
12
10
  end
data/samples/zipfind.rb CHANGED
@@ -2,36 +2,37 @@
2
2
 
3
3
  $VERBOSE = true
4
4
 
5
- $: << '../lib'
5
+ $LOAD_PATH << '../lib'
6
6
 
7
7
  require 'zip'
8
8
  require 'find'
9
9
 
10
10
  module Zip
11
11
  module ZipFind
12
- def self.find(path, zipFilePattern = /\.zip$/i)
13
- Find.find(path) do |fileName|
14
- yield(fileName)
15
- next unless zipFilePattern.match(fileName) && File.file?(fileName)
12
+ def self.find(path, zip_file_pattern = /\.zip$/i)
13
+ Find.find(path) do |filename|
14
+ yield(filename)
15
+ next unless zip_file_pattern.match(filename) && File.file?(filename)
16
+
16
17
  begin
17
- Zip::File.foreach(fileName) do |zipEntry|
18
- yield(fileName + File::SEPARATOR + zipEntry.to_s)
18
+ Zip::File.foreach(filename) do |entry|
19
+ yield(filename + File::SEPARATOR + entry.to_s)
19
20
  end
20
- rescue Errno::EACCES => ex
21
- puts ex
21
+ rescue Errno::EACCES => e
22
+ puts e
22
23
  end
23
24
  end
24
25
  end
25
26
 
26
- def self.find_file(path, fileNamePattern, zipFilePattern = /\.zip$/i)
27
- find(path, zipFilePattern) do |fileName|
28
- yield(fileName) if fileNamePattern.match(fileName)
27
+ def self.find_file(path, filename_pattern, zip_file_pattern = /\.zip$/i)
28
+ find(path, zip_file_pattern) do |filename|
29
+ yield(filename) if filename_pattern.match(filename)
29
30
  end
30
31
  end
31
32
  end
32
33
  end
33
34
 
34
- if $0 == __FILE__
35
+ if $PROGRAM_NAME == __FILE__
35
36
  module ZipFindConsoleRunner
36
37
  PATH_ARG_INDEX = 0
37
38
  FILENAME_PATTERN_ARG_INDEX = 1
@@ -41,24 +42,24 @@ if $0 == __FILE__
41
42
  check_args(args)
42
43
  Zip::ZipFind.find_file(args[PATH_ARG_INDEX],
43
44
  args[FILENAME_PATTERN_ARG_INDEX],
44
- args[ZIPFILE_PATTERN_ARG_INDEX]) do |fileName|
45
- report_entry_found fileName
45
+ args[ZIPFILE_PATTERN_ARG_INDEX]) do |filename|
46
+ report_entry_found filename
46
47
  end
47
48
  end
48
49
 
49
50
  def self.check_args(args)
50
- if args.size != 3
51
- usage
52
- exit
53
- end
51
+ return if args.size == 3
52
+
53
+ usage
54
+ exit
54
55
  end
55
56
 
56
57
  def self.usage
57
- puts "Usage: #{$0} PATH ZIPFILENAME_PATTERN FILNAME_PATTERN"
58
+ puts "Usage: #{$PROGRAM_NAME} PATH ZIPFILENAME_PATTERN FILNAME_PATTERN"
58
59
  end
59
60
 
60
- def self.report_entry_found(fileName)
61
- puts fileName
61
+ def self.report_entry_found(filename)
62
+ puts filename
62
63
  end
63
64
  end
64
65
 
metadata CHANGED
@@ -1,29 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyzip
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
+ - Robert Haines
8
+ - John Lees-Miller
7
9
  - Alexander Simonov
8
- autorequire:
10
+ autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2019-09-25 00:00:00.000000000 Z
13
+ date: 2025-01-05 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
- name: rake
16
+ name: minitest
15
17
  requirement: !ruby/object:Gem::Requirement
16
18
  requirements:
17
19
  - - "~>"
18
20
  - !ruby/object:Gem::Version
19
- version: '10.3'
21
+ version: '5.4'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
23
25
  requirements:
24
26
  - - "~>"
25
27
  - !ruby/object:Gem::Version
26
- version: '10.3'
28
+ version: '5.4'
27
29
  - !ruby/object:Gem::Dependency
28
30
  name: pry
29
31
  requirement: !ruby/object:Gem::Requirement
@@ -39,49 +41,43 @@ dependencies:
39
41
  - !ruby/object:Gem::Version
40
42
  version: '0.10'
41
43
  - !ruby/object:Gem::Dependency
42
- name: minitest
44
+ name: rake
43
45
  requirement: !ruby/object:Gem::Requirement
44
46
  requirements:
45
47
  - - "~>"
46
48
  - !ruby/object:Gem::Version
47
- version: '5.4'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
49
+ version: '12.3'
50
+ - - ">="
53
51
  - !ruby/object:Gem::Version
54
- version: '5.4'
55
- - !ruby/object:Gem::Dependency
56
- name: coveralls
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.7'
52
+ version: 12.3.3
62
53
  type: :development
63
54
  prerelease: false
64
55
  version_requirements: !ruby/object:Gem::Requirement
65
56
  requirements:
66
57
  - - "~>"
67
58
  - !ruby/object:Gem::Version
68
- version: '0.7'
59
+ version: '12.3'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 12.3.3
69
63
  - !ruby/object:Gem::Dependency
70
64
  name: rubocop
71
65
  requirement: !ruby/object:Gem::Requirement
72
66
  requirements:
73
67
  - - "~>"
74
68
  - !ruby/object:Gem::Version
75
- version: 0.49.1
69
+ version: '0.79'
76
70
  type: :development
77
71
  prerelease: false
78
72
  version_requirements: !ruby/object:Gem::Requirement
79
73
  requirements:
80
74
  - - "~>"
81
75
  - !ruby/object:Gem::Version
82
- version: 0.49.1
83
- description:
76
+ version: '0.79'
77
+ description:
84
78
  email:
79
+ - hainesr@gmail.com
80
+ - jdleesmiller@gmail.com
85
81
  - alex@simonov.me
86
82
  executables: []
87
83
  extensions: []
@@ -94,6 +90,7 @@ files:
94
90
  - lib/zip/central_directory.rb
95
91
  - lib/zip/compressor.rb
96
92
  - lib/zip/constants.rb
93
+ - lib/zip/crypto/decrypted_io.rb
97
94
  - lib/zip/crypto/encryption.rb
98
95
  - lib/zip/crypto/null_encryption.rb
99
96
  - lib/zip/crypto/traditional_encryption.rb
@@ -139,11 +136,35 @@ licenses:
139
136
  - BSD 2-Clause
140
137
  metadata:
141
138
  bug_tracker_uri: https://github.com/rubyzip/rubyzip/issues
142
- changelog_uri: https://github.com/rubyzip/rubyzip/blob/v2.0.0/Changelog.md
143
- documentation_uri: https://www.rubydoc.info/gems/rubyzip/2.0.0
144
- source_code_uri: https://github.com/rubyzip/rubyzip/tree/v2.0.0
139
+ changelog_uri: https://github.com/rubyzip/rubyzip/blob/v2.4.1/Changelog.md
140
+ documentation_uri: https://www.rubydoc.info/gems/rubyzip/2.4.1
141
+ source_code_uri: https://github.com/rubyzip/rubyzip/tree/v2.4.1
145
142
  wiki_uri: https://github.com/rubyzip/rubyzip/wiki
146
- post_install_message:
143
+ rubygems_mfa_required: 'true'
144
+ post_install_message: |
145
+ RubyZip 3.0 is coming!
146
+ **********************
147
+
148
+ The public API of some Rubyzip classes has been modernized to use named
149
+ parameters for optional arguments. Please check your usage of the
150
+ following classes:
151
+ * `Zip::File`
152
+ * `Zip::Entry`
153
+ * `Zip::InputStream`
154
+ * `Zip::OutputStream`
155
+ * `Zip::DOSTime`
156
+
157
+ Run your test suite with the `RUBYZIP_V3_API_WARN` environment
158
+ variable set to see warnings about usage of the old API. This will
159
+ help you to identify any changes that you need to make to your code.
160
+ See https://github.com/rubyzip/rubyzip/wiki/Updating-to-version-3.x for
161
+ more information.
162
+
163
+ Please ensure that your Gemfiles and .gemspecs are suitably restrictive
164
+ to avoid an unexpected breakage when 3.0 is released (e.g. ~> 2.3.0).
165
+ See https://github.com/rubyzip/rubyzip for details. The Changelog also
166
+ lists other enhancements and bugfixes that have been implemented since
167
+ version 2.3.0.
147
168
  rdoc_options: []
148
169
  require_paths:
149
170
  - lib
@@ -158,8 +179,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
179
  - !ruby/object:Gem::Version
159
180
  version: '0'
160
181
  requirements: []
161
- rubygems_version: 3.0.3
162
- signing_key:
182
+ rubygems_version: 3.1.6
183
+ signing_key:
163
184
  specification_version: 4
164
185
  summary: rubyzip is a ruby module for reading and writing zip files
165
186
  test_files: []