Sha256: 8660c6816f814fb095d4dc3bbdadad21fd0a7e3bab8f758cb7f5391aaf202e29

Contents?: true

Size: 512 Bytes

Versions: 11

Compression:

Stored size: 512 Bytes

Contents

module Kafka
  class GzipCodec
    def codec_id
      1
    end

    def load
      require "zlib"
    end

    def compress(data)
      buffer = StringIO.new
      buffer.set_encoding(Encoding::BINARY)

      writer = Zlib::GzipWriter.new(buffer, Zlib::DEFAULT_COMPRESSION, Zlib::DEFAULT_STRATEGY)
      writer.write(data)
      writer.close

      buffer.string
    end

    def decompress(data)
      buffer = StringIO.new(data)
      reader = Zlib::GzipReader.new(buffer)
      reader.read
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ruby-kafka-0.6.0.beta4 lib/kafka/gzip_codec.rb
ruby-kafka-0.6.0.beta3 lib/kafka/gzip_codec.rb
ruby-kafka-0.6.0.beta2 lib/kafka/gzip_codec.rb
ruby-kafka-0.6.0.beta1 lib/kafka/gzip_codec.rb
ruby-kafka-0.5.5 lib/kafka/gzip_codec.rb
ruby-kafka-0.5.4 lib/kafka/gzip_codec.rb
ruby-kafka-0.5.4.beta1 lib/kafka/gzip_codec.rb
ruby-kafka-0.5.3 lib/kafka/gzip_codec.rb
ruby-kafka-0.5.2 lib/kafka/gzip_codec.rb
ruby-kafka-0.5.2.beta3 lib/kafka/gzip_codec.rb
ruby-kafka-0.5.2.beta2 lib/kafka/gzip_codec.rb