Rename Decompressor#sysread to #read

This commit is contained in:
Jan-Joost Spanjers 2020-01-05 16:06:05 +01:00
parent 00b525d76e
commit c66277db58
6 changed files with 9 additions and 9 deletions

View File

@ -8,7 +8,7 @@ module Zip
@has_returned_empty_string = false @has_returned_empty_string = false
end end
def sysread(length = nil, outbuf = '') def read(length = nil, outbuf = '')
while length.nil? || (@buffer.bytesize < length) while length.nil? || (@buffer.bytesize < length)
break if input_finished? break if input_finished?
@buffer << produce_input @buffer << produce_input

View File

@ -80,8 +80,8 @@ module Zip
end end
# Modeled after IO.sysread # Modeled after IO.sysread
def sysread(number_of_bytes = nil, buf = nil) def sysread(length = nil, outbuf = '')
@decompressor.sysread(number_of_bytes, buf) @decompressor.read(length, outbuf)
end end
class << self class << self
@ -161,7 +161,7 @@ module Zip
end end
def produce_input def produce_input
@decompressor.sysread(CHUNK_SIZE) @decompressor.read(CHUNK_SIZE)
end end
def input_finished? def input_finished?

View File

@ -2,7 +2,7 @@ module Zip
module NullDecompressor #:nodoc:all module NullDecompressor #:nodoc:all
module_function module_function
def sysread(_length = nil, _outbuf = nil) def read(_length = nil, _outbuf = nil)
nil nil
end end

View File

@ -6,7 +6,7 @@ module Zip
@has_returned_empty_string = false @has_returned_empty_string = false
end end
def sysread(length = nil, outbuf = '') def read(length = nil, outbuf = '')
if eof? if eof?
has_returned_empty_string_val = @has_returned_empty_string has_returned_empty_string_val = @has_returned_empty_string
@has_returned_empty_string = true @has_returned_empty_string = true

View File

@ -59,7 +59,7 @@ class DeflaterTest < MiniTest::Test
def inflate(fileName) def inflate(fileName)
File.open(fileName, 'rb') do |file| File.open(fileName, 'rb') do |file|
inflater = ::Zip::Inflater.new(file) inflater = ::Zip::Inflater.new(file)
inflater.sysread inflater.read
end end
end end

View File

@ -66,12 +66,12 @@ module DecompressorTests
end end
def test_read_everything def test_read_everything
assert_equal(@refText, @decompressor.sysread) assert_equal(@refText, @decompressor.read)
end end
def test_read_in_chunks def test_read_in_chunks
chunkSize = 5 chunkSize = 5
while (decompressedChunk = @decompressor.sysread(chunkSize)) while (decompressedChunk = @decompressor.read(chunkSize))
assert_equal(@refText.slice!(0, chunkSize), decompressedChunk) assert_equal(@refText.slice!(0, chunkSize), decompressedChunk)
end end
assert_equal(0, @refText.size) assert_equal(0, @refText.size)