rubyzip 0.9.1 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +354 -0
- data/Rakefile +15 -104
- data/TODO +0 -1
- data/lib/zip/central_directory.rb +212 -0
- data/lib/zip/compressor.rb +9 -0
- data/lib/zip/constants.rb +115 -0
- data/lib/zip/crypto/decrypted_io.rb +40 -0
- data/lib/zip/crypto/encryption.rb +11 -0
- data/lib/zip/crypto/null_encryption.rb +43 -0
- data/lib/zip/crypto/traditional_encryption.rb +99 -0
- data/lib/zip/decompressor.rb +31 -0
- data/lib/zip/deflater.rb +34 -0
- data/lib/zip/dos_time.rb +53 -0
- data/lib/zip/entry.rb +719 -0
- data/lib/zip/entry_set.rb +88 -0
- data/lib/zip/errors.rb +19 -0
- data/lib/zip/extra_field/generic.rb +44 -0
- data/lib/zip/extra_field/ntfs.rb +94 -0
- data/lib/zip/extra_field/old_unix.rb +46 -0
- data/lib/zip/extra_field/universal_time.rb +77 -0
- data/lib/zip/extra_field/unix.rb +39 -0
- data/lib/zip/extra_field/zip64.rb +70 -0
- data/lib/zip/extra_field/zip64_placeholder.rb +15 -0
- data/lib/zip/extra_field.rb +103 -0
- data/lib/zip/file.rb +468 -0
- data/lib/zip/filesystem.rb +643 -0
- data/lib/zip/inflater.rb +54 -0
- data/lib/zip/input_stream.rb +180 -0
- data/lib/zip/ioextras/abstract_input_stream.rb +122 -0
- data/lib/zip/ioextras/abstract_output_stream.rb +43 -0
- data/lib/zip/ioextras.rb +21 -140
- data/lib/zip/null_compressor.rb +15 -0
- data/lib/zip/null_decompressor.rb +19 -0
- data/lib/zip/null_input_stream.rb +10 -0
- data/lib/zip/output_stream.rb +198 -0
- data/lib/zip/pass_thru_compressor.rb +23 -0
- data/lib/zip/pass_thru_decompressor.rb +31 -0
- data/lib/zip/streamable_directory.rb +15 -0
- data/lib/zip/streamable_stream.rb +52 -0
- data/lib/zip/version.rb +3 -0
- data/lib/zip.rb +72 -0
- data/samples/example.rb +44 -32
- data/samples/example_filesystem.rb +16 -19
- data/samples/example_recursive.rb +54 -0
- data/samples/gtk_ruby_zip.rb +84 -0
- data/samples/qtzip.rb +25 -34
- data/samples/write_simple.rb +10 -13
- data/samples/zipfind.rb +38 -45
- metadata +182 -91
- data/ChangeLog +0 -1504
- data/NEWS +0 -144
- data/README +0 -72
- data/install.rb +0 -22
- data/lib/download_quizzes.rb +0 -119
- data/lib/quiz1/t/solutions/Bill Guindon/solitaire.rb +0 -205
- data/lib/quiz1/t/solutions/Carlos/solitaire.rb +0 -111
- data/lib/quiz1/t/solutions/Dennis Ranke/solitaire.rb +0 -111
- data/lib/quiz1/t/solutions/Florian Gross/solitaire.rb +0 -301
- data/lib/quiz1/t/solutions/Glen M. Lewis/solitaire.rb +0 -268
- data/lib/quiz1/t/solutions/James Edward Gray II/solitaire.rb +0 -132
- data/lib/quiz1/t/solutions/Jamis Buck/bin/main.rb +0 -13
- data/lib/quiz1/t/solutions/Jamis Buck/lib/cipher.rb +0 -230
- data/lib/quiz1/t/solutions/Jamis Buck/lib/cli.rb +0 -24
- data/lib/quiz1/t/solutions/Jamis Buck/test/tc_deck.rb +0 -30
- data/lib/quiz1/t/solutions/Jamis Buck/test/tc_key-stream.rb +0 -19
- data/lib/quiz1/t/solutions/Jamis Buck/test/tc_keying-algorithms.rb +0 -31
- data/lib/quiz1/t/solutions/Jamis Buck/test/tc_solitaire-cipher.rb +0 -66
- data/lib/quiz1/t/solutions/Jamis Buck/test/tc_unkeyed-algorithm.rb +0 -17
- data/lib/quiz1/t/solutions/Jamis Buck/test/tests.rb +0 -2
- data/lib/quiz1/t/solutions/Jim Menard/solitaire_cypher.rb +0 -204
- data/lib/quiz1/t/solutions/Jim Menard/test.rb +0 -47
- data/lib/quiz1/t/solutions/Moses Hohman/cipher.rb +0 -97
- data/lib/quiz1/t/solutions/Moses Hohman/deck.rb +0 -140
- data/lib/quiz1/t/solutions/Moses Hohman/solitaire.rb +0 -14
- data/lib/quiz1/t/solutions/Moses Hohman/test_cipher.rb +0 -68
- data/lib/quiz1/t/solutions/Moses Hohman/test_deck.rb +0 -146
- data/lib/quiz1/t/solutions/Moses Hohman/test_util.rb +0 -38
- data/lib/quiz1/t/solutions/Moses Hohman/testsuite.rb +0 -5
- data/lib/quiz1/t/solutions/Moses Hohman/util.rb +0 -27
- data/lib/quiz1/t/solutions/Niklas Frykholm/solitaire.rb +0 -151
- data/lib/quiz1/t/solutions/Thomas Leitner/solitaire.rb +0 -198
- data/lib/zip/stdrubyext.rb +0 -111
- data/lib/zip/tempfile_bugfixed.rb +0 -195
- data/lib/zip/zip.rb +0 -1847
- data/lib/zip/zipfilesystem.rb +0 -609
- data/lib/zip/ziprequire.rb +0 -90
- data/samples/gtkRubyzip.rb +0 -86
- data/test/alltests.rb +0 -9
- data/test/data/file1.txt +0 -46
- data/test/data/file1.txt.deflatedData +0 -0
- data/test/data/file2.txt +0 -1504
- data/test/data/notzippedruby.rb +0 -7
- data/test/data/rubycode.zip +0 -0
- data/test/data/rubycode2.zip +0 -0
- data/test/data/testDirectory.bin +0 -0
- data/test/data/zipWithDirs.zip +0 -0
- data/test/gentestfiles.rb +0 -157
- data/test/ioextrastest.rb +0 -208
- data/test/stdrubyexttest.rb +0 -52
- data/test/zipfilesystemtest.rb +0 -831
- data/test/ziprequiretest.rb +0 -43
- data/test/ziptest.rb +0 -1599
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 35bd078119c42cd2250fadd127a0feae3299184b0bf90804c3ff0bc28d1c427f
|
4
|
+
data.tar.gz: 98e034b50a428ff970f25b28348993d938a88c5d5c93506561761f260062c059
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 421a8884fbfe6f720e2e0da35f34e4208b96f83529faf5cba03501aa2693d95d51b9c19e04e4567801de1822120a0e14faf1c4d0991a164b8f0d011eaa6c0f7b
|
7
|
+
data.tar.gz: 59f29c6b49a14c777605224b351d8d14f7fdfe88a2ffc75a5f2120f51152831ed9afa04d8daf1f971bad982c3bcdd86e17d5616c8c9d57ddff7509b7f59e58b1
|
data/README.md
ADDED
@@ -0,0 +1,354 @@
|
|
1
|
+
# rubyzip
|
2
|
+
|
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)
|
6
|
+
[![Coverage Status](https://img.shields.io/coveralls/rubyzip/rubyzip.svg)](https://coveralls.io/r/rubyzip/rubyzip?branch=master)
|
7
|
+
|
8
|
+
Rubyzip is a ruby library for reading and writing zip files.
|
9
|
+
|
10
|
+
## Important note
|
11
|
+
|
12
|
+
The Rubyzip interface has changed!!! No need to do `require "zip/zip"` and `Zip` prefix in class names removed.
|
13
|
+
|
14
|
+
If you have issues with any third-party gems that require an old version of rubyzip, you can use this workaround:
|
15
|
+
|
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
|
+
```
|
20
|
+
|
21
|
+
## Requirements
|
22
|
+
|
23
|
+
- Ruby 2.4 or greater (for rubyzip 2.0; use 1.x for older rubies)
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
Rubyzip is available on RubyGems:
|
28
|
+
|
29
|
+
```
|
30
|
+
gem install rubyzip
|
31
|
+
```
|
32
|
+
|
33
|
+
Or in your Gemfile:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
gem 'rubyzip'
|
37
|
+
```
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
### Basic zip archive creation
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require 'rubygems'
|
45
|
+
require 'zip'
|
46
|
+
|
47
|
+
folder = "Users/me/Desktop/stuff_to_zip"
|
48
|
+
input_filenames = ['image.jpg', 'description.txt', 'stats.csv']
|
49
|
+
|
50
|
+
zipfile_name = "/Users/me/Desktop/archive.zip"
|
51
|
+
|
52
|
+
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
|
53
|
+
input_filenames.each do |filename|
|
54
|
+
# Two arguments:
|
55
|
+
# - The name of the file as it will appear in the archive
|
56
|
+
# - The original file, including the path to find it
|
57
|
+
zipfile.add(filename, File.join(folder, filename))
|
58
|
+
end
|
59
|
+
zipfile.get_output_stream("myFile") { |f| f.write "myFile contains just this" }
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
### Zipping a directory recursively
|
64
|
+
|
65
|
+
Copy from [here](https://github.com/rubyzip/rubyzip/blob/9d891f7353e66052283562d3e252fe380bb4b199/samples/example_recursive.rb)
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
require 'zip'
|
69
|
+
|
70
|
+
# This is a simple example which uses rubyzip to
|
71
|
+
# recursively generate a zip file from the contents of
|
72
|
+
# a specified directory. The directory itself is not
|
73
|
+
# included in the archive, rather just its contents.
|
74
|
+
#
|
75
|
+
# Usage:
|
76
|
+
# directory_to_zip = "/tmp/input"
|
77
|
+
# output_file = "/tmp/out.zip"
|
78
|
+
# zf = ZipFileGenerator.new(directory_to_zip, output_file)
|
79
|
+
# zf.write()
|
80
|
+
class ZipFileGenerator
|
81
|
+
# Initialize with the directory to zip and the location of the output archive.
|
82
|
+
def initialize(input_dir, output_file)
|
83
|
+
@input_dir = input_dir
|
84
|
+
@output_file = output_file
|
85
|
+
end
|
86
|
+
|
87
|
+
# Zip the input directory.
|
88
|
+
def write
|
89
|
+
entries = Dir.entries(@input_dir) - %w[. ..]
|
90
|
+
|
91
|
+
::Zip::File.open(@output_file, ::Zip::File::CREATE) do |zipfile|
|
92
|
+
write_entries entries, '', zipfile
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
# A helper method to make the recursion work.
|
99
|
+
def write_entries(entries, path, zipfile)
|
100
|
+
entries.each do |e|
|
101
|
+
zipfile_path = path == '' ? e : File.join(path, e)
|
102
|
+
disk_file_path = File.join(@input_dir, zipfile_path)
|
103
|
+
|
104
|
+
if File.directory? disk_file_path
|
105
|
+
recursively_deflate_directory(disk_file_path, zipfile, zipfile_path)
|
106
|
+
else
|
107
|
+
put_into_archive(disk_file_path, zipfile, zipfile_path)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def recursively_deflate_directory(disk_file_path, zipfile, zipfile_path)
|
113
|
+
zipfile.mkdir zipfile_path
|
114
|
+
subdir = Dir.entries(disk_file_path) - %w[. ..]
|
115
|
+
write_entries subdir, zipfile_path, zipfile
|
116
|
+
end
|
117
|
+
|
118
|
+
def put_into_archive(disk_file_path, zipfile, zipfile_path)
|
119
|
+
zipfile.add(zipfile_path, disk_file_path)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
```
|
123
|
+
|
124
|
+
### Save zip archive entries in sorted by name state
|
125
|
+
|
126
|
+
To save zip archives in sorted order like below, you need to set `::Zip.sort_entries` to `true`
|
127
|
+
|
128
|
+
```
|
129
|
+
Vegetable/
|
130
|
+
Vegetable/bean
|
131
|
+
Vegetable/carrot
|
132
|
+
Vegetable/celery
|
133
|
+
fruit/
|
134
|
+
fruit/apple
|
135
|
+
fruit/kiwi
|
136
|
+
fruit/mango
|
137
|
+
fruit/orange
|
138
|
+
```
|
139
|
+
|
140
|
+
After this, entries in the zip archive will be saved in ordered state.
|
141
|
+
|
142
|
+
### Default permissions of zip archives
|
143
|
+
|
144
|
+
On Posix file systems the default file permissions applied to a new archive
|
145
|
+
are (0666 - umask), which mimics the behavior of standard tools such as `touch`.
|
146
|
+
|
147
|
+
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).
|
149
|
+
|
150
|
+
When modifying a zip archive the file permissions of the archive are preserved.
|
151
|
+
|
152
|
+
### Reading a Zip file
|
153
|
+
|
154
|
+
```ruby
|
155
|
+
MAX_SIZE = 1024**2 # 1MiB (but of course you can increase this)
|
156
|
+
Zip::File.open('foo.zip') do |zip_file|
|
157
|
+
# Handle entries one by one
|
158
|
+
zip_file.each do |entry|
|
159
|
+
puts "Extracting #{entry.name}"
|
160
|
+
raise 'File too large when extracted' if entry.size > MAX_SIZE
|
161
|
+
|
162
|
+
# Extract to file or directory based on name in the archive
|
163
|
+
entry.extract
|
164
|
+
|
165
|
+
# Read into memory
|
166
|
+
content = entry.get_input_stream.read
|
167
|
+
end
|
168
|
+
|
169
|
+
# Find specific entry
|
170
|
+
entry = zip_file.glob('*.csv').first
|
171
|
+
raise 'File too large when extracted' if entry.size > MAX_SIZE
|
172
|
+
puts entry.get_input_stream.read
|
173
|
+
end
|
174
|
+
```
|
175
|
+
|
176
|
+
#### Notice about ::Zip::InputStream
|
177
|
+
|
178
|
+
`::Zip::InputStream` usable for fast reading zip file content because it not read Central directory.
|
179
|
+
|
180
|
+
But there is one exception when it is not working - General Purpose Flag Bit 3.
|
181
|
+
|
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
|
183
|
+
|
184
|
+
If `::Zip::InputStream` finds such entry in the zip archive it will raise an exception.
|
185
|
+
|
186
|
+
### Password Protection (Experimental)
|
187
|
+
|
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.:
|
189
|
+
|
190
|
+
```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
|
195
|
+
```
|
196
|
+
|
197
|
+
This is an experimental feature and the interface for encryption may change in future versions.
|
198
|
+
|
199
|
+
## Known issues
|
200
|
+
|
201
|
+
### Modify docx file with rubyzip
|
202
|
+
|
203
|
+
Use `write_buffer` instead `open`. Thanks to @jondruse
|
204
|
+
|
205
|
+
```ruby
|
206
|
+
buffer = Zip::OutputStream.write_buffer do |out|
|
207
|
+
@zip_file.entries.each do |e|
|
208
|
+
unless [DOCUMENT_FILE_PATH, RELS_FILE_PATH].include?(e.name)
|
209
|
+
out.put_next_entry(e.name)
|
210
|
+
out.write e.get_input_stream.read
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
out.put_next_entry(DOCUMENT_FILE_PATH)
|
215
|
+
out.write xml_doc.to_xml(:indent => 0).gsub("\n","")
|
216
|
+
|
217
|
+
out.put_next_entry(RELS_FILE_PATH)
|
218
|
+
out.write rels.to_xml(:indent => 0).gsub("\n","")
|
219
|
+
end
|
220
|
+
|
221
|
+
File.open(new_path, "wb") {|f| f.write(buffer.string) }
|
222
|
+
```
|
223
|
+
|
224
|
+
## Configuration
|
225
|
+
|
226
|
+
### Existing Files
|
227
|
+
|
228
|
+
By default, rubyzip will not overwrite files if they already exist inside of the extracted path. To change this behavior, you may specify a configuration option like so:
|
229
|
+
|
230
|
+
```ruby
|
231
|
+
Zip.on_exists_proc = true
|
232
|
+
```
|
233
|
+
|
234
|
+
If you're using rubyzip with rails, consider placing this snippet of code in an initializer file such as `config/initializers/rubyzip.rb`
|
235
|
+
|
236
|
+
Additionally, if you want to configure rubyzip to overwrite existing files while creating a .zip file, you can do so with the following:
|
237
|
+
|
238
|
+
```ruby
|
239
|
+
Zip.continue_on_exists_proc = true
|
240
|
+
```
|
241
|
+
|
242
|
+
### Non-ASCII Names
|
243
|
+
|
244
|
+
If you want to store non-english names and want to open them on Windows(pre 7) you need to set this option:
|
245
|
+
|
246
|
+
```ruby
|
247
|
+
Zip.unicode_names = true
|
248
|
+
```
|
249
|
+
|
250
|
+
Sometimes file names inside zip contain non-ASCII characters. If you can assume which encoding was used for such names and want to be able to find such entries using `find_entry` then you can force assumed encoding like so:
|
251
|
+
|
252
|
+
```ruby
|
253
|
+
Zip.force_entry_names_encoding = 'UTF-8'
|
254
|
+
```
|
255
|
+
|
256
|
+
Allowed encoding names are the same as accepted by `String#force_encoding`
|
257
|
+
|
258
|
+
### Date Validation
|
259
|
+
|
260
|
+
Some zip files might have an invalid date format, which will raise a warning. You can hide this warning with the following setting:
|
261
|
+
|
262
|
+
```ruby
|
263
|
+
Zip.warn_invalid_date = false
|
264
|
+
```
|
265
|
+
|
266
|
+
### Size Validation
|
267
|
+
|
268
|
+
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
|
+
|
270
|
+
```ruby
|
271
|
+
MAX_FILE_SIZE = 10 * 1024**2 # 10MiB
|
272
|
+
MAX_FILES = 100
|
273
|
+
Zip::File.open('foo.zip') do |zip_file|
|
274
|
+
num_files = 0
|
275
|
+
zip_file.each do |entry|
|
276
|
+
num_files += 1 if entry.file?
|
277
|
+
raise 'Too many extracted files' if num_files > MAX_FILES
|
278
|
+
raise 'File too large when extracted' if entry.size > MAX_FILE_SIZE
|
279
|
+
entry.extract
|
280
|
+
end
|
281
|
+
end
|
282
|
+
```
|
283
|
+
|
284
|
+
If you need to extract zip files that report incorrect uncompressed sizes and you really trust them not too be too large, you can disable this setting with
|
285
|
+
```ruby
|
286
|
+
Zip.validate_entry_sizes = false
|
287
|
+
```
|
288
|
+
|
289
|
+
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
|
+
|
291
|
+
### Default Compression
|
292
|
+
|
293
|
+
You can set the default compression level like so:
|
294
|
+
|
295
|
+
```ruby
|
296
|
+
Zip.default_compression = Zlib::DEFAULT_COMPRESSION
|
297
|
+
```
|
298
|
+
|
299
|
+
It defaults to `Zlib::DEFAULT_COMPRESSION`. Possible values are `Zlib::BEST_COMPRESSION`, `Zlib::DEFAULT_COMPRESSION` and `Zlib::NO_COMPRESSION`
|
300
|
+
|
301
|
+
### Zip64 Support
|
302
|
+
|
303
|
+
By default, Zip64 support is disabled for writing. To enable it do this:
|
304
|
+
|
305
|
+
```ruby
|
306
|
+
Zip.write_zip64_support = true
|
307
|
+
```
|
308
|
+
|
309
|
+
_NOTE_: If you will enable Zip64 writing then you will need zip extractor with Zip64 support to extract archive.
|
310
|
+
|
311
|
+
### Block Form
|
312
|
+
|
313
|
+
You can set multiple settings at the same time by using a block:
|
314
|
+
|
315
|
+
```ruby
|
316
|
+
Zip.setup do |c|
|
317
|
+
c.on_exists_proc = true
|
318
|
+
c.continue_on_exists_proc = true
|
319
|
+
c.unicode_names = true
|
320
|
+
c.default_compression = Zlib::BEST_COMPRESSION
|
321
|
+
end
|
322
|
+
```
|
323
|
+
|
324
|
+
## Developing
|
325
|
+
|
326
|
+
To run the test you need to do this:
|
327
|
+
|
328
|
+
```
|
329
|
+
bundle install
|
330
|
+
rake
|
331
|
+
```
|
332
|
+
|
333
|
+
## Website and Project Home
|
334
|
+
|
335
|
+
http://github.com/rubyzip/rubyzip
|
336
|
+
|
337
|
+
http://rdoc.info/github/rubyzip/rubyzip/master/frames
|
338
|
+
|
339
|
+
## Authors
|
340
|
+
|
341
|
+
Alexander Simonov ( alex at simonov.me)
|
342
|
+
|
343
|
+
Alan Harper ( alan at aussiegeek.net)
|
344
|
+
|
345
|
+
Thomas Sondergaard (thomas at sondergaard.cc)
|
346
|
+
|
347
|
+
Technorama Ltd. (oss-ruby-zip at technorama.net)
|
348
|
+
|
349
|
+
extra-field support contributed by Tatsuki Sugiura (sugi at nemui.org)
|
350
|
+
|
351
|
+
## License
|
352
|
+
|
353
|
+
Rubyzip is distributed under the same license as ruby. See
|
354
|
+
http://www.ruby-lang.org/en/LICENSE.txt
|
data/Rakefile
CHANGED
@@ -1,110 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'rake/clean'
|
1
|
+
require 'bundler/gem_tasks'
|
5
2
|
require 'rake/testtask'
|
6
|
-
require '
|
7
|
-
require 'rake/gempackagetask'
|
8
|
-
require 'rake/rdoctask'
|
9
|
-
require 'rake/contrib/sshpublisher'
|
10
|
-
require 'net/ftp'
|
11
|
-
|
12
|
-
PKG_NAME = 'rubyzip'
|
13
|
-
PKG_VERSION = File.read('lib/zip/zip.rb').match(/\s+VERSION\s*=\s*'(.*)'/)[1]
|
14
|
-
|
15
|
-
PKG_FILES = FileList.new
|
16
|
-
|
17
|
-
PKG_FILES.add %w{ README NEWS TODO ChangeLog install.rb Rakefile }
|
18
|
-
PKG_FILES.add %w{ samples/*.rb }
|
19
|
-
PKG_FILES.add %w{ test/*.rb }
|
20
|
-
PKG_FILES.add %w{ test/data/* }
|
21
|
-
PKG_FILES.exclude "test/data/generated"
|
22
|
-
PKG_FILES.add %w{ lib/**/*.rb }
|
23
|
-
|
24
|
-
def clobberFromCvsIgnore(path)
|
25
|
-
CLOBBER.add File.readlines(path+'/.cvsignore').map {
|
26
|
-
|f| File.join(path, f.chomp)
|
27
|
-
} rescue StandardError
|
28
|
-
end
|
3
|
+
require 'rubocop/rake_task'
|
29
4
|
|
30
|
-
|
31
|
-
clobberFromCvsIgnore 'samples'
|
32
|
-
clobberFromCvsIgnore 'test'
|
33
|
-
clobberFromCvsIgnore 'test/data'
|
5
|
+
task default: :test
|
34
6
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
# Shortcuts for test targets
|
43
|
-
task :ut => [:test]
|
44
|
-
|
45
|
-
spec = Gem::Specification.new do |s|
|
46
|
-
s.name = PKG_NAME
|
47
|
-
s.version = PKG_VERSION
|
48
|
-
s.author = "Thomas Sondergaard"
|
49
|
-
s.email = "thomas(at)sondergaard.cc"
|
50
|
-
s.homepage = "http://rubyzip.sourceforge.net/"
|
51
|
-
s.platform = Gem::Platform::RUBY
|
52
|
-
s.summary = "rubyzip is a ruby module for reading and writing zip files"
|
53
|
-
s.files = PKG_FILES.to_a
|
54
|
-
s.require_path = 'lib'
|
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
|
55
12
|
end
|
56
13
|
|
57
|
-
|
58
|
-
pkg.need_zip = true
|
59
|
-
pkg.need_tar = true
|
60
|
-
end
|
14
|
+
RuboCop::RakeTask.new
|
61
15
|
|
62
|
-
Rake::
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
#
|
67
|
-
end
|
68
|
-
|
69
|
-
desc "Publish documentation"
|
70
|
-
task :pdoc => [:rdoc] do
|
71
|
-
Rake::SshFreshDirPublisher.
|
72
|
-
new("thomas@rubyzip.sourceforge.net", "/home/groups/r/ru/rubyzip/htdocs", "html").upload
|
73
|
-
end
|
74
|
-
|
75
|
-
desc "Publish package"
|
76
|
-
task :ppackage => [:package] do
|
77
|
-
Net::FTP.open("upload.sourceforge.net",
|
78
|
-
"ftp",
|
79
|
-
ENV['USER']+"@"+ENV['HOSTNAME']) {
|
80
|
-
|ftpclient|
|
81
|
-
ftpclient.passive = true
|
82
|
-
ftpclient.chdir "incoming"
|
83
|
-
Dir['pkg/*.{tgz,zip,gem}'].each {
|
84
|
-
|e|
|
85
|
-
ftpclient.putbinaryfile(e, File.basename(e))
|
86
|
-
}
|
87
|
-
}
|
88
|
-
end
|
89
|
-
|
90
|
-
desc "Generate the ChangeLog file"
|
91
|
-
task :ChangeLog do
|
92
|
-
puts "Updating ChangeLog"
|
93
|
-
system %{cvs2cl}
|
94
|
-
end
|
95
|
-
|
96
|
-
desc "Make a release"
|
97
|
-
task :release => [:tag_release, :pdoc, :ppackage] do
|
98
|
-
end
|
99
|
-
|
100
|
-
desc "Make a release tag"
|
101
|
-
task :tag_release do
|
102
|
-
tag = "release-#{PKG_VERSION.gsub('.','-')}"
|
103
|
-
|
104
|
-
puts "Checking for tag '#{tag}'"
|
105
|
-
if (Regexp.new("^\\s+#{tag}") =~ `cvs log README`)
|
106
|
-
abort "Tag '#{tag}' already exists"
|
107
|
-
end
|
108
|
-
puts "Tagging module with '#{tag}'"
|
109
|
-
system("cvs tag #{tag}")
|
110
|
-
end
|
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
|
data/TODO
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
* Suggestion: Add ZipFile/ZipInputStream example that demonstrates extracting all entries.
|
5
5
|
* Suggestion: ZipFile#extract destination should default to "."
|
6
6
|
* Suggestion: ZipEntry should have extract(), get_input_stream() methods etc
|
7
|
-
* SUggestion: ZipInputStream/ZipOutputStream should accept an IO object in addition to a filename.
|
8
7
|
* (is buffering used anywhere with write?)
|
9
8
|
* Inflater.sysread should pass the buffer to produce_input.
|
10
9
|
* Implement ZipFsDir.glob
|