lib/polyphony/extensions/io.rb in polyphony-1.3 vs lib/polyphony/extensions/io.rb in polyphony-1.4

- old
+ new

@@ -195,11 +195,11 @@ # @!visibility private alias_method :orig_read, :read # @!visibility private - def read(len = nil, buf = nil, buffer_pos: 0) + def read(len = nil, buf = nil, buffer_pos = 0) return '' if len == 0 return Polyphony.backend_read(self, buf, len, true, buffer_pos) if buf @read_buffer ||= +'' result = Polyphony.backend_read(self, @read_buffer, len, true, -1) @@ -212,11 +212,11 @@ # @!visibility private alias_method :orig_readpartial, :read # @!visibility private - def readpartial(len, str = +'', buffer_pos: 0, raise_on_eof: true) + def readpartial(len, str = +'', buffer_pos = 0, raise_on_eof = true) result = Polyphony.backend_read(self, str, len, false, buffer_pos) raise EOFError if !result && raise_on_eof result end @@ -253,11 +253,11 @@ while true idx = @read_buffer.index(sep) return @read_buffer.slice!(0, idx + sep_size) if idx - result = readpartial(8192, @read_buffer, buffer_pos: -1) + result = readpartial(8192, @read_buffer, -1) return nil unless result end rescue EOFError return nil end @@ -278,11 +278,11 @@ line = @read_buffer.slice!(0, idx + sep_size) line = line.chomp if chomp yield line end - result = readpartial(8192, @read_buffer, buffer_pos: -1) + result = readpartial(8192, @read_buffer, -1) return self if !result end rescue EOFError return self end @@ -423,9 +423,22 @@ # @param src [IO, Polpyhony::Pipe] source to splice from # @param maxlen [Integer] maximum bytes to splice # @return [Integer] bytes spliced def splice_from(src, maxlen) Polyphony.backend_splice(src, self, maxlen) + end + + # @!visibility private + alias_method :orig_close, :close + + # Closes the IO instance + # + # @return [void] + def close + return if closed? + + Polyphony.backend_close(self) + nil end if RUBY_PLATFORM =~ /linux/ # Tees data from the given IO. #