Sha256: 40f6405c4d702f00b952200c807c447e2aba140d00eb5eae9da14558a4d9c668

Contents?: true

Size: 570 Bytes

Versions: 2

Compression:

Stored size: 570 Bytes

Contents

module IOStreams
  module Gzip
    class Writer
      # Write to a file / stream, compressing with GZip
      def self.open(file_name_or_io, **args, &block)
        unless IOStreams.writer_stream?(file_name_or_io)
          IOStreams.mkpath(file_name_or_io)
          Zlib::GzipWriter.open(file_name_or_io, &block)
        else
          begin
            io = Zlib::GzipWriter.new(file_name_or_io)
            block.call(io)
          ensure
            io.close if io && (io.respond_to?(:closed?) && !io.closed?)
          end
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
iostreams-0.19.0 lib/io_streams/gzip/writer.rb
iostreams-0.18.0 lib/io_streams/gzip/writer.rb