I was doing this successfully with Ruby 1.9.2 and Syck:
data = YAML.load(Zlib::GzipReader.new(open('foo.yml.gz'))
but with Psych it fails like this:
NoMethodError: undefined method `external_encoding' for #<Zlib::GzipReader:0x007fa36303ffa8>
so it looks like it's assuming things about the input stream that aren't always true.
@ghostganz Because you sent it the Zlib::GzipReader object and didn't read the file to a string.
data = YAML.load(Zlib::GzipReader.new(open('foo.yml.gz')).read)
But I don't want to read it to a string, that was the point. Working with input streams directly used to work with Syck, but now it doesn't with Psych.
any update? why not allow reading yaml from a stream? This is most natural and memory efficient. After all it can read from a file stream, why not from a zstream?
hey, monkey patch workaround for the rescue:
loaded = nil
Zlib::GzipReader.open(gz) do |f|
class << f
loaded = YAML.load(f, gz)