Sha256: 991f0cb91acda74853646b59a4bca4f0265645e727cf9d6b1fb7e78c28f55ab3

Contents?: true

Size: 600 Bytes

Versions: 6

Compression:

Stored size: 600 Bytes

Contents

require 'zlib'

module Datadog
  module Utils
    # Common database-related utility functions.
    module Compression
      module_function

      def gzip(string, level: nil, strategy: nil)
        sio = StringIO.new
        sio.binmode
        gz = Zlib::GzipWriter.new(sio, level, strategy)
        gz.write(string)
        gz.close
        sio.string
      end

      def gunzip(string, encoding = ::Encoding::ASCII_8BIT)
        sio = StringIO.new(string)
        gz = Zlib::GzipReader.new(sio, encoding: encoding)
        gz.read
      ensure
        gz && gz.close
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ddtrace-0.51.1 lib/ddtrace/utils/compression.rb
ddtrace-0.51.0 lib/ddtrace/utils/compression.rb
ddtrace-0.50.0 lib/ddtrace/utils/compression.rb
ddtrace-0.49.0 lib/ddtrace/utils/compression.rb
ddtrace-0.48.0 lib/ddtrace/utils/compression.rb
ddtrace-0.47.0 lib/ddtrace/utils/compression.rb