Zippo is a fast zip library for ruby.
A benchmark is available.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install zippo
It can be called in block form:
.("file.zip") do |zip| str = zip["file.txt"] other = zip["other/file.txt"] puts str end
Or without a block:
zip = .("file.zip") puts zip["file.txt"] zip.close
Inserting archive members
Files can be inserted into the zip using the insert method. Note that no data will be written until the ZipFile is closed:
zip = .("out.zip", "w") zip.insert "file1.txt", "path/to/1.txt" zip.insert "file2.txt", "path/to/2.txt" zip.close
zip.insert "out.txt", "something.txt"
Directly from a string buffer
zip["other.txt"] = "now is the time"
io = File.open("foo.dat") zip.insert "data.dat", io
From another zip file (direct stream copy)
Inserting zip data from one file into another allows the compressed data to be reused from the original zip file (avoiding uncompression and recompression):
other = .("other.zip") zip.insert "final.bin", other["final.bin"]
- implement date handling
- implement unix attribute handling
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request
MIT License. Copyright (c) 2012-2013 Jonathon M. Abbott