Skip to content

Commit

Permalink
Rename Decompressor#sysread to #read
Browse files Browse the repository at this point in the history
  • Loading branch information
jspanjers committed Jan 26, 2020
1 parent 00b525d commit c66277d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/zip/inflater.rb
Expand Up @@ -8,7 +8,7 @@ def initialize(*args)
@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
Expand Down
6 changes: 3 additions & 3 deletions lib/zip/input_stream.rb
Expand Up @@ -80,8 +80,8 @@ def rewind
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
Expand Down Expand Up @@ -161,7 +161,7 @@ def get_decompressor
end

def produce_input
@decompressor.sysread(CHUNK_SIZE)
@decompressor.read(CHUNK_SIZE)
end

def input_finished?
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/null_decompressor.rb
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/zip/pass_thru_decompressor.rb
Expand Up @@ -6,7 +6,7 @@ def initialize(*args)
@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
Expand Down
2 changes: 1 addition & 1 deletion test/deflater_test.rb
Expand Up @@ -59,7 +59,7 @@ def deflate(data, fileName)
def inflate(fileName)
File.open(fileName, 'rb') do |file|
inflater = ::Zip::Inflater.new(file)
inflater.sysread
inflater.read
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/test_helper.rb
Expand Up @@ -66,12 +66,12 @@ def setup
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)
Expand Down

0 comments on commit c66277d

Please sign in to comment.