rbs 3.3.2 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +2 -5
- data/.github/workflows/ruby.yml +7 -8
- data/.github/workflows/typecheck.yml +37 -0
- data/CHANGELOG.md +65 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +11 -11
- data/README.md +1 -0
- data/Rakefile +2 -2
- data/Steepfile +2 -2
- data/core/array.rbs +19 -49
- data/core/basic_object.rbs +2 -2
- data/core/comparable.rbs +17 -8
- data/core/complex.rbs +82 -43
- data/core/data.rbs +2 -4
- data/core/dir.rbs +635 -295
- data/core/enumerable.rbs +11 -18
- data/core/enumerator.rbs +37 -31
- data/core/errors.rbs +4 -0
- data/core/false_class.rbs +34 -15
- data/core/fiber.rbs +23 -0
- data/core/file.rbs +329 -120
- data/core/float.rbs +17 -32
- data/core/gc.rbs +17 -11
- data/core/hash.rbs +22 -44
- data/core/integer.rbs +82 -113
- data/core/io/buffer.rbs +90 -47
- data/core/io.rbs +54 -121
- data/core/kernel.rbs +442 -489
- data/core/match_data.rbs +55 -56
- data/core/module.rbs +45 -1
- data/core/nil_class.rbs +98 -35
- data/core/numeric.rbs +22 -32
- data/core/object_space/weak_key_map.rbs +102 -0
- data/core/process.rbs +1242 -655
- data/core/ractor.rbs +139 -120
- data/core/range.rbs +100 -4
- data/core/rational.rbs +0 -4
- data/core/rbs/unnamed/argf.rbs +16 -8
- data/core/rbs/unnamed/env_class.rbs +0 -24
- data/core/refinement.rbs +8 -0
- data/core/regexp.rbs +1149 -598
- data/core/ruby_vm.rbs +126 -12
- data/core/rubygems/platform.rbs +9 -0
- data/core/rubygems/rubygems.rbs +1 -1
- data/core/rubygems/version.rbs +5 -1
- data/core/set.rbs +20 -22
- data/core/signal.rbs +4 -4
- data/core/string.rbs +283 -230
- data/core/string_io.rbs +2 -14
- data/core/struct.rbs +404 -24
- data/core/symbol.rbs +1 -19
- data/core/thread.rbs +29 -12
- data/core/time.rbs +227 -104
- data/core/trace_point.rbs +2 -5
- data/core/true_class.rbs +54 -21
- data/core/warning.rbs +14 -11
- data/docs/data_and_struct.md +29 -0
- data/docs/gem.md +58 -0
- data/docs/syntax.md +3 -5
- data/docs/tools.md +1 -0
- data/ext/rbs_extension/lexer.c +643 -559
- data/ext/rbs_extension/lexer.re +5 -1
- data/ext/rbs_extension/parser.c +12 -3
- data/ext/rbs_extension/unescape.c +7 -47
- data/lib/rbs/cli/diff.rb +4 -1
- data/lib/rbs/cli/validate.rb +280 -0
- data/lib/rbs/cli.rb +2 -194
- data/lib/rbs/collection/config.rb +5 -6
- data/lib/rbs/collection/sources/git.rb +1 -1
- data/lib/rbs/collection.rb +1 -0
- data/lib/rbs/diff.rb +7 -4
- data/lib/rbs/errors.rb +11 -0
- data/lib/rbs/test/errors.rb +10 -2
- data/lib/rbs/test/guaranteed.rb +2 -3
- data/lib/rbs/test/type_check.rb +15 -10
- data/lib/rbs/test.rb +3 -3
- data/lib/rbs/types.rb +29 -0
- data/lib/rbs/unit_test/convertibles.rb +176 -0
- data/lib/rbs/unit_test/spy.rb +136 -0
- data/lib/rbs/unit_test/type_assertions.rb +341 -0
- data/lib/rbs/unit_test/with_aliases.rb +143 -0
- data/lib/rbs/unit_test.rb +6 -0
- data/lib/rbs/version.rb +1 -1
- data/sig/cli/validate.rbs +43 -0
- data/sig/diff.rbs +3 -1
- data/sig/errors.rbs +8 -0
- data/sig/rbs.rbs +1 -1
- data/sig/test/errors.rbs +52 -0
- data/sig/test/guranteed.rbs +9 -0
- data/sig/test/type_check.rbs +19 -0
- data/sig/test.rbs +82 -0
- data/sig/types.rbs +6 -1
- data/sig/unit_test/convertibles.rbs +154 -0
- data/sig/unit_test/spy.rbs +28 -0
- data/sig/unit_test/type_assertions.rbs +194 -0
- data/sig/unit_test/with_aliases.rbs +136 -0
- data/stdlib/base64/0/base64.rbs +307 -45
- data/stdlib/bigdecimal/0/big_decimal.rbs +35 -15
- data/stdlib/coverage/0/coverage.rbs +2 -2
- data/stdlib/csv/0/csv.rbs +25 -55
- data/stdlib/date/0/date.rbs +1 -43
- data/stdlib/date/0/date_time.rbs +1 -13
- data/stdlib/delegate/0/delegator.rbs +186 -0
- data/stdlib/delegate/0/kernel.rbs +47 -0
- data/stdlib/delegate/0/simple_delegator.rbs +98 -0
- data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -1
- data/stdlib/erb/0/erb.rbs +2 -2
- data/stdlib/fileutils/0/fileutils.rbs +0 -19
- data/stdlib/io-console/0/io-console.rbs +12 -1
- data/stdlib/ipaddr/0/ipaddr.rbs +2 -1
- data/stdlib/json/0/json.rbs +320 -81
- data/stdlib/logger/0/logger.rbs +9 -5
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +6 -6
- data/stdlib/monitor/0/monitor.rbs +78 -0
- data/stdlib/net-http/0/net-http.rbs +1880 -543
- data/stdlib/objspace/0/objspace.rbs +19 -13
- data/stdlib/openssl/0/openssl.rbs +508 -127
- data/stdlib/optparse/0/optparse.rbs +25 -11
- data/stdlib/pathname/0/pathname.rbs +1 -1
- data/stdlib/pp/0/pp.rbs +2 -5
- data/stdlib/prettyprint/0/prettyprint.rbs +2 -2
- data/stdlib/pstore/0/pstore.rbs +2 -4
- data/stdlib/rdoc/0/comment.rbs +1 -2
- data/stdlib/resolv/0/resolv.rbs +4 -2
- data/stdlib/socket/0/socket.rbs +2 -2
- data/stdlib/socket/0/unix_socket.rbs +2 -2
- data/stdlib/strscan/0/string_scanner.rbs +3 -2
- data/stdlib/tempfile/0/tempfile.rbs +1 -1
- data/stdlib/uri/0/common.rbs +245 -123
- metadata +24 -4
- data/lib/rbs/test/spy.rb +0 -6
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# <!-- rdoc-file=lib/delegate.rb -->
|
|
2
|
+
# A concrete implementation of Delegator, this class provides the means to
|
|
3
|
+
# delegate all supported method calls to the object passed into the constructor
|
|
4
|
+
# and even to change the object being delegated to at a later time with
|
|
5
|
+
# #__setobj__.
|
|
6
|
+
#
|
|
7
|
+
# class User
|
|
8
|
+
# def born_on
|
|
9
|
+
# Date.new(1989, 9, 10)
|
|
10
|
+
# end
|
|
11
|
+
# end
|
|
12
|
+
#
|
|
13
|
+
# require 'delegate'
|
|
14
|
+
#
|
|
15
|
+
# class UserDecorator < SimpleDelegator
|
|
16
|
+
# def birth_year
|
|
17
|
+
# born_on.year
|
|
18
|
+
# end
|
|
19
|
+
# end
|
|
20
|
+
#
|
|
21
|
+
# decorated_user = UserDecorator.new(User.new)
|
|
22
|
+
# decorated_user.birth_year #=> 1989
|
|
23
|
+
# decorated_user.__getobj__ #=> #<User: ...>
|
|
24
|
+
#
|
|
25
|
+
# A SimpleDelegator instance can take advantage of the fact that SimpleDelegator
|
|
26
|
+
# is a subclass of `Delegator` to call `super` to have methods called on the
|
|
27
|
+
# object being delegated to.
|
|
28
|
+
#
|
|
29
|
+
# class SuperArray < SimpleDelegator
|
|
30
|
+
# def [](*args)
|
|
31
|
+
# super + 1
|
|
32
|
+
# end
|
|
33
|
+
# end
|
|
34
|
+
#
|
|
35
|
+
# SuperArray.new([1])[0] #=> 2
|
|
36
|
+
#
|
|
37
|
+
# Here's a simple example that takes advantage of the fact that
|
|
38
|
+
# SimpleDelegator's delegation object can be changed at any time.
|
|
39
|
+
#
|
|
40
|
+
# class Stats
|
|
41
|
+
# def initialize
|
|
42
|
+
# @source = SimpleDelegator.new([])
|
|
43
|
+
# end
|
|
44
|
+
#
|
|
45
|
+
# def stats(records)
|
|
46
|
+
# @source.__setobj__(records)
|
|
47
|
+
#
|
|
48
|
+
# "Elements: #{@source.size}\n" +
|
|
49
|
+
# " Non-Nil: #{@source.compact.size}\n" +
|
|
50
|
+
# " Unique: #{@source.uniq.size}\n"
|
|
51
|
+
# end
|
|
52
|
+
# end
|
|
53
|
+
#
|
|
54
|
+
# s = Stats.new
|
|
55
|
+
# puts s.stats(%w{James Edward Gray II})
|
|
56
|
+
# puts
|
|
57
|
+
# puts s.stats([1, 2, 3, nil, 4, 5, 1, 2])
|
|
58
|
+
#
|
|
59
|
+
# Prints:
|
|
60
|
+
#
|
|
61
|
+
# Elements: 4
|
|
62
|
+
# Non-Nil: 4
|
|
63
|
+
# Unique: 4
|
|
64
|
+
#
|
|
65
|
+
# Elements: 8
|
|
66
|
+
# Non-Nil: 7
|
|
67
|
+
# Unique: 6
|
|
68
|
+
#
|
|
69
|
+
class SimpleDelegator < Delegator
|
|
70
|
+
public
|
|
71
|
+
|
|
72
|
+
# <!--
|
|
73
|
+
# rdoc-file=lib/delegate.rb
|
|
74
|
+
# - __getobj__() { || ... }
|
|
75
|
+
# -->
|
|
76
|
+
# Returns the current object method calls are being delegated to.
|
|
77
|
+
#
|
|
78
|
+
def __getobj__: () -> untyped
|
|
79
|
+
|
|
80
|
+
# <!--
|
|
81
|
+
# rdoc-file=lib/delegate.rb
|
|
82
|
+
# - __setobj__(obj)
|
|
83
|
+
# -->
|
|
84
|
+
# Changes the delegate object to *obj*.
|
|
85
|
+
#
|
|
86
|
+
# It's important to note that this does **not** cause SimpleDelegator's methods
|
|
87
|
+
# to change. Because of this, you probably only want to change delegation to
|
|
88
|
+
# objects of the same type as the original delegate.
|
|
89
|
+
#
|
|
90
|
+
# Here's an example of changing the delegation object.
|
|
91
|
+
#
|
|
92
|
+
# names = SimpleDelegator.new(%w{James Edward Gray II})
|
|
93
|
+
# puts names[1] # => Edward
|
|
94
|
+
# names.__setobj__(%w{Gavin Sinclair})
|
|
95
|
+
# puts names[1] # => Sinclair
|
|
96
|
+
#
|
|
97
|
+
def __setobj__: (untyped obj) -> untyped
|
|
98
|
+
end
|
data/stdlib/erb/0/erb.rbs
CHANGED
|
@@ -286,11 +286,11 @@ class ERB
|
|
|
286
286
|
# def build
|
|
287
287
|
# b = binding
|
|
288
288
|
# # create and run templates, filling member data variables
|
|
289
|
-
# ERB.new(
|
|
289
|
+
# ERB.new(<<~'END_PRODUCT', trim_mode: "", eoutvar: "@product").result b
|
|
290
290
|
# <%= PRODUCT[:name] %>
|
|
291
291
|
# <%= PRODUCT[:desc] %>
|
|
292
292
|
# END_PRODUCT
|
|
293
|
-
# ERB.new(
|
|
293
|
+
# ERB.new(<<~'END_PRICE', trim_mode: "", eoutvar: "@price").result b
|
|
294
294
|
# <%= PRODUCT[:name] %> -- <%= PRODUCT[:cost] %>
|
|
295
295
|
# <%= PRODUCT[:desc] %>
|
|
296
296
|
# END_PRICE
|
|
@@ -238,8 +238,6 @@ module FileUtils
|
|
|
238
238
|
# cd fileutils
|
|
239
239
|
#
|
|
240
240
|
#
|
|
241
|
-
# FileUtils.chdir is an alias for FileUtils.cd.
|
|
242
|
-
#
|
|
243
241
|
# Related: FileUtils.pwd.
|
|
244
242
|
#
|
|
245
243
|
def self?.cd: (path dir, ?verbose: boolish) -> void
|
|
@@ -652,8 +650,6 @@ module FileUtils
|
|
|
652
650
|
#
|
|
653
651
|
# Raises an exception if `src` is a directory.
|
|
654
652
|
#
|
|
655
|
-
# FileUtils.copy is an alias for FileUtils.cp.
|
|
656
|
-
#
|
|
657
653
|
# Related: [methods for copying](rdoc-ref:FileUtils@Copying).
|
|
658
654
|
#
|
|
659
655
|
def self?.cp: (pathlist src, path dest, ?preserve: boolish, ?noop: boolish, ?verbose: boolish) -> void
|
|
@@ -1066,8 +1062,6 @@ module FileUtils
|
|
|
1066
1062
|
# Raises an exception if `dest` is the path to an existing file and keyword
|
|
1067
1063
|
# argument `force` is not `true`.
|
|
1068
1064
|
#
|
|
1069
|
-
# FileUtils#link is an alias for FileUtils#ln.
|
|
1070
|
-
#
|
|
1071
1065
|
# Related: FileUtils.link_entry (has different options).
|
|
1072
1066
|
#
|
|
1073
1067
|
def self?.ln: (pathlist src, path dest, ?force: boolish, ?noop: boolish, ?verbose: boolish) -> void
|
|
@@ -1157,8 +1151,6 @@ module FileUtils
|
|
|
1157
1151
|
# ln -s srcdir3/src0.txt srcdir3/src1.txt destdir3
|
|
1158
1152
|
#
|
|
1159
1153
|
#
|
|
1160
|
-
# FileUtils.symlink is an alias for FileUtils.ln_s.
|
|
1161
|
-
#
|
|
1162
1154
|
# Related: FileUtils.ln_sf.
|
|
1163
1155
|
#
|
|
1164
1156
|
def self?.ln_s: (pathlist src, path dest, ?force: boolish, ?relative: boolish, ?target_directory: boolish, ?noop: boolish, ?verbose: boolish) -> void
|
|
@@ -1368,9 +1360,6 @@ module FileUtils
|
|
|
1368
1360
|
# mv src0 dest0
|
|
1369
1361
|
# mv src1.txt src1 dest1
|
|
1370
1362
|
#
|
|
1371
|
-
#
|
|
1372
|
-
# FileUtils.move is an alias for FileUtils.mv.
|
|
1373
|
-
#
|
|
1374
1363
|
def self?.mv: (pathlist src, path dest, ?force: boolish, ?noop: boolish, ?verbose: boolish, ?secure: boolish) -> void
|
|
1375
1364
|
|
|
1376
1365
|
# <!--
|
|
@@ -1417,8 +1406,6 @@ module FileUtils
|
|
|
1417
1406
|
#
|
|
1418
1407
|
# FileUtils.pwd # => "/rdoc/fileutils"
|
|
1419
1408
|
#
|
|
1420
|
-
# FileUtils.getwd is an alias for FileUtils.pwd.
|
|
1421
|
-
#
|
|
1422
1409
|
# Related: FileUtils.cd.
|
|
1423
1410
|
#
|
|
1424
1411
|
def self?.pwd: () -> String
|
|
@@ -1538,8 +1525,6 @@ module FileUtils
|
|
|
1538
1525
|
# rm src0.dat src0.txt
|
|
1539
1526
|
#
|
|
1540
1527
|
#
|
|
1541
|
-
# FileUtils.remove is an alias for FileUtils.rm.
|
|
1542
|
-
#
|
|
1543
1528
|
# Related: [methods for deleting](rdoc-ref:FileUtils@Deleting).
|
|
1544
1529
|
#
|
|
1545
1530
|
def self?.rm: (pathlist list, ?force: boolish, ?noop: boolish, ?verbose: boolish) -> void
|
|
@@ -1571,8 +1556,6 @@ module FileUtils
|
|
|
1571
1556
|
#
|
|
1572
1557
|
# See FileUtils.rm for keyword arguments.
|
|
1573
1558
|
#
|
|
1574
|
-
# FileUtils.safe_unlink is an alias for FileUtils.rm_f.
|
|
1575
|
-
#
|
|
1576
1559
|
# Related: [methods for deleting](rdoc-ref:FileUtils@Deleting).
|
|
1577
1560
|
#
|
|
1578
1561
|
def self?.rm_f: (pathlist list, ?noop: boolish, ?verbose: boolish) -> void
|
|
@@ -1664,8 +1647,6 @@ module FileUtils
|
|
|
1664
1647
|
#
|
|
1665
1648
|
# See FileUtils.rm_r for keyword arguments.
|
|
1666
1649
|
#
|
|
1667
|
-
# FileUtils.rmtree is an alias for FileUtils.rm_rf.
|
|
1668
|
-
#
|
|
1669
1650
|
# Related: [methods for deleting](rdoc-ref:FileUtils@Deleting).
|
|
1670
1651
|
#
|
|
1671
1652
|
def self?.rm_rf: (pathlist list, ?noop: boolish, ?verbose: boolish, ?secure: boolish) -> void
|
|
@@ -106,8 +106,14 @@ class IO
|
|
|
106
106
|
|
|
107
107
|
# <!--
|
|
108
108
|
# rdoc-file=ext/io/console/console.c
|
|
109
|
-
# - cursor
|
|
109
|
+
# - io.cursor -> [row, column]
|
|
110
110
|
# -->
|
|
111
|
+
# Returns the current cursor position as a two-element array of integers (row,
|
|
112
|
+
# column)
|
|
113
|
+
#
|
|
114
|
+
# io.cursor # => [3, 5]
|
|
115
|
+
#
|
|
116
|
+
# You must require 'io/console' to use this method.
|
|
111
117
|
#
|
|
112
118
|
def cursor: () -> [ Integer, Integer ]
|
|
113
119
|
|
|
@@ -205,6 +211,11 @@ class IO
|
|
|
205
211
|
#
|
|
206
212
|
# You must require 'io/console' to use this method.
|
|
207
213
|
#
|
|
214
|
+
# require 'io/console'
|
|
215
|
+
# IO::console.getpass("Enter password:")
|
|
216
|
+
# Enter password:
|
|
217
|
+
# # => "mypassword"
|
|
218
|
+
#
|
|
208
219
|
def getpass: (?String) -> String
|
|
209
220
|
|
|
210
221
|
# <!--
|
data/stdlib/ipaddr/0/ipaddr.rbs
CHANGED
|
@@ -295,7 +295,8 @@ class IPAddr
|
|
|
295
295
|
# Returns true if the ipaddr is a private address. IPv4 addresses in
|
|
296
296
|
# 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 as defined in RFC 1918 and IPv6
|
|
297
297
|
# Unique Local Addresses in fc00::/7 as defined in RFC 4193 are considered
|
|
298
|
-
# private.
|
|
298
|
+
# private. Private IPv4 addresses in the IPv4-mapped IPv6 address range are also
|
|
299
|
+
# considered private.
|
|
299
300
|
#
|
|
300
301
|
def private?: () -> bool
|
|
301
302
|
|