rubyzip/rubyzip — pull request #201 by mcantor (2014-12-17 21:20:41+00:00)
Title: Be smarter about handling buffer file modes

This is a fix for #119.

The test suite still runs, but I have not added a test for this fix because I'm not sure if the behavior I defined is correct.

1. **Force binary mode** (`file.rb`): I noticed that the errors went away when I opened files in binary mode, like `rubyzip` itself does when you pass a filename to `Zip::File.open`, so now it forces binary mode when you pass an IO object.

1. **Abort unnecessary writes** (`output_stream.rb`): If you don't pass a stream which was opened for writing, then this results in a "not opened for writing" error, even if you didn't actually try to write anything.

The second part is probably not correct; I imagine the best fix would be one that only bothers doing `zf.write_buffer(io)` if changes were actually made to the in-memory archive.