archive-zip 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/LICENSE +22 -57
  4. data/{NEWS → NEWS.md} +29 -16
  5. data/README.md +250 -0
  6. data/Rakefile +119 -76
  7. data/lib/archive/support/binary_stringio.rb +9 -2
  8. data/lib/archive/support/time.rb +2 -2
  9. data/lib/archive/zip.rb +1 -1
  10. data/lib/archive/zip/entry.rb +2 -2
  11. data/lib/archive/zip/version.rb +1 -1
  12. data/spec/archive/zip/archive_spec.rb +54 -0
  13. data/spec/archive/zip/codec/deflate/compress/checksum_spec.rb +8 -6
  14. data/spec/archive/zip/codec/deflate/compress/close_spec.rb +13 -12
  15. data/spec/archive/zip/codec/deflate/compress/crc32_spec.rb +6 -4
  16. data/spec/archive/zip/codec/deflate/compress/data_descriptor_spec.rb +17 -10
  17. data/spec/archive/zip/codec/deflate/compress/new_spec.rb +7 -5
  18. data/spec/archive/zip/codec/deflate/compress/open_spec.rb +9 -7
  19. data/spec/archive/zip/codec/deflate/compress/write_spec.rb +15 -15
  20. data/spec/archive/zip/codec/deflate/decompress/checksum_spec.rb +6 -4
  21. data/spec/archive/zip/codec/deflate/decompress/close_spec.rb +10 -9
  22. data/spec/archive/zip/codec/deflate/decompress/crc32_spec.rb +6 -4
  23. data/spec/archive/zip/codec/deflate/decompress/data_descriptor_spec.rb +17 -10
  24. data/spec/archive/zip/codec/deflate/decompress/new_spec.rb +5 -3
  25. data/spec/archive/zip/codec/deflate/decompress/open_spec.rb +7 -5
  26. data/spec/archive/zip/codec/null_encryption/decrypt/close_spec.rb +10 -9
  27. data/spec/archive/zip/codec/null_encryption/decrypt/new_spec.rb +6 -4
  28. data/spec/archive/zip/codec/null_encryption/decrypt/open_spec.rb +8 -6
  29. data/spec/archive/zip/codec/null_encryption/decrypt/read_spec.rb +8 -6
  30. data/spec/archive/zip/codec/null_encryption/decrypt/rewind_spec.rb +9 -7
  31. data/spec/archive/zip/codec/null_encryption/decrypt/seek_spec.rb +15 -13
  32. data/spec/archive/zip/codec/null_encryption/decrypt/tell_spec.rb +8 -6
  33. data/spec/archive/zip/codec/null_encryption/encrypt/close_spec.rb +10 -9
  34. data/spec/archive/zip/codec/null_encryption/encrypt/new_spec.rb +5 -3
  35. data/spec/archive/zip/codec/null_encryption/encrypt/open_spec.rb +9 -5
  36. data/spec/archive/zip/codec/null_encryption/encrypt/rewind_spec.rb +9 -7
  37. data/spec/archive/zip/codec/null_encryption/encrypt/seek_spec.rb +15 -13
  38. data/spec/archive/zip/codec/null_encryption/encrypt/tell_spec.rb +11 -9
  39. data/spec/archive/zip/codec/null_encryption/encrypt/write_spec.rb +12 -10
  40. data/spec/archive/zip/codec/store/compress/close_spec.rb +10 -9
  41. data/spec/archive/zip/codec/store/compress/data_descriptor_spec.rb +19 -10
  42. data/spec/archive/zip/codec/store/compress/new_spec.rb +5 -3
  43. data/spec/archive/zip/codec/store/compress/open_spec.rb +7 -5
  44. data/spec/archive/zip/codec/store/compress/rewind_spec.rb +9 -7
  45. data/spec/archive/zip/codec/store/compress/seek_spec.rb +15 -13
  46. data/spec/archive/zip/codec/store/compress/tell_spec.rb +11 -9
  47. data/spec/archive/zip/codec/store/compress/write_spec.rb +10 -10
  48. data/spec/archive/zip/codec/store/decompress/close_spec.rb +10 -9
  49. data/spec/archive/zip/codec/store/decompress/data_descriptor_spec.rb +17 -10
  50. data/spec/archive/zip/codec/store/decompress/new_spec.rb +5 -3
  51. data/spec/archive/zip/codec/store/decompress/open_spec.rb +7 -5
  52. data/spec/archive/zip/codec/store/decompress/read_spec.rb +8 -6
  53. data/spec/archive/zip/codec/store/decompress/rewind_spec.rb +9 -7
  54. data/spec/archive/zip/codec/store/decompress/seek_spec.rb +15 -13
  55. data/spec/archive/zip/codec/store/decompress/tell_spec.rb +8 -6
  56. data/spec/archive/zip/codec/traditional_encryption/decrypt/close_spec.rb +13 -24
  57. data/spec/archive/zip/codec/traditional_encryption/decrypt/new_spec.rb +6 -4
  58. data/spec/archive/zip/codec/traditional_encryption/decrypt/open_spec.rb +10 -6
  59. data/spec/archive/zip/codec/traditional_encryption/decrypt/read_spec.rb +12 -13
  60. data/spec/archive/zip/codec/traditional_encryption/decrypt/rewind_spec.rb +10 -12
  61. data/spec/archive/zip/codec/traditional_encryption/decrypt/seek_spec.rb +16 -18
  62. data/spec/archive/zip/codec/traditional_encryption/decrypt/tell_spec.rb +8 -6
  63. data/spec/archive/zip/codec/traditional_encryption/encrypt/close_spec.rb +13 -24
  64. data/spec/archive/zip/codec/traditional_encryption/encrypt/new_spec.rb +5 -3
  65. data/spec/archive/zip/codec/traditional_encryption/encrypt/open_spec.rb +7 -5
  66. data/spec/archive/zip/codec/traditional_encryption/encrypt/rewind_spec.rb +10 -12
  67. data/spec/archive/zip/codec/traditional_encryption/encrypt/seek_spec.rb +16 -18
  68. data/spec/archive/zip/codec/traditional_encryption/encrypt/tell_spec.rb +12 -14
  69. data/spec/archive/zip/codec/traditional_encryption/encrypt/write_spec.rb +8 -23
  70. data/spec/binary_stringio/new_spec.rb +18 -12
  71. data/spec/binary_stringio/set_encoding_spec.rb +10 -7
  72. data/spec/ioextensions/read_exactly_spec.rb +14 -12
  73. data/spec/zlib/zreader/checksum_spec.rb +10 -8
  74. data/spec/zlib/zreader/close_spec.rb +5 -3
  75. data/spec/zlib/zreader/compressed_size_spec.rb +6 -4
  76. data/spec/zlib/zreader/new_spec.rb +7 -5
  77. data/spec/zlib/zreader/open_spec.rb +9 -7
  78. data/spec/zlib/zreader/read_spec.rb +10 -8
  79. data/spec/zlib/zreader/rewind_spec.rb +7 -5
  80. data/spec/zlib/zreader/seek_spec.rb +13 -11
  81. data/spec/zlib/zreader/tell_spec.rb +8 -6
  82. data/spec/zlib/zreader/uncompressed_size_spec.rb +6 -4
  83. data/spec/zlib/zwriter/checksum_spec.rb +10 -8
  84. data/spec/zlib/zwriter/close_spec.rb +5 -3
  85. data/spec/zlib/zwriter/compressed_size_spec.rb +6 -4
  86. data/spec/zlib/zwriter/new_spec.rb +10 -8
  87. data/spec/zlib/zwriter/open_spec.rb +12 -10
  88. data/spec/zlib/zwriter/rewind_spec.rb +9 -7
  89. data/spec/zlib/zwriter/seek_spec.rb +15 -17
  90. data/spec/zlib/zwriter/tell_spec.rb +11 -9
  91. data/spec/zlib/zwriter/uncompressed_size_spec.rb +6 -4
  92. data/spec/zlib/zwriter/write_spec.rb +9 -9
  93. metadata +268 -217
  94. data/CONTRIBUTORS +0 -13
  95. data/GPL +0 -676
  96. data/HACKING +0 -105
  97. data/LEGAL +0 -8
  98. data/README +0 -151
  99. data/TODO +0 -5
  100. data/default.mspec +0 -8
  101. data/spec_helper.rb +0 -49
data/HACKING DELETED
@@ -1,105 +0,0 @@
1
- = Guide to Hacking Archive::Zip
2
-
3
- == Licensing
4
-
5
- Contributed code must be licensed under the same license as this project. See
6
- the included LICENSE file for details. Special consideration MAY be made in
7
- some cases, but such cases will be rare.
8
-
9
-
10
- == Dependencies
11
-
12
- === Runtime
13
-
14
- * Ruby 1.8.6 or greater
15
- * io-like 0.3.0 or greater
16
-
17
-
18
- === Build
19
-
20
- * rubygems 1.8.8 or greater
21
- * rake 0.9.2 or greater
22
- * rdoc 3.9.2 or greater
23
- * mspec 1.5.17 or greater
24
-
25
-
26
- === Install
27
-
28
- * rubygems 0.9.0 or greater
29
-
30
-
31
- == Versioning Policy
32
-
33
- Version numbers will be in <em>x.y.z</em> format, where <em>x</em>, <em>y</em>,
34
- and <em>z</em> are integers starting from 0. The version increment rules are
35
- as follows:
36
-
37
- <b>x</b>:: Planned releases which implement significant changes and/or break API
38
- compatibility. An exception is to be made for the transition from
39
- the <em>0.y.z</em> series to the <em>1.y.z</em> series since the
40
- <em>0.y.z</em> series is expected to be unstable throughout
41
- development. When incremented, <em>y</em> and <em>z</em> are reset
42
- to 0.
43
- <b>y</b>:: Planned releases which incorporate numerous bug fixes and/or new
44
- features which do not break backward compatibility. When
45
- incremented, <em>z</em> is reset to 0.
46
- <b>z</b>:: Generally, unplanned releases which incorporate a single fix for a
47
- critical defect.
48
-
49
- This is the {Rational Versioning Policy}[http://www.rubygems.org/read/chapter/7]
50
- as outlined in the {RubyGems User Guide}[http://www.rubygems.org/read/book/1].
51
-
52
-
53
- == Support Policy
54
-
55
- Due to limitations in resources (time/money/manpower), this project will focus
56
- primarily upon the development line of the current release at any given time.
57
- Fixes and new features should be applied first to that development line and then
58
- backported to earlier releases if necessary and feasible. Long term maintenance
59
- of previous releases is not planned. Users are generally expected to upgrade to
60
- the latest release in order to receive updates unless an explicit declaration of
61
- support for a previous release is made.
62
-
63
-
64
- == Coding Style
65
-
66
- The following points are not necessarily set in stone but should rather be used
67
- as a good guideline. Consistency is the goal of coding style, and changes will
68
- be more easily accepted if they are consistent with the rest of the code.
69
-
70
- <b>File Encoding</b>:: UTF-8
71
- <b>Indentation</b>:: Two spaces; no tabs
72
- <b>Comments</b>:: Document classes, attributes, methods, and code
73
- <b>Boolean Operators</b>:: Use <tt>&&</tt> and <tt>||</tt> for boolean tests;
74
- avoid <tt>and</tt> and <tt>or</tt>
75
- <b>Method Calls</b>:: Use <tt>a_method(arg, arg, etc)</tt>; <b>not</b>
76
- <tt>a_method( arg, arg, etc )</tt>,
77
- <tt>a_method arg, arg, etc</tt>, or any other
78
- variation
79
- <b>Blocks</b>:: <tt>do end</tt> for multi-line blocks and
80
- <tt>{ }</tt> for single-line blocks
81
- <b>Line length</b>:: Limit lines to a maximum of 80 characters
82
- <b>General</b>:: Try to follow the flow and style of the rest of the
83
- code
84
-
85
-
86
- == Contributing Code
87
-
88
- Making a contribution is pretty simple. Fork the project on Github
89
- (http://github.com/javanthropus/archive-zip), make your changes, and submit a
90
- pull request. Requests that meet the following criteria will be the most
91
- readily accepted:
92
-
93
- 1. Each pull request should target an individual issue and should introduce
94
- relatively few commits.
95
- 2. Individual commits need to be small, easily digestible units.
96
- 3. Good descriptions of the changes introduced should be included in each commit
97
- message.
98
- 4. Interdependencies on existing pull requests need to be noted in the pull
99
- request.
100
- 5. New test cases are a major plus.
101
- 6. Documentation for new classes, methods, etc. is also a win.
102
- 7. The coding style of the project should be respected.
103
-
104
- In other words, the less work necessary to bring your changes into the project,
105
- the faster you can expect them to be pulled.
data/LEGAL DELETED
@@ -1,8 +0,0 @@
1
- = Other Legalities
2
-
3
- == Files Licensed Differently
4
-
5
- The following file(s) are provided under a license or licenses separate from
6
- this project.
7
-
8
- None at present
data/README DELETED
@@ -1,151 +0,0 @@
1
- = Archive::Zip - ZIP Archival Made Easy
2
-
3
- The Archive::Zip library intends to provide a simple, yet complete and
4
- Ruby-esque, interface to working with ZIP archives.
5
-
6
- Basic archive creation and extraction can be handled using only a few methods.
7
- More complex operations involving the manipulation of existing archives in place
8
- (adding, removing, and modifying entries) are also possible with a little more
9
- work. Even adding advanced features such as new compression codecs are
10
- supported with a moderate amount of effort.
11
-
12
-
13
- == License
14
-
15
- Copyright © 2010 Jeremy Bopp <jeremy at bopp dot net>
16
-
17
- Licensed under the same terms as Ruby -- See the included LICENSE file for
18
- details
19
-
20
-
21
- == Installation/Removal
22
-
23
- Download the GEM file and install it with:
24
- % sudo gem install archive-zip-VERSION.gem
25
-
26
- or directly with:
27
- % sudo gem install archive-zip
28
-
29
- Removal is the same in either case:
30
- % sudo gem uninstall archive-zip
31
-
32
-
33
- == Example
34
- More examples can be found in the +examples+ directory of the source
35
- distribution.
36
-
37
- Create a few archives:
38
- gem 'archive-zip' # Use require_gem for rubygems versions older than 0.9.0.
39
- require 'archive/zip'
40
-
41
- # Add a_directory and its contents to example1.zip.
42
- Archive::Zip.archive('example1.zip', 'a_directory')
43
-
44
- # Add the contents of a_directory to example2.zip.
45
- Archive::Zip.archive('example2.zip', 'a_directory/.')
46
-
47
- # Add a_file and a_directory and its contents to example3.zip.
48
- Archive::Zip.archive('example3.zip', ['a_directory', 'a_file'])
49
-
50
- # Add only the files and symlinks contained in a_directory under the path
51
- # a/b/c/a_directory in example4.zip.
52
- Archive::Zip.archive(
53
- 'example4.zip',
54
- 'a_directory',
55
- :directories => false,
56
- :path_prefix => 'a/b/c'
57
- )
58
-
59
- # Add the contents of a_directory to example5.zip and encrypt Ruby source
60
- # files.
61
- require 'archive/zip/codec/null_encryption'
62
- require 'archive/zip/codec/traditional_encryption'
63
- Archive::Zip.archive(
64
- 'example5.zip',
65
- 'a_directory/.',
66
- :encryption_codec => lambda do |entry|
67
- if entry.file? and entry.zip_path =~ /\.rb$/ then
68
- Archive::Zip::Codec::TraditionalEncryption
69
- else
70
- Archive::Zip::Codec::NullEncryption
71
- end
72
- end,
73
- :password => 'seakrit'
74
- )
75
-
76
- # Create a new archive which will be written to a pipe.
77
- # Assume $stdout is the write end a pipe.
78
- # (ruby example.rb | cat >example.zip)
79
- Archive::Zip.open($stdout, :w) do |z|
80
- z.archive('a_directory')
81
- end
82
-
83
- Now extract those archives:
84
- gem 'archive-zip' # Use require_gem for rubygems versions older than 0.9.0.
85
- require 'archive/zip'
86
-
87
- # Extract example1.zip to a_destination.
88
- Archive::Zip.extract('example1.zip', 'a_destination')
89
-
90
- # Extract example2.zip to a_destination, skipping directory entries.
91
- Archive::Zip.extract(
92
- 'example2.zip',
93
- 'a_destination',
94
- :directories => false
95
- )
96
-
97
- # Extract example3.zip to a_destination, skipping symlinks.
98
- Archive::Zip.extract(
99
- 'example3.zip',
100
- 'a_destination',
101
- :symlinks => false
102
- )
103
-
104
- # Extract example4.zip to a_destination, skipping entries for which files
105
- # already exist but are newer or for which files do not exist at all.
106
- Archive::Zip.extract(
107
- 'example4.zip',
108
- 'a_destination',
109
- :create => false,
110
- :overwrite => :older
111
- )
112
-
113
- # Extract example5.zip to a_destination, decrypting the contents.
114
- Archive::Zip.extract('example5.zip', 'a_destination', :password => 'seakrit')
115
-
116
-
117
- == Features
118
-
119
- 1. 100% native Ruby. (Well, almost... depends on zlib.)
120
- 2. Archive creation and extraction is supported with only a few lines of code.
121
- 3. Archives can be updated "in place" or dumped out to other files or pipes.
122
- 4. Files, symlinks, and directories are supported within archives.
123
- 5. Unix permission/mode bits are supported.
124
- 6. Unix user and group ownerships are supported.
125
- 7. Unix last accessed and last modified times are supported.
126
- 8. Entry extension (AKA extra field) implementations can be added on the fly.
127
- 9. Unknown entry extension types are preserved during archive processing.
128
- 10. The Deflate and Store compression codecs are supported out of the box.
129
- 11. More compression codecs can be added on the fly.
130
- 12. Traditional (weak) encryption is supported out of the box.
131
-
132
-
133
- == Known Bugs/Limitations
134
-
135
- 1. More testcases are needed.
136
- 2. All file entries are archived and extracted in binary mode. No attempt is
137
- made to normalize text files to the line ending convention of any target
138
- system.
139
- 3. Hard links and device files are not currently supported within archives.
140
- 4. Reading archives from non-seekable IO, such as pipes and sockets, is not
141
- supported.
142
- 5. MSDOS permission attributes are not supported.
143
- 6. Strong encryption is not supported.
144
- 7. Zip64 is not supported.
145
- 8. Digital signatures are not supported.
146
-
147
-
148
- == Contributing
149
-
150
- Contributions for bug fixes, documentation, extensions, tests, etc. are
151
- encouraged. Please read the file HACKING for details.
data/TODO DELETED
@@ -1,5 +0,0 @@
1
- = Future work items (in no particular order):
2
-
3
- * Add test cases for all classes.
4
- * Add support for using non-seekable IO objects as archive sources.
5
- * Add support for 0x5855 and 0x7855 extra fields.
@@ -1,8 +0,0 @@
1
- # encoding: UTF-8
2
- class MSpecScript
3
- # An ordered list of the directories containing specs to run
4
- set :files, ['spec']
5
-
6
- # The default implementation to run the specs.
7
- set :target, 'ruby'
8
- end
@@ -1,49 +0,0 @@
1
- # encoding: UTF-8
2
- # Add the lib directory for this module to the search path.
3
- $: << File.join(File.dirname(__FILE__), 'lib')
4
-
5
- unless ENV['MSPEC_RUNNER']
6
- begin
7
- require 'mspec/version'
8
- require 'mspec/helpers'
9
- require 'mspec/guards'
10
- require 'mspec/runner/shared'
11
- require 'mspec/matchers/complain'
12
-
13
- # Code to setup HOME directory correctly on Windows
14
- # This duplicates Ruby 1.9 semantics for defining HOME
15
- platform_is :windows do
16
- if ENV['HOME']
17
- ENV['HOME'] = ENV['HOME'].tr '\\', '/'
18
- elsif ENV['HOMEDIR'] && ENV['HOMEDRIVE']
19
- ENV['HOME'] = File.join(ENV['HOMEDRIVE'], ENV['HOMEDIR'])
20
- elsif ENV['HOMEDIR']
21
- ENV['HOME'] = ENV['HOMEDIR']
22
- elsif ENV['HOMEDRIVE']
23
- ENV['HOME'] = ENV['HOMEDRIVE']
24
- elsif ENV['USERPROFILE']
25
- ENV['HOME'] = ENV['USERPROFILE']
26
- else
27
- puts "No suitable HOME environment found. This means that all of"
28
- puts "HOME, HOMEDIR, HOMEDRIVE, and USERPROFILE are not set"
29
- exit 1
30
- end
31
- end
32
-
33
- TOLERANCE = 0.00003 unless Object.const_defined?(:TOLERANCE)
34
- rescue LoadError
35
- puts "Please install the MSpec gem to run the specs."
36
- exit 1
37
- end
38
- end
39
-
40
- minimum_version = "1.5.17"
41
- unless MSpec::VERSION >= minimum_version
42
- puts "Please install MSpec version >= #{minimum_version} to run the specs"
43
- exit 1
44
- end
45
-
46
- # Set a flag when encodings are supported.
47
- MSpec.enable_feature :encoding if Object.const_defined?(:Encoding)
48
-
49
- $VERBOSE = nil unless ENV['OUTPUT_WARNINGS']