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
end
def sysread(length = nil, outbuf = '')
def read(length = nil, outbuf = '')
while length.nil? || (@buffer.bytesize < length)
break if input_finished?
@buffer << produce_input

View File

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

View File

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

View File

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

View File

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

View File

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