A convenient wrapper for the zlib standard library that allows compression/decompression of strings with gzip.
Compresses a string using gzip.
# File lib/active_support/gzip.rb, line 22 def self.compress(source) output = Stream.new gz = Zlib::GzipWriter.new(output) gz.write(source) gz.close output.string end
Decompresses a gzipped string.
# File lib/active_support/gzip.rb, line 17 def self.decompress(source) Zlib::GzipReader.new(StringIO.new(source)).read end