rubyzip 2.4.rc1 → 3.0.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +368 -0
  3. data/README.md +112 -37
  4. data/Rakefile +11 -7
  5. data/lib/zip/central_directory.rb +164 -118
  6. data/lib/zip/compressor.rb +3 -1
  7. data/lib/zip/constants.rb +25 -21
  8. data/lib/zip/crypto/decrypted_io.rb +3 -1
  9. data/lib/zip/crypto/encryption.rb +4 -2
  10. data/lib/zip/crypto/null_encryption.rb +5 -3
  11. data/lib/zip/crypto/traditional_encryption.rb +5 -3
  12. data/lib/zip/decompressor.rb +4 -3
  13. data/lib/zip/deflater.rb +10 -8
  14. data/lib/zip/dirtyable.rb +32 -0
  15. data/lib/zip/dos_time.rb +32 -3
  16. data/lib/zip/entry.rb +263 -199
  17. data/lib/zip/entry_set.rb +9 -7
  18. data/lib/zip/errors.rb +115 -16
  19. data/lib/zip/extra_field/generic.rb +3 -10
  20. data/lib/zip/extra_field/ntfs.rb +4 -2
  21. data/lib/zip/extra_field/old_unix.rb +3 -1
  22. data/lib/zip/extra_field/universal_time.rb +3 -1
  23. data/lib/zip/extra_field/unix.rb +5 -3
  24. data/lib/zip/extra_field/unknown.rb +33 -0
  25. data/lib/zip/extra_field/zip64.rb +12 -5
  26. data/lib/zip/extra_field.rb +15 -21
  27. data/lib/zip/file.rb +143 -264
  28. data/lib/zip/file_split.rb +97 -0
  29. data/lib/zip/filesystem/dir.rb +86 -0
  30. data/lib/zip/filesystem/directory_iterator.rb +48 -0
  31. data/lib/zip/filesystem/file.rb +262 -0
  32. data/lib/zip/filesystem/file_stat.rb +110 -0
  33. data/lib/zip/filesystem/zip_file_name_mapper.rb +81 -0
  34. data/lib/zip/filesystem.rb +26 -595
  35. data/lib/zip/inflater.rb +7 -5
  36. data/lib/zip/input_stream.rb +44 -39
  37. data/lib/zip/ioextras/abstract_input_stream.rb +14 -9
  38. data/lib/zip/ioextras/abstract_output_stream.rb +5 -3
  39. data/lib/zip/ioextras.rb +6 -6
  40. data/lib/zip/null_compressor.rb +3 -1
  41. data/lib/zip/null_decompressor.rb +3 -1
  42. data/lib/zip/null_input_stream.rb +3 -1
  43. data/lib/zip/output_stream.rb +47 -48
  44. data/lib/zip/pass_thru_compressor.rb +3 -1
  45. data/lib/zip/pass_thru_decompressor.rb +4 -2
  46. data/lib/zip/streamable_directory.rb +3 -1
  47. data/lib/zip/streamable_stream.rb +3 -0
  48. data/lib/zip/version.rb +3 -1
  49. data/lib/zip.rb +15 -16
  50. data/rubyzip.gemspec +38 -0
  51. data/samples/example.rb +8 -3
  52. data/samples/example_filesystem.rb +2 -1
  53. data/samples/example_recursive.rb +3 -1
  54. data/samples/gtk_ruby_zip.rb +4 -2
  55. data/samples/qtzip.rb +6 -5
  56. data/samples/write_simple.rb +1 -0
  57. data/samples/zipfind.rb +1 -0
  58. metadata +81 -46
  59. data/TODO +0 -15
  60. data/lib/zip/extra_field/zip64_placeholder.rb +0 -15
data/samples/example.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  $LOAD_PATH << '../lib'
4
5
  system('zip example.zip example.rb gtk_ruby_zip.rb')
@@ -20,7 +21,8 @@ end
20
21
 
21
22
  zf = Zip::File.new('example.zip')
22
23
  zf.each_with_index do |entry, index|
23
- puts "entry #{index} is #{entry.name}, size = #{entry.size}, compressed size = #{entry.compressed_size}"
24
+ puts "entry #{index} is #{entry.name}, size = #{entry.size}, " \
25
+ "compressed size = #{entry.compressed_size}"
24
26
  # use zf.get_input_stream(entry) to get a ZipInputStream for the entry
25
27
  # entry can be the ZipEntry object or any object which has a to_s method that
