bzip2-ruby
bzip2-ruby copied to clipboard
NoMethodError: undefined method `pos' for #<Bzip2::Reader:0xaa2bf5c>
Hi
I'm trying to use bzip2-ruby
to stream-in .tar.bz2
files via Gem::Package::TarReader
.
BRIEF: It doesn't work yet due to this:
NoMethodError: undefined method `pos' for #<Bzip2::Reader:0xaa2bf5c>
Details follow.
require "bzip2-ruby"
require "rubygems/package"
#fn = "/path/to/file.tar"
fn = "/path/to/file.tar.bz2"
#fn = "/path/to/file.tar.gz"
stream = if fn.match /\.bz2\z/
Bzip2::Reader.open(fn)
elsif fn.match /\.gz\z/
Zlib::GzipReader.open(fn)
elsif fn.match /\.tar\z/
File.open(fn)
else
raise "Error: Don't know how to handle '#{fn}', aborting"
end
untar = Gem::Package::TarReader.new(stream)
untar.each do |entry|
...
end
Plain tar
and .tar.gz
work. .tar.bz2
doesn't, here's the exception info:
NoMethodError: undefined method `pos' for #<Bzip2::Reader:0xaad6394>
from /home/rbdev/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_reader.rb:42:in `initialize'
from /home/rbdev/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_reader.rb:23:in `new'
from /home/rbdev/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_reader.rb:23:in `new'
Thank you.
Alex