From 42e82406469a9f615ba1610ec798952de7d76ed1 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Mon, 1 Jan 2024 22:50:32 +1300 Subject: [PATCH] Add support for `gets(chomp: true)`. --- lib/openssl/buffering.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/openssl/buffering.rb b/lib/openssl/buffering.rb index 9570f14f3..68aa7bc97 100644 --- a/lib/openssl/buffering.rb +++ b/lib/openssl/buffering.rb @@ -229,7 +229,7 @@ def read_nonblock(maxlen, buf=nil, exception: true) # # Unlike IO#gets the separator must be provided if a limit is provided. - def gets(eol=$/, limit=nil) + def gets(eol=$/, limit=nil, chomp: false) idx = @rbuffer.index(eol) until @eof break if idx @@ -244,7 +244,11 @@ def gets(eol=$/, limit=nil) if size && limit && limit >= 0 size = [size, limit].min end - consume_rbuff(size) + line = consume_rbuff(size) + if chomp && line + line.chomp!(eol) + end + line end ##