Sha256: fb66b624d9133232e0c26192d73914f999f8e6019f7497e42277383eba3a89af

Contents?: true

Size: 582 Bytes

Versions: 4

Compression:

Stored size: 582 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::File::Path.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

4 entries across 4 versions & 1 rubygems

Version Path
iostreams-0.20.3 lib/io_streams/gzip/writer.rb
iostreams-0.20.2 lib/io_streams/gzip/writer.rb
iostreams-0.20.1 lib/io_streams/gzip/writer.rb
iostreams-0.20.0 lib/io_streams/gzip/writer.rb