lib/io_streams/bzip2/reader.rb in iostreams-1.3.3 vs lib/io_streams/bzip2/reader.rb in iostreams-1.4.0

- old
+ new

@@ -1,13 +1,15 @@ module IOStreams module Bzip2 class Reader < IOStreams::Reader # Read from a Bzip2 stream, decompressing the contents as it is read - def self.stream(input_stream, **_args) - Utils.load_soft_dependency("rbzip2", "Bzip2") unless defined?(RBzip2) + def self.stream(input_stream, **args) + unless defined?(::Bzip2::FFI) + Utils.load_soft_dependency("bzip2-ffi", "Bzip2", "bzip2/ffi") + end begin - io = RBzip2.default_adapter::Decompressor.new(input_stream) + io = ::Bzip2::FFI::Reader.new(input_stream, args) yield io ensure io&.close end end