26
28
  # returns the name of the entry.
@@ -70,8 +72,11 @@ part_zips_count = Zip::File.split('large_zip_file.zip', 2_097_152, false)
70
72
  puts "Zip file splitted in #{part_zips_count} parts"
71
73
 
72
74
  # Track splitting an archive
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 * 100).to_i}%"
75
+ Zip::File.split(
76
+ 'large_zip_file.zip', 1_048_576, true, 'part_zip_file'
77
+ ) do |part_count, part_index, chunk_bytes, segment_bytes|
78
+ puts "#{part_index} of #{part_count} part splitting: " \
79
+ "#{(chunk_bytes.to_f / segment_bytes * 100).to_i}%"
75
80
  end
76
81
 
77
82
  # For other examples, look at zip.rb and ziptest.rb
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  $LOAD_PATH << '../lib'
4
5
 
@@ -8,7 +9,7 @@ EXAMPLE_ZIP = 'filesystem.zip'
8
9
 
9
10
  File.delete(EXAMPLE_ZIP) if File.exist?(EXAMPLE_ZIP)
10
11
 
11
- Zip::File.open(EXAMPLE_ZIP, Zip::File::CREATE) do |zf|
12
+ Zip::File.open(EXAMPLE_ZIP, create: true) do |zf|
12
13
  zf.file.open('file1.txt', 'w') { |os| os.write 'first file1.txt' }
13
14
  zf.dir.mkdir('dir1')
14
15
  zf.dir.chdir('dir1')
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'zip'
2
4
 
3
5
  # This is a simple example which uses rubyzip to
@@ -21,7 +23,7 @@ class ZipFileGenerator
21
23
  def write
22
24
  entries = Dir.entries(@input_dir) - %w[. ..]
23
25
 
24
- ::Zip::File.open(@output_file, ::Zip::File::CREATE) do |zipfile|
26
+ ::Zip::File.open(@output_file, create: true) do |zipfile|
25
27
  write_entries entries, '', zipfile
26
28
  end
27
29
  end
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  $LOAD_PATH << '../lib'
4
5
 
@@ -42,7 +43,8 @@ class MainApp < Gtk::Window
42
43
  end
43
44
 
44
45
  class ButtonPanel < Gtk::HButtonBox
45
- attr_reader :open_button, :extract_button
46
+ attr_reader :extract_button, :open_button
47
+
46
48
  def initialize
47
49
  super
48
50
  set_layout(Gtk::BUTTONBOX_START)
@@ -72,7 +74,7 @@ class MainApp < Gtk::Window
72
74
  @zipfile.each do |entry|
73
75
  @clist.append([entry.name,
74
76
  entry.size.to_s,
75
- (100.0 * entry.compressedSize / entry.size).to_s + '%'])
77
+ "#{100.0 * entry.compressedSize / entry.size}%"])
76
78
  end
77
79
  end
78
80
  end
data/samples/qtzip.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  $VERBOSE = true
4
5
 
@@ -6,7 +7,7 @@ $LOAD_PATH << '../lib'
6
7
 
7
8
  require 'Qt'
8
9
  system('rbuic -o zipdialogui.rb zipdialogui.ui')
9
- require 'zipdialogui.rb'
10
+ require 'zipdialogui'
10
11
  require 'zip'
11
12
 
12
13
  a = Qt::Application.new(ARGV)
@@ -65,14 +66,14 @@ class ZipDialog < ZipDialogUI
65
66
  end
66
67
  puts "selected_items.size = #{selected_items.size}"
67
68
  puts "unselected_items.size = #{unselected_items.size}"
68
- items = !selected_items.empty? ? selected_items : unselected_items
69
+ items = selected_items.empty? ? unselected_items : selected_items
69
70
  puts "items.size = #{items.size}"
70
71
 
71
72
  d = Qt::FileDialog.get_existing_directory(nil, self)
72
- if !d
73
- puts 'No directory chosen'
74
- else
73
+ if d
75
74
  zipfile { |zf| items.each { |e| zf.extract(e, File.join(d, e)) } }
75
+ else
76
+ puts 'No directory chosen'
76
77
  end
77
78
  end
78
79
 
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  $LOAD_PATH << '../lib'
4
5
 
data/samples/zipfind.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  $VERBOSE = true
4
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyzip
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.rc1
4
+ version: 3.0.0.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Haines
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-04-08 00:00:00.000000000 Z
13
+ date: 2023-04-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: minitest
@@ -27,53 +27,103 @@ dependencies:
27
27
  - !ruby/object:Gem::Version
