Sha256: a9656245a2cb42d5648e9c2ef0df3c4ba32cb076d1e6bf3ac1c3d1ca1fdceec0
Contents?: true
Size: 884 Bytes
Versions: 2
Compression:
Stored size: 884 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, _=nil, &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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
iostreams-0.15.0 | lib/io_streams/bzip2/reader.rb |
iostreams-0.14.0 | lib/io_streams/bzip2/reader.rb |