Zippo is a fast zip library for ruby.
A benchmark is available.
Add this line to your application's Gemfile:
gem 'zippo'
And then execute:
$ bundle
Or install it yourself as:
$ gem install zippo
It can be called in block form:
Zippo.open("file.zip") do |zip|
str = zip["file.txt"]
other = zip["other/file.txt"]
puts str
end
Or without a block:
zip = Zippo.open("file.zip")
puts zip["file.txt"]
zip.close
Files can be inserted into the zip using the insert method. Note that no data will be written until the ZipFile is closed:
zip = Zippo.open("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"
zip["other.txt"] = "now is the time"
io = File.open("foo.dat")
zip.insert "data.dat", io
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 = Zippo.open("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