28
28
  version: '5.4'
29
29
  - !ruby/object:Gem::Dependency
30
- name: pry
30
+ name: rake
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: '0.10'
35
+ version: 12.3.3
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '0.10'
42
+ version: 12.3.3
43
43
  - !ruby/object:Gem::Dependency
44
- name: rake
44
+ name: rdoc
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '12.3'
50
- - - ">="
49
+ version: 6.4.0
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
51
55
  - !ruby/object:Gem::Version
52
- version: 12.3.3
56
+ version: 6.4.0
57
+ - !ruby/object:Gem::Dependency
58
+ name: rubocop
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: 1.12.0
53
64
  type: :development
54
65
  prerelease: false
55
66
  version_requirements: !ruby/object:Gem::Requirement
56
67
  requirements:
57
68
  - - "~>"
58
69
  - !ruby/object:Gem::Version
59
- version: '12.3'
60
- - - ">="
70
+ version: 1.12.0
71
+ - !ruby/object:Gem::Dependency
72
+ name: rubocop-performance
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
61
76
  - !ruby/object:Gem::Version
62
- version: 12.3.3
77
+ version: 1.10.0
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: 1.10.0
63
85
  - !ruby/object:Gem::Dependency
64
- name: rubocop
86
+ name: rubocop-rake
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: 0.5.0
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: 0.5.0
99
+ - !ruby/object:Gem::Dependency
100
+ name: simplecov
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - "~>"
104
+ - !ruby/object:Gem::Version
105
+ version: 0.18.0
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: 0.18.0
113
+ - !ruby/object:Gem::Dependency
114
+ name: simplecov-lcov
65
115
  requirement: !ruby/object:Gem::Requirement
66
116
  requirements:
67
117
  - - "~>"
68
118
  - !ruby/object:Gem::Version
69
- version: '0.79'
119
+ version: '0.8'
70
120
  type: :development
71
121
  prerelease: false
72
122
  version_requirements: !ruby/object:Gem::Requirement
73
123
  requirements:
74
124
  - - "~>"
75
125
  - !ruby/object:Gem::Version
76
- version: '0.79'
126
+ version: '0.8'
77
127
  description:
78
128
  email:
79
129
  - hainesr@gmail.com
@@ -83,9 +133,9 @@ executables: []
83
133
  extensions: []
84
134
  extra_rdoc_files: []
85
135
  files:
136
+ - Changelog.md
86
137
  - README.md
87
138
  - Rakefile
88
- - TODO
89
139
  - lib/zip.rb
90
140
  - lib/zip/central_directory.rb
91
141
  - lib/zip/compressor.rb
@@ -96,6 +146,7 @@ files:
96
146
  - lib/zip/crypto/traditional_encryption.rb
97
147
  - lib/zip/decompressor.rb
98
148
  - lib/zip/deflater.rb
149
+ - lib/zip/dirtyable.rb
99
150
  - lib/zip/dos_time.rb
100
151
  - lib/zip/entry.rb
101
152
  - lib/zip/entry_set.rb
@@ -106,10 +157,16 @@ files:
106
157
  - lib/zip/extra_field/old_unix.rb
107
158
  - lib/zip/extra_field/universal_time.rb
108
159
  - lib/zip/extra_field/unix.rb
160
+ - lib/zip/extra_field/unknown.rb
109
161
  - lib/zip/extra_field/zip64.rb
110
- - lib/zip/extra_field/zip64_placeholder.rb
111
162
  - lib/zip/file.rb
163
+ - lib/zip/file_split.rb
112
164
  - lib/zip/filesystem.rb
165
+ - lib/zip/filesystem/dir.rb
166
+ - lib/zip/filesystem/directory_iterator.rb
167
+ - lib/zip/filesystem/file.rb
168
+ - lib/zip/filesystem/file_stat.rb
169
+ - lib/zip/filesystem/zip_file_name_mapper.rb
113
170
  - lib/zip/inflater.rb
114
171
  - lib/zip/input_stream.rb
115
172
  - lib/zip/ioextras.rb
@@ -124,6 +181,7 @@ files:
124
181
  - lib/zip/streamable_directory.rb
125
182
  - lib/zip/streamable_stream.rb
126
183
  - lib/zip/version.rb
