Sha256: b047fee7a88f06f1df2c9baeb81fc55d2d4cf459c3c2c73b8d4ff39f7cdfb696

Contents?: true

Size: 592 Bytes

Versions: 211

Compression:

Stored size: 592 Bytes

Contents

require 'zlib'
require 'stringio'

module ActiveSupport
  # A convenient wrapper for the zlib standard library that allows compression/decompression of strings with gzip.
  module Gzip
    class Stream < StringIO
      def close; rewind; end
    end

    # Decompresses a gzipped string.
    def self.decompress(source)
      Zlib::GzipReader.new(StringIO.new(source)).read
    end

    # Compresses a string using gzip.
    def self.compress(source)
      output = Stream.new
      gz = Zlib::GzipWriter.new(output)
      gz.write(source)
      gz.close
      output.string
    end
  end
end

Version data entries

211 entries across 178 versions & 27 rubygems

Version Path
activesupport-2.3.8 lib/active_support/gzip.rb
activesupport-2.3.8.pre1 lib/active_support/gzip.rb
activesupport-2.3.7 lib/active_support/gzip.rb
activesupport-2.3.6 lib/active_support/gzip.rb
radiant-0.8.2 vendor/rails/activesupport/lib/active_support/gzip.rb
radiant-0.9.0.rc2 vendor/rails/activesupport/lib/active_support/gzip.rb
activesupport-3.0.0.beta3 lib/active_support/gzip.rb
activesupport-3.0.0.beta2 lib/active_support/gzip.rb
webroar-0.3.1 src/admin_panel/vendor/rails/activesupport/lib/active_support/gzip.rb
webroar-0.3.0 src/admin_panel/vendor/rails/activesupport/lib/active_support/gzip.rb
usher-0.7.0 spec/rails2_3/vendor/rails/vendor/rails/activesupport/pkg/activesupport-2.3.3/lib/active_support/gzip.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/activesupport/lib/active_support/gzip.rb
usher-0.7.0 spec/rails2_2/vendor/rails/vendor/rails/activesupport/pkg/activesupport-2.2.2/lib/active_support/gzip.rb
usher-0.7.0 spec/rails2_3/vendor/rails/vendor/rails/activesupport/lib/active_support/gzip.rb
activesupport-2.3.6.pre lib/active_support/gzip.rb
activesupport-3.0.0.beta lib/active_support/gzip.rb
simply_stated-0.0.5 vendor/gems/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/gzip.rb
simply_stated-0.0.4 vendor/gems/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/gzip.rb
factorylabs-castronaut-0.7.5 vendor/activesupport/lib/active_support/gzip.rb
ginst-2009.12.8 vendor/rails/activesupport/lib/active_support/gzip.rb