archive-zip 0.6.0 → 0.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.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/LICENSE +22 -57
- data/{NEWS → NEWS.md} +29 -16
- data/README.md +250 -0
- data/Rakefile +119 -76
- data/lib/archive/support/binary_stringio.rb +9 -2
- data/lib/archive/support/time.rb +2 -2
- data/lib/archive/zip.rb +1 -1
- data/lib/archive/zip/entry.rb +2 -2
- data/lib/archive/zip/version.rb +1 -1
- data/spec/archive/zip/archive_spec.rb +54 -0
- data/spec/archive/zip/codec/deflate/compress/checksum_spec.rb +8 -6
- data/spec/archive/zip/codec/deflate/compress/close_spec.rb +13 -12
- data/spec/archive/zip/codec/deflate/compress/crc32_spec.rb +6 -4
- data/spec/archive/zip/codec/deflate/compress/data_descriptor_spec.rb +17 -10
- data/spec/archive/zip/codec/deflate/compress/new_spec.rb +7 -5
- data/spec/archive/zip/codec/deflate/compress/open_spec.rb +9 -7
- data/spec/archive/zip/codec/deflate/compress/write_spec.rb +15 -15
- data/spec/archive/zip/codec/deflate/decompress/checksum_spec.rb +6 -4
- data/spec/archive/zip/codec/deflate/decompress/close_spec.rb +10 -9
- data/spec/archive/zip/codec/deflate/decompress/crc32_spec.rb +6 -4
- data/spec/archive/zip/codec/deflate/decompress/data_descriptor_spec.rb +17 -10
- data/spec/archive/zip/codec/deflate/decompress/new_spec.rb +5 -3
- data/spec/archive/zip/codec/deflate/decompress/open_spec.rb +7 -5
- data/spec/archive/zip/codec/null_encryption/decrypt/close_spec.rb +10 -9
- data/spec/archive/zip/codec/null_encryption/decrypt/new_spec.rb +6 -4
- data/spec/archive/zip/codec/null_encryption/decrypt/open_spec.rb +8 -6
- data/spec/archive/zip/codec/null_encryption/decrypt/read_spec.rb +8 -6
- data/spec/archive/zip/codec/null_encryption/decrypt/rewind_spec.rb +9 -7
- data/spec/archive/zip/codec/null_encryption/decrypt/seek_spec.rb +15 -13
- data/spec/archive/zip/codec/null_encryption/decrypt/tell_spec.rb +8 -6
- data/spec/archive/zip/codec/null_encryption/encrypt/close_spec.rb +10 -9
- data/spec/archive/zip/codec/null_encryption/encrypt/new_spec.rb +5 -3
- data/spec/archive/zip/codec/null_encryption/encrypt/open_spec.rb +9 -5
- data/spec/archive/zip/codec/null_encryption/encrypt/rewind_spec.rb +9 -7
- data/spec/archive/zip/codec/null_encryption/encrypt/seek_spec.rb +15 -13
- data/spec/archive/zip/codec/null_encryption/encrypt/tell_spec.rb +11 -9
- data/spec/archive/zip/codec/null_encryption/encrypt/write_spec.rb +12 -10
- data/spec/archive/zip/codec/store/compress/close_spec.rb +10 -9
- data/spec/archive/zip/codec/store/compress/data_descriptor_spec.rb +19 -10
- data/spec/archive/zip/codec/store/compress/new_spec.rb +5 -3
- data/spec/archive/zip/codec/store/compress/open_spec.rb +7 -5
- data/spec/archive/zip/codec/store/compress/rewind_spec.rb +9 -7
- data/spec/archive/zip/codec/store/compress/seek_spec.rb +15 -13
- data/spec/archive/zip/codec/store/compress/tell_spec.rb +11 -9
- data/spec/archive/zip/codec/store/compress/write_spec.rb +10 -10
- data/spec/archive/zip/codec/store/decompress/close_spec.rb +10 -9
- data/spec/archive/zip/codec/store/decompress/data_descriptor_spec.rb +17 -10
- data/spec/archive/zip/codec/store/decompress/new_spec.rb +5 -3
- data/spec/archive/zip/codec/store/decompress/open_spec.rb +7 -5
- data/spec/archive/zip/codec/store/decompress/read_spec.rb +8 -6
- data/spec/archive/zip/codec/store/decompress/rewind_spec.rb +9 -7
- data/spec/archive/zip/codec/store/decompress/seek_spec.rb +15 -13
- data/spec/archive/zip/codec/store/decompress/tell_spec.rb +8 -6
- data/spec/archive/zip/codec/traditional_encryption/decrypt/close_spec.rb +13 -24
- data/spec/archive/zip/codec/traditional_encryption/decrypt/new_spec.rb +6 -4
- data/spec/archive/zip/codec/traditional_encryption/decrypt/open_spec.rb +10 -6
- data/spec/archive/zip/codec/traditional_encryption/decrypt/read_spec.rb +12 -13
- data/spec/archive/zip/codec/traditional_encryption/decrypt/rewind_spec.rb +10 -12
- data/spec/archive/zip/codec/traditional_encryption/decrypt/seek_spec.rb +16 -18
- data/spec/archive/zip/codec/traditional_encryption/decrypt/tell_spec.rb +8 -6
- data/spec/archive/zip/codec/traditional_encryption/encrypt/close_spec.rb +13 -24
- data/spec/archive/zip/codec/traditional_encryption/encrypt/new_spec.rb +5 -3
- data/spec/archive/zip/codec/traditional_encryption/encrypt/open_spec.rb +7 -5
- data/spec/archive/zip/codec/traditional_encryption/encrypt/rewind_spec.rb +10 -12
- data/spec/archive/zip/codec/traditional_encryption/encrypt/seek_spec.rb +16 -18
- data/spec/archive/zip/codec/traditional_encryption/encrypt/tell_spec.rb +12 -14
- data/spec/archive/zip/codec/traditional_encryption/encrypt/write_spec.rb +8 -23
- data/spec/binary_stringio/new_spec.rb +18 -12
- data/spec/binary_stringio/set_encoding_spec.rb +10 -7
- data/spec/ioextensions/read_exactly_spec.rb +14 -12
- data/spec/zlib/zreader/checksum_spec.rb +10 -8
- data/spec/zlib/zreader/close_spec.rb +5 -3
- data/spec/zlib/zreader/compressed_size_spec.rb +6 -4
- data/spec/zlib/zreader/new_spec.rb +7 -5
- data/spec/zlib/zreader/open_spec.rb +9 -7
- data/spec/zlib/zreader/read_spec.rb +10 -8
- data/spec/zlib/zreader/rewind_spec.rb +7 -5
- data/spec/zlib/zreader/seek_spec.rb +13 -11
- data/spec/zlib/zreader/tell_spec.rb +8 -6
- data/spec/zlib/zreader/uncompressed_size_spec.rb +6 -4
- data/spec/zlib/zwriter/checksum_spec.rb +10 -8
- data/spec/zlib/zwriter/close_spec.rb +5 -3
- data/spec/zlib/zwriter/compressed_size_spec.rb +6 -4
- data/spec/zlib/zwriter/new_spec.rb +10 -8
- data/spec/zlib/zwriter/open_spec.rb +12 -10
- data/spec/zlib/zwriter/rewind_spec.rb +9 -7
- data/spec/zlib/zwriter/seek_spec.rb +15 -17
- data/spec/zlib/zwriter/tell_spec.rb +11 -9
- data/spec/zlib/zwriter/uncompressed_size_spec.rb +6 -4
- data/spec/zlib/zwriter/write_spec.rb +9 -9
- metadata +268 -217
- data/CONTRIBUTORS +0 -13
- data/GPL +0 -676
- data/HACKING +0 -105
- data/LEGAL +0 -8
- data/README +0 -151
- data/TODO +0 -5
- data/default.mspec +0 -8
- data/spec_helper.rb +0 -49
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 392506a75d8d411a81f373e7615de05e8e253007
|
|
4
|
+
data.tar.gz: 6d099f03a5b075ab68265eb3918ad8d657d6ee5e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa9900725853cb1ee4a92a9484696e39091128403f0d6bd887bd54313769ce623fd25f1a82d7a151066c0613e1280da041b8ca0800fb6e203ca660a05c8e7f85
|
|
7
|
+
data.tar.gz: 2b7e98ea155628cbd446f36c2e2894242a472176ef8f4ed8e8bcbdbf8562a2dcd5814d2a72a018e2563264e8514dfa23d9b374b37683b757c191ec63a70dab21
|
data/.yardopts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--protected --private --plugin redcarpet-ext --main README.md lib/**/*.rb - NEWS.md LICENSE
|
data/LICENSE
CHANGED
|
@@ -1,57 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
c) rename any non-standard executables so the names do not conflict
|
|
24
|
-
with standard executables, which must also be provided.
|
|
25
|
-
|
|
26
|
-
d) make other distribution arrangements with the author.
|
|
27
|
-
|
|
28
|
-
3. You may distribute the software in object code or executable
|
|
29
|
-
form, provided that you do at least ONE of the following:
|
|
30
|
-
|
|
31
|
-
a) distribute the executables and library files of the software,
|
|
32
|
-
together with instructions (in the manual page or equivalent)
|
|
33
|
-
on where to get the original distribution.
|
|
34
|
-
|
|
35
|
-
b) accompany the distribution with the machine-readable source of
|
|
36
|
-
the software.
|
|
37
|
-
|
|
38
|
-
c) give non-standard executables non-standard names, with
|
|
39
|
-
instructions on where to get the original software distribution.
|
|
40
|
-
|
|
41
|
-
d) make other distribution arrangements with the author.
|
|
42
|
-
|
|
43
|
-
4. You may modify and include the covered part of the software into any
|
|
44
|
-
other software (possibly commercial). But some files in the
|
|
45
|
-
distribution may not be written by the author, such that they are not
|
|
46
|
-
under these terms. (See the file LEGAL for a listing and conditions)
|
|
47
|
-
|
|
48
|
-
5. The scripts and library files supplied as input to or produced as
|
|
49
|
-
output from the software do not automatically fall under the
|
|
50
|
-
copyright of the software, but belong to whomever generated them,
|
|
51
|
-
and may be sold commercially, and may be aggregated with this
|
|
52
|
-
software.
|
|
53
|
-
|
|
54
|
-
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
|
55
|
-
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
56
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
57
|
-
PURPOSE.
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 Jeremy Bopp
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/{NEWS → NEWS.md}
RENAMED
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
# News and Notifications by Version
|
|
2
2
|
|
|
3
3
|
This file lists noteworthy changes which may affect users of this project. More
|
|
4
4
|
detailed information is available in the rest of the documentation.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
**NOTE:** Date stamps in the following entries are in YYYY/MM/DD format.
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## v0.7.0 (2014/08/18)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
### Fixes
|
|
12
|
+
|
|
13
|
+
* Avoid corrupting the archive when storing entries that have multibyte names.
|
|
14
|
+
|
|
15
|
+
### Notes
|
|
16
|
+
|
|
17
|
+
* Ruby 1.8.6 support has been dropped.
|
|
18
|
+
* This may come back if demand warrants it.
|
|
19
|
+
* Switched to the MIT license.
|
|
20
|
+
* Now using minitest instead of mspec for tests.
|
|
21
|
+
|
|
22
|
+
## v0.6.0 (2013/03/24)
|
|
23
|
+
|
|
24
|
+
### Fixes
|
|
12
25
|
|
|
13
26
|
* Only define Zlib constants when they are not already defined.
|
|
14
27
|
* Fixes constant redefinition warnings under MRI 2.0.0-p0.
|
|
@@ -18,27 +31,27 @@ detailed information is available in the rest of the documentation.
|
|
|
18
31
|
#adler methods appear inconsistent for raw streams and really aren't
|
|
19
32
|
necessary in this case anyway.
|
|
20
33
|
|
|
21
|
-
|
|
34
|
+
### Notes
|
|
22
35
|
|
|
23
36
|
* Broke backward compatibility with the behavior of Zlib::ZWriter#checksum and
|
|
24
37
|
Zlib::ZReader#checksum when working with raw streams.
|
|
25
38
|
* This should not affect direct users of Archive::Zip because the checksum
|
|
26
39
|
methods of those classes are never used.
|
|
27
40
|
|
|
28
|
-
|
|
41
|
+
## v0.5.0 (2012/03/01)
|
|
29
42
|
|
|
30
|
-
|
|
43
|
+
### Fixes
|
|
31
44
|
|
|
32
45
|
* Avoid timezone discrepancies in encryption tests.
|
|
33
46
|
* Moved the DOSTime class to the Archive namespace (Chris Schneider).
|
|
34
47
|
|
|
35
|
-
|
|
48
|
+
### Notes
|
|
36
49
|
|
|
37
50
|
* Broke backward compatibility of the DOSTime class.
|
|
38
51
|
|
|
39
|
-
|
|
52
|
+
## v0.4.0 (2011/08/29)
|
|
40
53
|
|
|
41
|
-
|
|
54
|
+
### Features
|
|
42
55
|
|
|
43
56
|
* Added Ruby 1.9 support.
|
|
44
57
|
* Simplified arguments for Archive::Zip.new.
|
|
@@ -48,27 +61,27 @@ detailed information is available in the rest of the documentation.
|
|
|
48
61
|
* Updated and simplified rake tasks.
|
|
49
62
|
* Created a standalone gemspec file.
|
|
50
63
|
|
|
51
|
-
|
|
64
|
+
### Fixes
|
|
52
65
|
|
|
53
66
|
* Fixed a potential data loss bug in Zlib::ZReader.
|
|
54
67
|
* Archives larger than the maximum Fixnum for the platform don't falsely raise a
|
|
55
68
|
"non-integer windows position given" error.
|
|
56
69
|
|
|
57
|
-
|
|
70
|
+
### Notes
|
|
58
71
|
|
|
59
72
|
* Broke backward compatibility for Archive::Zip.new.
|
|
60
73
|
* Wrapper class methods continue to work as before.
|
|
61
74
|
* Broke backward compatibility for Archive::Zip::ExtraField.
|
|
62
75
|
* Allows separate handling of extra fields in central and local records.
|
|
63
76
|
|
|
64
|
-
|
|
77
|
+
## v0.3.0 (2009/01/23)
|
|
65
78
|
|
|
66
79
|
* Made a significant performance improvement for the extraction of compressed
|
|
67
80
|
entries for performance on par with InfoZIP's unzip. Parsing archives with
|
|
68
81
|
many entries is still a bit subpar however.
|
|
69
82
|
|
|
70
83
|
|
|
71
|
-
|
|
84
|
+
## v0.2.0 (2008/08/06)
|
|
72
85
|
|
|
73
86
|
* Traditional (weak) encryption is now supported.
|
|
74
87
|
* Adding new encryption methods should be easier now.
|
|
@@ -78,14 +91,14 @@ detailed information is available in the rest of the documentation.
|
|
|
78
91
|
the _codec_ attribute to access the compression codec of the entry.
|
|
79
92
|
|
|
80
93
|
|
|
81
|
-
|
|
94
|
+
## v0.1.1 (2008/07/11)
|
|
82
95
|
|
|
83
96
|
* Archive files are now closed when the Archive::Zip object is closed even when
|
|
84
97
|
no changes were made to the archive, a problem on Windows if you want to
|
|
85
98
|
delete the archive after extracting it within the same script.
|
|
86
99
|
|
|
87
100
|
|
|
88
|
-
|
|
101
|
+
## v0.1.0 (2008/07/10)
|
|
89
102
|
|
|
90
103
|
* Initial release.
|
|
91
104
|
* Archive creation and extraction is supported with only a few lines of code.
|
data/README.md
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# Archive::Zip - ZIP Archival Made Easy
|
|
2
|
+
|
|
3
|
+
Simple, extensible, pure Ruby ZIP archive support.
|
|
4
|
+
|
|
5
|
+
Basic archive creation and extraction can be handled using only a few methods.
|
|
6
|
+
More complex operations involving the manipulation of existing archives in place
|
|
7
|
+
(adding, removing, and modifying entries) are also possible with a little more
|
|
8
|
+
work. Even adding advanced features such as new compression codecs are
|
|
9
|
+
supported with a moderate amount of effort.
|
|
10
|
+
|
|
11
|
+
## LINKS
|
|
12
|
+
|
|
13
|
+
* Homepage :: http://github.com/javanthropus/archive-zip
|
|
14
|
+
* Documentation :: http://rdoc.info/gems/archive-zip/frames
|
|
15
|
+
* Source :: http://github.com/javanthropus/archive-zip
|
|
16
|
+
|
|
17
|
+
## DESCRIPTION
|
|
18
|
+
|
|
19
|
+
Archive::Zip provides a simple Ruby-esque interface to creating, extracting, and
|
|
20
|
+
updating ZIP archives. This implementation is 100% Ruby and loosely modeled on
|
|
21
|
+
the archive creation and extraction capabilities of InfoZip's zip and unzip
|
|
22
|
+
tools.
|
|
23
|
+
|
|
24
|
+
## FEATURES
|
|
25
|
+
|
|
26
|
+
* 100% native Ruby. (Well, almost... depends on zlib.)
|
|
27
|
+
* Archive creation and extraction is supported with only a few lines of code.
|
|
28
|
+
* Archives can be updated "in place" or dumped out to other files or pipes.
|
|
29
|
+
* Files, symlinks, and directories are supported within archives.
|
|
30
|
+
* Unix permission/mode bits are supported.
|
|
31
|
+
* Unix user and group ownerships are supported.
|
|
32
|
+
* Unix last accessed and last modified times are supported.
|
|
33
|
+
* Entry extension (AKA extra field) implementations can be added on the fly.
|
|
34
|
+
* Unknown entry extension types are preserved during archive processing.
|
|
35
|
+
* The Deflate and Store compression codecs are supported out of the box.
|
|
36
|
+
* More compression codecs can be added on the fly.
|
|
37
|
+
* Traditional (weak) encryption is supported out of the box.
|
|
38
|
+
|
|
39
|
+
## KNOWN BUGS/LIMITATIONS
|
|
40
|
+
|
|
41
|
+
* More testcases are needed.
|
|
42
|
+
* All file entries are archived and extracted in binary mode. No attempt is
|
|
43
|
+
made to normalize text files to the line ending convention of any target
|
|
44
|
+
system.
|
|
45
|
+
* Hard links and device files are not currently supported within archives.
|
|
46
|
+
* Reading archives from non-seekable IO, such as pipes and sockets, is not
|
|
47
|
+
supported.
|
|
48
|
+
* MSDOS permission attributes are not supported.
|
|
49
|
+
* Strong encryption is not supported.
|
|
50
|
+
* Zip64 is not supported.
|
|
51
|
+
* Digital signatures are not supported.
|
|
52
|
+
|
|
53
|
+
## SYNOPSIS
|
|
54
|
+
|
|
55
|
+
More examples can be found in the `examples` directory of the source
|
|
56
|
+
distribution.
|
|
57
|
+
|
|
58
|
+
Create a few archives:
|
|
59
|
+
|
|
60
|
+
```ruby
|
|
61
|
+
require 'archive/zip'
|
|
62
|
+
|
|
63
|
+
# Add a_directory and its contents to example1.zip.
|
|
64
|
+
Archive::Zip.archive('example1.zip', 'a_directory')
|
|
65
|
+
|
|
66
|
+
# Add the contents of a_directory to example2.zip.
|
|
67
|
+
Archive::Zip.archive('example2.zip', 'a_directory/.')
|
|
68
|
+
|
|
69
|
+
# Add a_file and a_directory and its contents to example3.zip.
|
|
70
|
+
Archive::Zip.archive('example3.zip', ['a_directory', 'a_file'])
|
|
71
|
+
|
|
72
|
+
# Add only the files and symlinks contained in a_directory under the path
|
|
73
|
+
# a/b/c/a_directory in example4.zip.
|
|
74
|
+
Archive::Zip.archive(
|
|
75
|
+
'example4.zip',
|
|
76
|
+
'a_directory',
|
|
77
|
+
:directories => false,
|
|
78
|
+
:path_prefix => 'a/b/c'
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
# Add the contents of a_directory to example5.zip and encrypt Ruby source
|
|
82
|
+
# files.
|
|
83
|
+
require 'archive/zip/codec/null_encryption'
|
|
84
|
+
require 'archive/zip/codec/traditional_encryption'
|
|
85
|
+
Archive::Zip.archive(
|
|
86
|
+
'example5.zip',
|
|
87
|
+
'a_directory/.',
|
|
88
|
+
:encryption_codec => lambda do |entry|
|
|
89
|
+
if entry.file? and entry.zip_path =~ /\.rb$/ then
|
|
90
|
+
Archive::Zip::Codec::TraditionalEncryption
|
|
91
|
+
else
|
|
92
|
+
Archive::Zip::Codec::NullEncryption
|
|
93
|
+
end
|
|
94
|
+
end,
|
|
95
|
+
:password => 'seakrit'
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
# Create a new archive which will be written to a pipe.
|
|
99
|
+
# Assume $stdout is the write end a pipe.
|
|
100
|
+
# (ruby example.rb | cat >example.zip)
|
|
101
|
+
Archive::Zip.open($stdout, :w) do |z|
|
|
102
|
+
z.archive('a_directory')
|
|
103
|
+
end
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Now extract those archives:
|
|
107
|
+
|
|
108
|
+
```ruby
|
|
109
|
+
require 'archive/zip'
|
|
110
|
+
|
|
111
|
+
# Extract example1.zip to a_destination.
|
|
112
|
+
Archive::Zip.extract('example1.zip', 'a_destination')
|
|
113
|
+
|
|
114
|
+
# Extract example2.zip to a_destination, skipping directory entries.
|
|
115
|
+
Archive::Zip.extract(
|
|
116
|
+
'example2.zip',
|
|
117
|
+
'a_destination',
|
|
118
|
+
:directories => false
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
# Extract example3.zip to a_destination, skipping symlinks.
|
|
122
|
+
Archive::Zip.extract(
|
|
123
|
+
'example3.zip',
|
|
124
|
+
'a_destination',
|
|
125
|
+
:symlinks => false
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
# Extract example4.zip to a_destination, skipping entries for which files
|
|
129
|
+
# already exist but are newer or for which files do not exist at all.
|
|
130
|
+
Archive::Zip.extract(
|
|
131
|
+
'example4.zip',
|
|
132
|
+
'a_destination',
|
|
133
|
+
:create => false,
|
|
134
|
+
:overwrite => :older
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
# Extract example5.zip to a_destination, decrypting the contents.
|
|
138
|
+
Archive::Zip.extract(
|
|
139
|
+
'example5.zip',
|
|
140
|
+
'a_destination',
|
|
141
|
+
:password => 'seakrit'
|
|
142
|
+
)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## FUTURE WORK ITEMS (in no particular order):
|
|
146
|
+
|
|
147
|
+
* Add test cases for all classes.
|
|
148
|
+
* Add support for using non-seekable IO objects as archive sources.
|
|
149
|
+
* Add support for 0x5855 and 0x7855 extra fields.
|
|
150
|
+
|
|
151
|
+
## REQUIREMENTS
|
|
152
|
+
|
|
153
|
+
* io-like
|
|
154
|
+
|
|
155
|
+
## INSTALL
|
|
156
|
+
|
|
157
|
+
Download the GEM file and install it with:
|
|
158
|
+
|
|
159
|
+
$ gem install archive-zip-VERSION.gem
|
|
160
|
+
|
|
161
|
+
or directly with:
|
|
162
|
+
|
|
163
|
+
$ gem install archive-zip
|
|
164
|
+
|
|
165
|
+
Removal is the same in either case:
|
|
166
|
+
|
|
167
|
+
$ gem uninstall archive-zip
|
|
168
|
+
|
|
169
|
+
## DEVELOPERS
|
|
170
|
+
|
|
171
|
+
After checking out the source, run:
|
|
172
|
+
|
|
173
|
+
$ bundle install
|
|
174
|
+
$ bundle exec rake test yard
|
|
175
|
+
|
|
176
|
+
This will install all dependencies, run the tests/specs, and generate the
|
|
177
|
+
documentation.
|
|
178
|
+
|
|
179
|
+
## AUTHORS and CONTRIBUTORS
|
|
180
|
+
|
|
181
|
+
Thanks to all contributors. Without your help this project would not exist.
|
|
182
|
+
|
|
183
|
+
* Jeremy Bopp :: jeremy@bopp.net
|
|
184
|
+
|
|
185
|
+
## CONTRIBUTING
|
|
186
|
+
|
|
187
|
+
Contributions for bug fixes, documentation, extensions, tests, etc. are
|
|
188
|
+
encouraged.
|
|
189
|
+
|
|
190
|
+
1. Clone the repository.
|
|
191
|
+
2. Fix a bug or add a feature.
|
|
192
|
+
3. Add tests for the fix or feature.
|
|
193
|
+
4. Make a pull request.
|
|
194
|
+
|
|
195
|
+
### CODING STYLE
|
|
196
|
+
|
|
197
|
+
The following points are not necessarily set in stone but should rather be used
|
|
198
|
+
as a good guideline. Consistency is the goal of coding style, and changes will
|
|
199
|
+
be more easily accepted if they are consistent with the rest of the code.
|
|
200
|
+
|
|
201
|
+
* **File Encoding**
|
|
202
|
+
* UTF-8
|
|
203
|
+
* **Indentation**
|
|
204
|
+
* Two spaces; no tabs
|
|
205
|
+
* **Line length**
|
|
206
|
+
* Limit lines to a maximum of 80 characters
|
|
207
|
+
* **Comments**
|
|
208
|
+
* Document classes, attributes, methods, and code
|
|
209
|
+
* **Method Calls with Arguments**
|
|
210
|
+
* Use `a_method(arg, arg, etc)`; **not** `a_method( arg, arg, etc )`,
|
|
211
|
+
`a_method arg, arg, etc`, or any other variation
|
|
212
|
+
* **Method Calls without Arguments**
|
|
213
|
+
* Use `a_method`; avoid parenthesis
|
|
214
|
+
* **String Literals**
|
|
215
|
+
* Use single quotes by default
|
|
216
|
+
* Use double quotes when interpolation is necessary
|
|
217
|
+
* Use `%{...}` and similar when embedding the quoting character is cumbersome
|
|
218
|
+
* **Blocks**
|
|
219
|
+
* `do ... end` for multi-line blocks and `{ ... }` for single-line blocks
|
|
220
|
+
* **Boolean Operators**
|
|
221
|
+
* Use `&&` and `||` for boolean tests; avoid `and` and `or`
|
|
222
|
+
* **In General**
|
|
223
|
+
* Try to follow the flow and style of the rest of the code
|
|
224
|
+
|
|
225
|
+
## LICENSE
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
(The MIT License)
|
|
229
|
+
|
|
230
|
+
Copyright (c) 2014 Jeremy Bopp
|
|
231
|
+
|
|
232
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
233
|
+
a copy of this software and associated documentation files (the
|
|
234
|
+
'Software'), to deal in the Software without restriction, including
|
|
235
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
236
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
237
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
238
|
+
the following conditions:
|
|
239
|
+
|
|
240
|
+
The above copyright notice and this permission notice shall be
|
|
241
|
+
included in all copies or substantial portions of the Software.
|
|
242
|
+
|
|
243
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
244
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
245
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
246
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
247
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
248
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
249
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
250
|
+
```
|