184
+ - rubyzip.gemspec
127
185
  - samples/example.rb
128
186
  - samples/example_filesystem.rb
129
187
  - samples/example_recursive.rb
@@ -133,37 +191,14 @@ files:
133
191
  - samples/zipfind.rb
134
192
  homepage: http://github.com/rubyzip/rubyzip
135
193
  licenses:
136
- - BSD 2-Clause
194
+ - BSD-2-Clause
137
195
  metadata:
138
196
  bug_tracker_uri: https://github.com/rubyzip/rubyzip/issues
139
- changelog_uri: https://github.com/rubyzip/rubyzip/blob/v2.4.rc1/Changelog.md
140
- documentation_uri: https://www.rubydoc.info/gems/rubyzip/2.4.rc1
141
- source_code_uri: https://github.com/rubyzip/rubyzip/tree/v2.4.rc1
197
+ changelog_uri: https://github.com/rubyzip/rubyzip/blob/v3.0.0.alpha/Changelog.md
198
+ documentation_uri: https://www.rubydoc.info/gems/rubyzip/3.0.0.alpha
199
+ source_code_uri: https://github.com/rubyzip/rubyzip/tree/v3.0.0.alpha
142
200
  wiki_uri: https://github.com/rubyzip/rubyzip/wiki
143
- post_install_message: |
144
- RubyZip 3.0 is coming!
145
- **********************
146
-
147
- The public API of some Rubyzip classes has been modernized to use named
148
- parameters for optional arguments. Please check your usage of the
149
- following classes:
150
- * `Zip::File`
151
- * `Zip::Entry`
152
- * `Zip::InputStream`
153
- * `Zip::OutputStream`
154
- * `Zip::DOSTime`
155
-
156
- Run your test suite with the `RUBYZIP_V3_API_WARN` environment
157
- variable set to see warnings about usage of the old API. This will
158
- help you to identify any changes that you need to make to your code.
159
- See https://github.com/rubyzip/rubyzip/wiki/Updating-to-version-3.x for
160
- more information.
161
-
162
- Please ensure that your Gemfiles and .gemspecs are suitably restrictive
163
- to avoid an unexpected breakage when 3.0 is released (e.g. ~> 2.3.0).
164
- See https://github.com/rubyzip/rubyzip for details. The Changelog also
165
- lists other enhancements and bugfixes that have been implemented since
166
- version 2.3.0.
201
+ post_install_message:
167
202
  rdoc_options: []
168
203
  require_paths:
169
204
  - lib
@@ -171,7 +206,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
206
  requirements:
172
207
  - - ">="
173
208
  - !ruby/object:Gem::Version
174
- version: '2.4'
209
+ version: '2.5'
175
210
  required_rubygems_version: !ruby/object:Gem::Requirement
176
211
  requirements:
177
212
  - - ">"
data/TODO DELETED
@@ -1,15 +0,0 @@
1
-
2
- * ZipInputStream: Support zip-files with trailing data descriptors
3
- * Adjust rdoc stylesheet to advertise inherited methods if possible
4
- * Suggestion: Add ZipFile/ZipInputStream example that demonstrates extracting all entries.
5
- * Suggestion: ZipFile#extract destination should default to "."
6
- * Suggestion: ZipEntry should have extract(), get_input_stream() methods etc
7
- * (is buffering used anywhere with write?)
8
- * Inflater.sysread should pass the buffer to produce_input.
9
- * Implement ZipFsDir.glob
10
- * ZipFile.checkIntegrity method
11
- * non-MSDOS permission attributes
12
- ** See mail from Ned Konz to ruby-talk subj. "Re: SV: [ANN] Archive 0.2"
13
- * Packager version, required unpacker version in zip headers
14
- ** See mail from Ned Konz to ruby-talk subj. "Re: SV: [ANN] Archive 0.2"
15
- * implement storing attributes and ownership information
@@ -1,15 +0,0 @@
1
- module Zip
2
- # placeholder to reserve space for a Zip64 extra information record, for the
3
- # local file header only, that we won't know if we'll need until after
4
- # we write the file data
5
- class ExtraField::Zip64Placeholder < ExtraField::Generic
6
- HEADER_ID = ['9999'].pack('H*') # this ID is used by other libraries such as .NET's Ionic.zip
7
- register_map
8
-
9
- def initialize(_binstr = nil); end
10
-
11
- def pack_for_local
12
- "\x00" * 16
13
- end
14
- end
15
- end