문제

I am trying to read a gzipped file using Zlib:GzipReader. This works as expected using ruby 1.9.3 but I am getting a method_missing error for each_line when using Rubinius.

Is there any way to read a gzipped file using Rubinius?

require 'zlib'

Zlib::GzipReader.open("lines.txt.gz").each_line { |line|
  puts "#{line}"
}

Kernel(Zlib::GzipReader)#each_line (method_missing) at kernel/delta/kernel.rb:81
도움이 되었습니까?

해결책

I believe this is a bug in Rubinius, you should consider opening an issue for it with the project. However, this workaround should get you going:

require 'zlib'
require 'stringio'

file = File.read("lines.txt.gz")
lines = Zlib::GzipReader.new(StringIO.new(file)).read
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top