Sha256: 2d508f44b882a6d291b856349653a4477a0d53c841c12d9f9fbaa6742847cb88

Contents?: true

Size: 500 Bytes

Versions: 4

Compression:

Stored size: 500 Bytes

Contents

require "stringio"
require "zlib"

class Stream < StringIO
  def initialize(*)
    super
    set_encoding "BINARY"
  end

  def close
    rewind;
  end
end

class Gzip
  def self.compress(string, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY)
    output = Stream.new
    gz = Zlib::GzipWriter.new(output, level, strategy)
    gz.write(string)
    gz.close
    output.string
  end

  def self.decompress(string)
    Zlib::GzipReader.wrap(StringIO.new(string), &:read)
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
fluent-plugin-kinesis-3.5.0 lib/fluent/plugin/kinesis_helper/compression.rb
fluent-plugin-kinesis-3.4.2 lib/fluent/plugin/kinesis_helper/compression.rb
adp-fluent-plugin-kinesis-0.0.2 lib/fluent/plugin/kinesis_helper/compression.rb
adp-fluent-plugin-kinesis-0.0.1 lib/fluent/plugin/kinesis_helper/compression.rb