8000 Merge pull request #314 from mwlang/bugfix/open_buffer_without_block · rubyzip/rubyzip@df8dfbc · GitHub
[go: up one dir, main page]

Skip to content

Commit df8dfbc

Browse files
authored
Merge pull request #314 from mwlang/bugfix/open_buffer_without_block
allows open_buffer to work without a given block
2 parents 28c5dd5 + 14b8fed commit df8dfbc

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/zip/file.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def open_buffer(io, options = {})
129129
end
130130
zf = ::Zip::File.new(io, true, true, options)
131131
zf.read_from_stream(io)
132+
return zf unless block_given?
132133
yield zf
133134
begin
134135
zf.write_buffer(io)

test/file_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ def test_open_buffer_with_stringio
104104
end
105105
end
106106

107+
def test_open_buffer_without_block
108+
string_io = StringIO.new File.read('test/data/rubycode.zip')
109+
zf = ::Zip::File.open_buffer string_io
110+
assert zf.entries.map { |e| e.name }.include?('zippedruby1.rb')
111+
end
112+
107113
def test_cleans_up_tempfiles_after_close
108114
zf = ::Zip::File.new(EMPTY_FILENAME, ::Zip::File::CREATE)
109115
zf.get_output_stream('myFile') do |os|

0 commit comments

Comments
 (0)
0