Sha256: fdf5edfb3818af91f9b202931bdc6f13c42467251a02e6818ea07fc33901c658
Contents?: true
Size: 885 Bytes
Versions: 13
Compression:
Stored size: 885 Bytes
Contents
module IOStreams module Bzip2 class Reader # Read from a Bzip2 file or stream, decompressing the contents as it is read 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::Decompressor.new(file_name_or_io) block.call(io) ensure io.close if io && (io.respond_to?(:closed?) && !io.closed?) end else ::File.open(file_name_or_io, 'rb') do |file| io = RBzip2.default_adapter::Decompressor.new(file) block.call(io) end end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems