Skip to content

Commit 74c7a7b

Browse files
committed
#readlines and #readliness *also* accept chomp: true
(wow how many `chomp: true`s are there) * Kernel * ARGF * StringIO * OpenSSL::Buffering
1 parent c958f48 commit 74c7a7b

File tree

6 files changed

+39
-5
lines changed

6 files changed

+39
-5
lines changed

core/kernel.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ module Kernel : BasicObject
14861486
# Optional keyword argument `chomp` specifies whether line separators are to be
14871487
# omitted.
14881488
#
1489-
def self?.readline: (?String arg0, ?Integer arg1) -> String
1489+
def self?.readline: (?String arg0, ?Integer arg1, ?chomp: boolish) -> String
14901490

14911491
# <!--
14921492
# rdoc-file=io.c

core/rbs/unnamed/argf.rbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ module RBS
10241024
# An EOFError is raised at the end of the file.
10251025
#
10261026
%a{annotate:rdoc:copy:ARGF#readline}
1027-
def readline: (?String sep, ?Integer limit) -> String
1027+
def readline: (?String sep, ?Integer limit, ?chomp: boolish) -> String
10281028

10291029
# <!--
10301030
# rdoc-file=io.c
@@ -1044,7 +1044,7 @@ module RBS
10441044
# See `IO.readlines` for a full description of all options.
10451045
#
10461046
%a{annotate:rdoc:copy:ARGF#readlines}
1047-
def readlines: (?String sep, ?Integer limit) -> ::Array[String]
1047+
def readlines: (?String sep, ?Integer limit, ?chomp: boolish) -> ::Array[String]
10481048

10491049
# <!--
10501050
# rdoc-file=io.c

stdlib/openssl/0/openssl.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,7 @@ module OpenSSL
20252025
#
20262026
# Unlike IO#gets the separator must be provided if a limit is provided.
20272027
#
2028-
def gets: (?String | Regexp eol, ?Integer limit) -> String?
2028+
def gets: (?String | Regexp eol, ?Integer limit, ?chomp: boolish) -> String?
20292029

20302030
# <!--
20312031
# rdoc-file=ext/openssl/lib/openssl/buffering.rb

stdlib/stringio/0/stringio.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ class StringIO
338338

339339
def readchar: () -> String
340340

341-
def readline: (?String sep, ?Integer limit) -> String
341+
def readline: (?String sep, ?Integer limit, ?chomp: boolish) -> String
342342

343343
# <!--
344344
# rdoc-file=ext/stringio/stringio.c

test/stdlib/ARGF_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ def test_readline
6464
ARGF.class.new(__FILE__), :readline, "\n"
6565
assert_send_type "(::String sep, ::Integer limit) -> ::String",
6666
ARGF.class.new(__FILE__), :readline, "\n", 1
67+
assert_send_type "(chomp: boolish) -> ::String",
68+
ARGF.class.new(__FILE__), :readline, chomp: true
69+
assert_send_type "(::String sep, ::Integer limit, chomp: boolish) -> ::String",
70+
ARGF.class.new(__FILE__), :readline, "\n", 1, chomp: true
6771
end
6872

6973
def test_readlines
@@ -73,6 +77,10 @@ def test_readlines
7377
ARGF.class.new(__FILE__), :readlines, "\n"
7478
assert_send_type "(::String sep, ::Integer limit) -> ::Array[::String]",
7579
ARGF.class.new(__FILE__), :readlines, "\n", 1
80+
assert_send_type "(chomp: boolish) -> ::Array[::String]",
81+
ARGF.class.new(__FILE__), :readlines, chomp: true
82+
assert_send_type "(::String sep, ::Integer limit, chomp: boolish) -> ::Array[::String]",
83+
ARGF.class.new(__FILE__), :readlines, "\n", 1, chomp: true
7684
end
7785

7886
def test_inspect

test/stdlib/StringIO_test.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,30 @@ def test_truncate
5959
io, :truncate, 10
6060
)
6161
end
62+
63+
def test_readline
64+
assert_send_type "() -> ::String",
65+
StringIO.new("\n"), :readline
66+
assert_send_type "(::String sep) -> ::String",
67+
StringIO.new("\n"), :readline, "\n"
68+
assert_send_type "(::String sep, ::Integer limit) -> ::String",
69+
StringIO.new("\n"), :readline, "\n", 1
70+
assert_send_type "(chomp: boolish) -> ::String",
71+
StringIO.new("\n"), :readline, chomp: true
72+
assert_send_type "(::String sep, ::Integer limit, chomp: boolish) -> ::String",
73+
StringIO.new("\n"), :readline, "\n", 1, chomp: true
74+
end
75+
76+
def test_readlines
77+
assert_send_type "() -> ::Array[::String]",
78+
StringIO.new("\n"), :readlines
79+
assert_send_type "(::String sep) -> ::Array[::String]",
80+
StringIO.new("\n"), :readlines, "\n"
81+
assert_send_type "(::String sep, ::Integer limit) -> ::Array[::String]",
82+
StringIO.new("\n"), :readlines, "\n", 1
83+
assert_send_type "(chomp: boolish) -> ::Array[::String]",
84+
StringIO.new("\n"), :readlines, chomp: true
85+
assert_send_type "(::String sep, ::Integer limit, chomp: boolish) -> ::Array[::String]",
86+
StringIO.new("\n"), :readlines, "\n", 1, chomp: true
87+
end
6288
end

0 commit comments

Comments
 (0)