Method: Crackup.compress_file
- Defined in:
- lib/crackup.rb
.compress_file(infile, outfile) ⇒ Object
Reads infile and compresses it to outfile using zlib compression.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/crackup.rb', line 20 def self.compress_file(infile, outfile) File.open(infile, 'rb') do |input| Zlib::GzipWriter.open(outfile, 9) do |output| while data = input.read(1048576) do output.write(data) end end end rescue => e raise Crackup::CompressionError, "Unable to compress #{infile}: #{e}" end |