Module: ActiveSupport::Gzip

Defined in:
lib/gems/activesupport-2.2.2/lib/active_support/gzip.rb

Overview

A convenient wrapper for the zlib standard library that allows compression/decompression of strings with gzip.

Defined Under Namespace

Classes: Stream

Class Method Summary collapse

Class Method Details

.compress(source) ⇒ Object

Compresses a string using gzip.



17
18
19
20
21
22
23
# File 'lib/gems/activesupport-2.2.2/lib/active_support/gzip.rb', line 17

def self.compress(source)
  output = Stream.new
  gz = Zlib::GzipWriter.new(output)
  gz.write(source)
  gz.close
  output.string
end

.decompress(source) ⇒ Object

Decompresses a gzipped string.



12
13
14
# File 'lib/gems/activesupport-2.2.2/lib/active_support/gzip.rb', line 12

def self.decompress(source)
  Zlib::GzipReader.new(StringIO.new(source)).read
end