Mike McQuaid 86f43f79ee
Enable/fix optional Ruby frozen string literal usage
Combined with https://github.com/Homebrew/homebrew-test-bot/pull/247
this will test Homebrew's use of frozen strings in CI. After this we
will then enable it for Homebrew developers and eventually all Homebrew
users.
2019-04-19 10:30:41 +09:00

20 lines
316 B
Ruby

class IO
def readline_nonblock(sep = $INPUT_RECORD_SEPARATOR)
line = +""
buffer = +""
loop do
break if buffer == sep
read_nonblock(1, buffer)
line.concat(buffer)
end
line.freeze
rescue IO::WaitReadable, EOFError => e
raise e if line.empty?
line.freeze
end
end