Sha256: ed27d124a8158e60fec8199e7e1448149f233785bf8b5248a3e3ce0d6b416068
Contents?: true
Size: 825 Bytes
Versions: 7
Compression:
Stored size: 825 Bytes
Contents
module IOStreams module Bzip2 class Writer # Write to a file / stream, compressing with Bzip2 def self.open(file_name_or_io, **args, &block) begin require 'rbzip2' unless defined?(RBzip2) rescue LoadError => e raise(LoadError, "Please install the 'rbzip2' gem for Bzip2 streaming support. #{e.message}") end if IOStreams.reader_stream?(file_name_or_io) begin io = RBzip2.default_adapter::Compressor.new(file_name_or_io) block.call(io) ensure io.close end else ::File.open(file_name_or_io, 'wb') do |file| io = RBzip2.default_adapter::Compressor.new(file) block.call(io) io.close end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems