rubyzip 2.3.1 → 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 +122 -39
  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 +41 -5
  16. data/lib/zip/entry.rb +273 -170
  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 +152 -221
  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 +6 -4
  36. data/lib/zip/input_stream.rb +43 -25
  37. data/lib/zip/ioextras/abstract_input_stream.rb +13 -8
  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 +45 -39
  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 -22
  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 +83 -35
  59. data/TODO +0 -15
  60. data/lib/zip/extra_field/zip64_placeholder.rb +0 -15
@@ -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,101 +1,141 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyzip
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 3.0.0.alpha
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: 2021-07-03 00:00:00.000000000 Z
13
+ date: 2023-04-16 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
- name: coveralls
16
+ name: minitest
15
17
  requirement: !ruby/object:Gem::Requirement
16
18
  requirements:
17
19
  - - "~>"
18
20
  - !ruby/object:Gem::Version
19
- version: '0.7'
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: '0.7'
28
+ version: '5.4'
27
29
  - !ruby/object:Gem::Dependency
28
- name: minitest
30
+ name: rake
29
31
  requirement: !ruby/object:Gem::Requirement
30
32
  requirements:
31
33
  - - "~>"
32
34
  - !ruby/object:Gem::Version
33
- version: '5.4'
35
+ version: 12.3.3
34
36
  type: :development
35
37
  prerelease: false
36
38
  version_requirements: !ruby/object:Gem::Requirement
37
39
  requirements:
38
40
  - - "~>"
39
41
  - !ruby/object:Gem::Version
40
- version: '5.4'
42
+ version: 12.3.3
41
43
  - !ruby/object:Gem::Dependency
42
- name: pry
44
+ name: rdoc
43
45
  requirement: !ruby/object:Gem::Requirement
44
46
  requirements:
45
47
  - - "~>"
46
48
  - !ruby/object:Gem::Version
47
- version: '0.10'
49
+ version: 6.4.0
48
50
  type: :development
49
51
  prerelease: false
50
52
  version_requirements: !ruby/object:Gem::Requirement
51
53
  requirements:
52
54
  - - "~>"
53
55
  - !ruby/object:Gem::Version
54
- version: '0.10'
56
+ version: 6.4.0
55
57
  - !ruby/object:Gem::Dependency
56
- name: rake
58
+ name: rubocop
57
59
  requirement: !ruby/object:Gem::Requirement
58
60
  requirements:
59
61
  - - "~>"
60
62
  - !ruby/object:Gem::Version
61
- version: '12.3'
62
- - - ">="
63
+ version: 1.12.0
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
63
69
  - !ruby/object:Gem::Version
64
- version: 12.3.3
70
+ version: 1.12.0
71
+ - !ruby/object:Gem::Dependency
72
+ name: rubocop-performance
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
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
85
+ - !ruby/object:Gem::Dependency
86
+ name: rubocop-rake
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: 0.5.0
65
92
  type: :development
66
93
  prerelease: false
67
94
  version_requirements: !ruby/object:Gem::Requirement
68
95
  requirements:
69
96
  - - "~>"
70
97
  - !ruby/object:Gem::Version
71
- version: '12.3'
72
- - - ">="
98
+ version: 0.5.0
99
+ - !ruby/object:Gem::Dependency
100
+ name: simplecov
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - "~>"
73
104
  - !ruby/object:Gem::Version
74
- version: 12.3.3
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
75
113
  - !ruby/object:Gem::Dependency
76
- name: rubocop
114
+ name: simplecov-lcov
77
115
  requirement: !ruby/object:Gem::Requirement
78
116
  requirements:
79
117
  - - "~>"
80
118
  - !ruby/object:Gem::Version
81
- version: '0.79'
119
+ version: '0.8'
82
120
  type: :development
83
121
  prerelease: false
84
122
  version_requirements: !ruby/object:Gem::Requirement
85
123
  requirements:
86
124
  - - "~>"
87
125
  - !ruby/object:Gem::Version
88
- version: '0.79'
89
- description:
126
+ version: '0.8'
127
+ description:
90
128
  email:
129
+ - hainesr@gmail.com
130
+ - jdleesmiller@gmail.com
91
131
  - alex@simonov.me
92
132
  executables: []
93
133
  extensions: []
94
134
  extra_rdoc_files: []
95
135
  files:
136
+ - Changelog.md
96
137
  - README.md
97
138
  - Rakefile
98
- - TODO
99
139
  - lib/zip.rb
100
140
  - lib/zip/central_directory.rb
101
141
  - lib/zip/compressor.rb
@@ -106,6 +146,7 @@ files:
106
146
  - lib/zip/crypto/traditional_encryption.rb
107
147
  - lib/zip/decompressor.rb
108
148
  - lib/zip/deflater.rb
149
+ - lib/zip/dirtyable.rb
109
150
  - lib/zip/dos_time.rb
110
151
  - lib/zip/entry.rb
111
152
  - lib/zip/entry_set.rb
@@ -116,10 +157,16 @@ files:
116
157
  - lib/zip/extra_field/old_unix.rb
117
158
  - lib/zip/extra_field/universal_time.rb
118
159
  - lib/zip/extra_field/unix.rb
160
+ - lib/zip/extra_field/unknown.rb
119
161
  - lib/zip/extra_field/zip64.rb
120
- - lib/zip/extra_field/zip64_placeholder.rb
121
162
  - lib/zip/file.rb
163
+ - lib/zip/file_split.rb
122
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
123
170
  - lib/zip/inflater.rb
124
171
  - lib/zip/input_stream.rb
125
172
  - lib/zip/ioextras.rb
@@ -134,6 +181,7 @@ files:
134
181
  - lib/zip/streamable_directory.rb
135
182
  - lib/zip/streamable_stream.rb
136
183
  - lib/zip/version.rb
184
+ - rubyzip.gemspec
137
185
  - samples/example.rb
138
186
  - samples/example_filesystem.rb
139
187
  - samples/example_recursive.rb
@@ -143,14 +191,14 @@ files:
143
191
  - samples/zipfind.rb
144
192
  homepage: http://github.com/rubyzip/rubyzip
145
193
  licenses:
146
- - BSD 2-Clause
194
+ - BSD-2-Clause
147
195
  metadata:
148
196
  bug_tracker_uri: https://github.com/rubyzip/rubyzip/issues
149
- changelog_uri: https://github.com/rubyzip/rubyzip/blob/v2.3.1/Changelog.md
150
- documentation_uri: https://www.rubydoc.info/gems/rubyzip/2.3.1
151
- source_code_uri: https://github.com/rubyzip/rubyzip/tree/v2.3.1
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
152
200
  wiki_uri: https://github.com/rubyzip/rubyzip/wiki
153
- post_install_message:
201
+ post_install_message:
154
202
  rdoc_options: []
155
203
  require_paths:
156
204
  - lib
@@ -158,15 +206,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
206
  requirements:
159
207
  - - ">="
160
208
  - !ruby/object:Gem::Version
161
- version: '2.4'
209
+ version: '2.5'
162
210
  required_rubygems_version: !ruby/object:Gem::Requirement
163
211
  requirements:
164
- - - ">="
212
+ - - ">"
165
213
  - !ruby/object:Gem::Version
166
- version: '0'
214
+ version: 1.3.1
167
215
  requirements: []
168
- rubygems_version: 3.1.4
169
- signing_key:
216
+ rubygems_version: 3.3.23
217
+ signing_key:
170
218
  specification_version: 4
171
219
  summary: rubyzip is a ruby module for reading and writing zip files
172
220
  test_files: []
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