Sha256: b5ab2624e25615cd2a72c968f7a14dc70cc9db0aa5a7b9622d5b3c86746e5905

Contents?: true

Size: 518 Bytes

Versions: 47

Compression:

Stored size: 518 Bytes

Contents

module Kafka
  class GzipCodec
    def initialize
      require "zlib"
    end

    def codec_id
      1
    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

47 entries across 47 versions & 1 rubygems

Version Path
ruby-kafka-0.5.2.beta1 lib/kafka/gzip_codec.rb
ruby-kafka-0.5.1 lib/kafka/gzip_codec.rb
ruby-kafka-0.5.1.beta2 lib/kafka/gzip_codec.rb
ruby-kafka-0.5.1.beta1 lib/kafka/gzip_codec.rb
ruby-kafka-0.4.4 lib/kafka/gzip_codec.rb
ruby-kafka-0.5.0 lib/kafka/gzip_codec.rb
ruby-kafka-0.5.0.beta6 lib/kafka/gzip_codec.rb
ruby-kafka-0.5.0.beta5 lib/kafka/gzip_codec.rb
ruby-kafka-0.5.0.beta4 lib/kafka/gzip_codec.rb
ruby-kafka-0.5.0.beta3 lib/kafka/gzip_codec.rb
ruby-kafka-0.5.0.beta2 lib/kafka/gzip_codec.rb
ruby-kafka-0.4.3 lib/kafka/gzip_codec.rb
ruby-kafka-0.4.2 lib/kafka/gzip_codec.rb
ruby-kafka-0.4.1 lib/kafka/gzip_codec.rb
ruby-kafka-0.4.0 lib/kafka/gzip_codec.rb
ruby-kafka-0.4.0.beta1 lib/kafka/gzip_codec.rb
ruby-kafka-0.3.18.beta2 lib/kafka/gzip_codec.rb
ruby-kafka-0.3.18.beta1 lib/kafka/gzip_codec.rb
ruby-kafka-0.3.17 lib/kafka/gzip_codec.rb
ruby-kafka-0.3.16 lib/kafka/gzip_codec.rb