rbs 0.14.0 → 0.18.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +8 -4
- data/CHANGELOG.md +35 -0
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/Rakefile +19 -1
- data/Steepfile +0 -1
- data/bin/test_runner.rb +15 -1
- data/{stdlib/builtin → core}/array.rbs +124 -120
- data/{stdlib/builtin → core}/basic_object.rbs +0 -0
- data/{stdlib/builtin → core}/binding.rbs +0 -0
- data/core/builtin.rbs +70 -0
- data/{stdlib/builtin → core}/class.rbs +0 -0
- data/{stdlib/builtin → core}/comparable.rbs +0 -0
- data/{stdlib/builtin → core}/complex.rbs +0 -0
- data/{stdlib/builtin → core}/constants.rbs +0 -0
- data/{stdlib/builtin → core}/data.rbs +0 -0
- data/{stdlib/builtin → core}/deprecated.rbs +0 -0
- data/{stdlib/builtin → core}/dir.rbs +1 -1
- data/{stdlib/builtin → core}/encoding.rbs +0 -0
- data/{stdlib/builtin → core}/enumerable.rbs +67 -60
- data/{stdlib/builtin → core}/enumerator.rbs +5 -5
- data/{stdlib/builtin → core}/errno.rbs +0 -0
- data/{stdlib/builtin → core}/errors.rbs +1 -1
- data/{stdlib/builtin → core}/exception.rbs +0 -0
- data/{stdlib/builtin → core}/false_class.rbs +0 -0
- data/{stdlib/builtin → core}/fiber.rbs +0 -0
- data/{stdlib/builtin → core}/fiber_error.rbs +0 -0
- data/{stdlib/builtin → core}/file.rbs +0 -0
- data/{stdlib/builtin → core}/file_test.rbs +0 -0
- data/{stdlib/builtin → core}/float.rbs +0 -0
- data/{stdlib/builtin → core}/gc.rbs +2 -2
- data/{stdlib/builtin → core}/hash.rbs +15 -15
- data/{stdlib/builtin → core}/integer.rbs +0 -0
- data/{stdlib/builtin → core}/io.rbs +6 -6
- data/{stdlib/builtin → core}/kernel.rbs +1 -85
- data/{stdlib/builtin → core}/marshal.rbs +0 -0
- data/{stdlib/builtin → core}/match_data.rbs +0 -0
- data/{stdlib/builtin → core}/math.rbs +0 -0
- data/{stdlib/builtin → core}/method.rbs +0 -0
- data/{stdlib/builtin → core}/module.rbs +13 -13
- data/{stdlib/builtin → core}/nil_class.rbs +0 -0
- data/{stdlib/builtin → core}/numeric.rbs +0 -0
- data/{stdlib/builtin → core}/object.rbs +1 -1
- data/core/object_space.rbs +98 -0
- data/{stdlib/builtin → core}/proc.rbs +0 -0
- data/{stdlib/builtin → core}/process.rbs +0 -0
- data/{stdlib/builtin → core}/random.rbs +1 -1
- data/{stdlib/builtin → core}/range.rbs +3 -3
- data/{stdlib/builtin → core}/rational.rbs +0 -0
- data/{stdlib/builtin → core}/rb_config.rbs +0 -0
- data/{stdlib/builtin → core}/regexp.rbs +0 -0
- data/{stdlib/builtin → core}/ruby_vm.rbs +0 -0
- data/{stdlib/builtin → core}/signal.rbs +0 -0
- data/{stdlib/builtin → core}/string.rbs +6 -6
- data/{stdlib/builtin → core}/string_io.rbs +7 -7
- data/{stdlib/builtin → core}/struct.rbs +2 -2
- data/{stdlib/builtin → core}/symbol.rbs +1 -1
- data/{stdlib/builtin → core}/thread.rbs +4 -4
- data/{stdlib/builtin → core}/thread_group.rbs +0 -0
- data/{stdlib/builtin → core}/time.rbs +0 -0
- data/{stdlib/builtin → core}/trace_point.rbs +0 -0
- data/{stdlib/builtin → core}/true_class.rbs +1 -1
- data/{stdlib/builtin → core}/unbound_method.rbs +0 -0
- data/{stdlib/builtin → core}/warning.rbs +0 -0
- data/docs/repo.md +125 -0
- data/docs/syntax.md +50 -6
- data/lib/rbs.rb +1 -0
- data/lib/rbs/cli.rb +105 -103
- data/lib/rbs/definition.rb +9 -4
- data/lib/rbs/definition_builder.rb +50 -17
- data/lib/rbs/environment_loader.rb +79 -105
- data/lib/rbs/environment_walker.rb +70 -35
- data/lib/rbs/parser.rb +404 -397
- data/lib/rbs/parser.y +18 -9
- data/lib/rbs/prototype/rb.rb +186 -25
- data/lib/rbs/prototype/runtime.rb +18 -7
- data/lib/rbs/repository.rb +121 -0
- data/lib/rbs/test/hook.rb +27 -15
- data/lib/rbs/test/setup.rb +5 -3
- data/lib/rbs/test/tester.rb +4 -1
- data/lib/rbs/test/type_check.rb +16 -5
- data/lib/rbs/type_name.rb +2 -1
- data/lib/rbs/vendorer.rb +38 -16
- data/lib/rbs/version.rb +1 -1
- data/sig/cli.rbs +58 -0
- data/sig/constant_table.rbs +1 -1
- data/sig/declarations.rbs +1 -1
- data/sig/definition.rbs +9 -4
- data/sig/definition_builder.rbs +4 -1
- data/sig/environment_loader.rbs +92 -46
- data/sig/members.rbs +2 -2
- data/sig/method_types.rbs +1 -1
- data/sig/namespace.rbs +1 -1
- data/sig/polyfill.rbs +42 -0
- data/sig/rbs.rbs +8 -0
- data/sig/repository.rbs +79 -0
- data/sig/vendorer.rbs +44 -0
- data/stdlib/abbrev/{abbrev.rbs → 0/abbrev.rbs} +0 -0
- data/stdlib/base64/{base64.rbs → 0/base64.rbs} +1 -1
- data/stdlib/benchmark/{benchmark.rbs → 0/benchmark.rbs} +0 -0
- data/stdlib/{bigdecimal/math → bigdecimal-math/0}/big_math.rbs +0 -0
- data/stdlib/bigdecimal/{big_decimal.rbs → 0/big_decimal.rbs} +0 -0
- data/stdlib/coverage/{coverage.rbs → 0/coverage.rbs} +2 -2
- data/stdlib/csv/{csv.rbs → 0/csv.rbs} +4 -4
- data/stdlib/date/{date.rbs → 0/date.rbs} +2 -2
- data/stdlib/date/{date_time.rbs → 0/date_time.rbs} +1 -1
- data/stdlib/dbm/0/dbm.rbs +277 -0
- data/stdlib/erb/{erb.rbs → 0/erb.rbs} +0 -0
- data/stdlib/fiber/{fiber.rbs → 0/fiber.rbs} +0 -0
- data/stdlib/find/{find.rbs → 0/find.rbs} +2 -2
- data/stdlib/forwardable/{forwardable.rbs → 0/forwardable.rbs} +0 -0
- data/stdlib/ipaddr/{ipaddr.rbs → 0/ipaddr.rbs} +0 -0
- data/stdlib/json/{json.rbs → 0/json.rbs} +0 -0
- data/stdlib/logger/{formatter.rbs → 0/formatter.rbs} +0 -0
- data/stdlib/logger/{log_device.rbs → 0/log_device.rbs} +1 -1
- data/stdlib/logger/{logger.rbs → 0/logger.rbs} +1 -1
- data/stdlib/logger/{period.rbs → 0/period.rbs} +0 -0
- data/stdlib/logger/{severity.rbs → 0/severity.rbs} +0 -0
- data/stdlib/mutex_m/{mutex_m.rbs → 0/mutex_m.rbs} +0 -0
- data/stdlib/pathname/{pathname.rbs → 0/pathname.rbs} +39 -39
- data/stdlib/prime/{integer-extension.rbs → 0/integer-extension.rbs} +0 -0
- data/stdlib/prime/{prime.rbs → 0/prime.rbs} +1 -1
- data/stdlib/pstore/0/pstore.rbs +287 -0
- data/stdlib/pty/{pty.rbs → 0/pty.rbs} +1 -1
- data/stdlib/securerandom/{securerandom.rbs → 0/securerandom.rbs} +0 -0
- data/stdlib/set/{set.rbs → 0/set.rbs} +10 -10
- data/stdlib/singleton/0/singleton.rbs +111 -0
- data/stdlib/tmpdir/{tmpdir.rbs → 0/tmpdir.rbs} +0 -0
- data/stdlib/tsort/0/cyclic.rbs +4 -0
- data/stdlib/tsort/0/interfaces.rbs +19 -0
- data/stdlib/tsort/0/tsort.rbs +363 -0
- data/stdlib/uri/{file.rbs → 0/file.rbs} +0 -0
- data/stdlib/uri/{generic.rbs → 0/generic.rbs} +1 -1
- data/stdlib/uri/{http.rbs → 0/http.rbs} +0 -0
- data/stdlib/uri/{https.rbs → 0/https.rbs} +0 -0
- data/stdlib/uri/{ldap.rbs → 0/ldap.rbs} +0 -0
- data/stdlib/uri/{ldaps.rbs → 0/ldaps.rbs} +0 -0
- data/stdlib/yaml/0/dbm.rbs +221 -0
- data/stdlib/yaml/0/store.rbs +53 -0
- data/stdlib/zlib/{zlib.rbs → 0/zlib.rbs} +0 -0
- data/steep/Gemfile.lock +9 -9
- metadata +108 -94
- data/stdlib/builtin/builtin.rbs +0 -42
File without changes
|
@@ -105,13 +105,13 @@
|
|
105
105
|
class IO < Object
|
106
106
|
include File::Constants
|
107
107
|
|
108
|
-
include Enumerable[String
|
108
|
+
include Enumerable[String]
|
109
109
|
|
110
110
|
def <<: (untyped arg0) -> self
|
111
111
|
|
112
112
|
def advise: (Symbol arg0, ?Integer offset, ?Integer len) -> NilClass
|
113
113
|
|
114
|
-
def autoclose=: (
|
114
|
+
def autoclose=: (boolish) -> bool
|
115
115
|
|
116
116
|
# Returns `true` if the underlying file descriptor of *ios* will be closed
|
117
117
|
# automatically at its finalization, otherwise `false` .
|
@@ -141,7 +141,7 @@ class IO < Object
|
|
141
141
|
# just ignored since Ruby 2.3.
|
142
142
|
def close: () -> NilClass
|
143
143
|
|
144
|
-
def close_on_exec=: (
|
144
|
+
def close_on_exec=: (boolish) -> bool
|
145
145
|
|
146
146
|
# Returns `true` if *ios* will be closed on exec.
|
147
147
|
#
|
@@ -474,7 +474,7 @@ class IO < Object
|
|
474
474
|
# ```
|
475
475
|
def sync: () -> bool
|
476
476
|
|
477
|
-
def sync=: (
|
477
|
+
def sync=: (boolish) -> bool
|
478
478
|
|
479
479
|
def sysread: (Integer maxlen, String outbuf) -> String
|
480
480
|
|
@@ -514,7 +514,7 @@ class IO < Object
|
|
514
514
|
|
515
515
|
def self.binwrite: (String name, _ToS arg0, ?Integer offset, ?external_encoding: String external_encoding, ?internal_encoding: String internal_encoding, ?encoding: String encoding, ?textmode: untyped textmode, ?binmode: untyped binmode, ?autoclose: untyped autoclose, ?mode: String mode) -> Integer
|
516
516
|
|
517
|
-
def self.copy_stream: (
|
517
|
+
def self.copy_stream: (_Reader src, _Writer dst, ?Integer copy_length, ?Integer src_offset) -> Integer
|
518
518
|
|
519
519
|
def self.popen: (*untyped args) -> untyped
|
520
520
|
|
@@ -522,7 +522,7 @@ class IO < Object
|
|
522
522
|
|
523
523
|
def self.readlines: (String name, ?String sep, ?Integer limit, ?external_encoding: String external_encoding, ?internal_encoding: String internal_encoding, ?encoding: String encoding, ?textmode: untyped textmode, ?binmode: untyped binmode, ?autoclose: untyped autoclose, ?mode: String mode) -> ::Array[String]
|
524
524
|
|
525
|
-
def self.select: (::Array[
|
525
|
+
def self.select: (::Array[io]? read_array, ?::Array[io]? write_array, ?::Array[io]? error_array, ?Integer? timeout) -> ::Array[::Array[io]]?
|
526
526
|
|
527
527
|
def self.sysopen: (String path, ?String mode, ?String perm) -> Integer
|
528
528
|
|
@@ -71,28 +71,6 @@ module Kernel
|
|
71
71
|
|
72
72
|
def srand: (?Numeric number) -> Numeric
|
73
73
|
|
74
|
-
def !~: (untyped other) -> bool
|
75
|
-
|
76
|
-
def <=>: (untyped other) -> Integer?
|
77
|
-
|
78
|
-
def ===: (untyped other) -> bool
|
79
|
-
|
80
|
-
def =~: (untyped other) -> NilClass
|
81
|
-
|
82
|
-
def clone: (?freeze: (TrueClass | FalseClass)) -> self
|
83
|
-
|
84
|
-
def display: (?IO port) -> NilClass
|
85
|
-
|
86
|
-
def dup: () -> self
|
87
|
-
|
88
|
-
def enum_for: (Symbol method, *untyped args) -> ::Enumerator[untyped, untyped]
|
89
|
-
| (Symbol method, *untyped args) { (*untyped args) -> (Integer|Float|nil) } -> ::Enumerator[untyped, untyped]
|
90
|
-
alias to_enum enum_for
|
91
|
-
|
92
|
-
def eql?: (untyped other) -> bool
|
93
|
-
|
94
|
-
def `extend`: (*Module mod) -> self
|
95
|
-
|
96
74
|
# Creates a subprocess. If a block is specified, that block is run in the
|
97
75
|
# subprocess, and the subprocess terminates with a status of zero.
|
98
76
|
# Otherwise, the `fork` call returns twice, once in the parent, returning
|
@@ -113,70 +91,8 @@ module Kernel
|
|
113
91
|
def fork: () -> Integer?
|
114
92
|
| () { () -> untyped } -> Integer?
|
115
93
|
|
116
|
-
def freeze: () -> self
|
117
|
-
|
118
|
-
def frozen?: () -> bool
|
119
|
-
|
120
|
-
def hash: () -> Integer
|
121
|
-
|
122
94
|
def initialize_copy: (self object) -> self
|
123
95
|
|
124
|
-
def inspect: () -> String
|
125
|
-
|
126
|
-
def instance_of?: (Class arg0) -> bool
|
127
|
-
|
128
|
-
def instance_variable_defined?: (Symbol | String arg0) -> bool
|
129
|
-
|
130
|
-
def instance_variable_get: (Symbol | String arg0) -> untyped
|
131
|
-
|
132
|
-
def instance_variable_set: [T] (Symbol | String arg0, T arg1) -> T
|
133
|
-
|
134
|
-
def instance_variables: () -> ::Array[Symbol]
|
135
|
-
|
136
|
-
def is_a?: (Class | Module arg0) -> bool
|
137
|
-
alias kind_of? is_a?
|
138
|
-
|
139
|
-
def method: (Symbol | String arg0) -> Method
|
140
|
-
|
141
|
-
def methods: (?bool regular) -> ::Array[Symbol]
|
142
|
-
|
143
|
-
def `nil?`: () -> FalseClass
|
144
|
-
|
145
|
-
def private_methods: (?bool all) -> ::Array[Symbol]
|
146
|
-
|
147
|
-
def protected_methods: (?bool all) -> ::Array[Symbol]
|
148
|
-
|
149
|
-
def public_method: (Symbol | String arg0) -> Method
|
150
|
-
|
151
|
-
def public_methods: (?bool all) -> ::Array[Symbol]
|
152
|
-
|
153
|
-
def `public_send`: (Symbol | String arg0, *untyped args) -> untyped
|
154
|
-
| (Symbol | String arg0, *untyped args) { (*untyped) -> untyped } -> untyped
|
155
|
-
|
156
|
-
def remove_instance_variable: (Symbol | String arg0) -> untyped
|
157
|
-
|
158
|
-
def `send`: (String | Symbol arg0, *untyped arg1) -> untyped
|
159
|
-
| (String | Symbol arg0, *untyped arg1) { (*untyped) -> untyped } -> untyped
|
160
|
-
|
161
|
-
def `singleton_class`: () -> Class
|
162
|
-
|
163
|
-
def singleton_method: (Symbol | String arg0) -> Method
|
164
|
-
|
165
|
-
def singleton_methods: (?bool all) -> ::Array[Symbol]
|
166
|
-
|
167
|
-
def taint: () -> self
|
168
|
-
alias untrust taint
|
169
|
-
|
170
|
-
def tainted?: () -> bool
|
171
|
-
alias untrusted? tainted?
|
172
|
-
|
173
|
-
def tap: () { (untyped x) -> void } -> self
|
174
|
-
|
175
|
-
def to_s: () -> String
|
176
|
-
|
177
|
-
def untaint: () -> self
|
178
|
-
alias trust untaint
|
179
|
-
|
180
96
|
# Returns `arg` as an [Array](https://ruby-doc.org/core-2.6.3/Array.html)
|
181
97
|
# .
|
182
98
|
#
|
@@ -331,7 +247,7 @@ module Kernel
|
|
331
247
|
# ```
|
332
248
|
def global_variables: () -> ::Array[Symbol]
|
333
249
|
|
334
|
-
def load: (String filename, ?
|
250
|
+
def load: (String filename, ?boolish) -> bool
|
335
251
|
|
336
252
|
# Repeatedly executes the block.
|
337
253
|
#
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -237,7 +237,7 @@ class Module < Object
|
|
237
237
|
# B.autoload?(:CONST) #=> "const.rb", found in A (ancestor)
|
238
238
|
# B.autoload?(:CONST, false) #=> nil, not found in B itself
|
239
239
|
#
|
240
|
-
def autoload?: (Symbol name, ?
|
240
|
+
def autoload?: (Symbol name, ?boolish inherit) -> String?
|
241
241
|
|
242
242
|
# Evaluates the string or block in the context of *mod*, except that when a
|
243
243
|
# block is given, constant/class variable lookup is not affected. This can be
|
@@ -329,7 +329,7 @@ class Module < Object
|
|
329
329
|
# Two.class_variables #=> [:@@var2, :@@var1]
|
330
330
|
# Two.class_variables(false) #=> [:@@var2]
|
331
331
|
#
|
332
|
-
def class_variables: (?
|
332
|
+
def class_variables: (?boolish inherit) -> ::Array[Symbol]
|
333
333
|
|
334
334
|
# Says whether *mod* or its ancestors have a constant with the given name:
|
335
335
|
#
|
@@ -364,7 +364,7 @@ class Module < Object
|
|
364
364
|
#
|
365
365
|
# Hash.const_defined? 'foobar' #=> NameError: wrong constant name foobar
|
366
366
|
#
|
367
|
-
def const_defined?: (Symbol | String
|
367
|
+
def const_defined?: (Symbol | String name, ?boolish inherit) -> bool
|
368
368
|
|
369
369
|
# Checks for a constant with the given name in *mod*. If `inherit` is set, the
|
370
370
|
# lookup will also search the ancestors (and `Object` if *mod* is a `Module`).
|
@@ -398,7 +398,7 @@ class Module < Object
|
|
398
398
|
#
|
399
399
|
# Object.const_get 'foobar' #=> NameError: wrong constant name foobar
|
400
400
|
#
|
401
|
-
def const_get: (Symbol | String
|
401
|
+
def const_get: (Symbol | String name, ?boolish inherit) -> untyped
|
402
402
|
|
403
403
|
# Invoked when a reference is made to an undefined constant in *mod*. It is
|
404
404
|
# passed a symbol for the undefined constant, and returns a value to be used for
|
@@ -455,7 +455,7 @@ class Module < Object
|
|
455
455
|
#
|
456
456
|
# Also see Module#const_defined?.
|
457
457
|
#
|
458
|
-
def constants: (?
|
458
|
+
def constants: (?boolish inherit) -> ::Array[Symbol]
|
459
459
|
|
460
460
|
# Defines an instance method in the receiver. The *method* parameter can be a
|
461
461
|
# `Proc`, a `Method` or an `UnboundMethod` object. If a block is specified, it
|
@@ -662,7 +662,7 @@ class Module < Object
|
|
662
662
|
# C.instance_methods(false) #=> [:method3]
|
663
663
|
# C.instance_methods.include?(:method2) #=> true
|
664
664
|
#
|
665
|
-
def instance_methods: (?
|
665
|
+
def instance_methods: (?boolish include_super) -> ::Array[Symbol]
|
666
666
|
|
667
667
|
# Invoked as a callback whenever an instance method is added to the receiver.
|
668
668
|
#
|
@@ -709,7 +709,7 @@ class Module < Object
|
|
709
709
|
# C.method_defined? "method4" #=> false
|
710
710
|
# C.method_defined? "private_method2" #=> false
|
711
711
|
#
|
712
|
-
def method_defined?: (Symbol | String
|
712
|
+
def method_defined?: (Symbol | String name, ?boolish inherit) -> bool
|
713
713
|
|
714
714
|
# Invoked as a callback whenever an instance method is removed from the
|
715
715
|
# receiver.
|
@@ -881,7 +881,7 @@ class Module < Object
|
|
881
881
|
# Mod.instance_methods #=> [:method2]
|
882
882
|
# Mod.private_instance_methods #=> [:method1]
|
883
883
|
#
|
884
|
-
def private_instance_methods: (?
|
884
|
+
def private_instance_methods: (?boolish include_super) -> ::Array[Symbol]
|
885
885
|
|
886
886
|
# Returns `true` if the named private method is defined by *mod*. If *inherit*
|
887
887
|
# is set, the lookup will also search *mod*'s ancestors. String arguments are
|
@@ -906,7 +906,7 @@ class Module < Object
|
|
906
906
|
# C.private_method_defined? "method2", false #=> false
|
907
907
|
# C.method_defined? "method2" #=> false
|
908
908
|
#
|
909
|
-
def private_method_defined?: (Symbol | String
|
909
|
+
def private_method_defined?: (Symbol | String name, ?boolish inherit) -> bool
|
910
910
|
|
911
911
|
# With no arguments, sets the default visibility for subsequently defined
|
912
912
|
# methods to protected. With arguments, sets the named methods to have protected
|
@@ -926,7 +926,7 @@ class Module < Object
|
|
926
926
|
# Returns a list of the protected instance methods defined in *mod*. If the
|
927
927
|
# optional parameter is `false`, the methods of any ancestors are not included.
|
928
928
|
#
|
929
|
-
def protected_instance_methods: (?
|
929
|
+
def protected_instance_methods: (?boolish include_super) -> ::Array[Symbol]
|
930
930
|
|
931
931
|
# Returns `true` if the named protected method is defined *mod*. If *inherit*
|
932
932
|
# is set, the lookup will also search *mod*'s ancestors. String arguments are
|
@@ -951,7 +951,7 @@ class Module < Object
|
|
951
951
|
# C.protected_method_defined? "method2", false #=> false
|
952
952
|
# C.method_defined? "method2" #=> true
|
953
953
|
#
|
954
|
-
def protected_method_defined?: (Symbol | String
|
954
|
+
def protected_method_defined?: (Symbol | String name, ?boolish inherit) -> bool
|
955
955
|
|
956
956
|
# With no arguments, sets the default visibility for subsequently defined
|
957
957
|
# methods to public. With arguments, sets the named methods to have public
|
@@ -976,7 +976,7 @@ class Module < Object
|
|
976
976
|
# Returns a list of the public instance methods defined in *mod*. If the
|
977
977
|
# optional parameter is `false`, the methods of any ancestors are not included.
|
978
978
|
#
|
979
|
-
def public_instance_methods: (?
|
979
|
+
def public_instance_methods: (?boolish include_super) -> ::Array[Symbol]
|
980
980
|
|
981
981
|
# Returns `true` if the named public method is defined by *mod*. If *inherit*
|
982
982
|
# is set, the lookup will also search *mod*'s ancestors. String arguments are
|
@@ -1001,7 +1001,7 @@ class Module < Object
|
|
1001
1001
|
# C.public_method_defined? "method2" #=> false
|
1002
1002
|
# C.method_defined? "method2" #=> true
|
1003
1003
|
#
|
1004
|
-
def public_method_defined?: (Symbol | String
|
1004
|
+
def public_method_defined?: (Symbol | String name, ?boolish inherit) -> bool
|
1005
1005
|
|
1006
1006
|
# Refine *mod* in the receiver.
|
1007
1007
|
#
|
File without changes
|
File without changes
|
@@ -631,7 +631,7 @@ class Object < BasicObject
|
|
631
631
|
# When the method name parameter is given as a string, the string is converted
|
632
632
|
# to a symbol.
|
633
633
|
#
|
634
|
-
def respond_to?: (name name, ?
|
634
|
+
def respond_to?: (name name, ?boolish include_all) -> bool
|
635
635
|
|
636
636
|
# Invokes the method identified by *symbol*, passing it any arguments specified.
|
637
637
|
# You can use `__send__` if the name `send` clashes with an existing method in
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# The ObjectSpace module contains a number of routines that interact with the
|
2
|
+
# garbage collection facility and allow you to traverse all living objects with
|
3
|
+
# an iterator.
|
4
|
+
#
|
5
|
+
# ObjectSpace also provides support for object finalizers, procs that will be
|
6
|
+
# called when a specific object is about to be destroyed by garbage collection.
|
7
|
+
#
|
8
|
+
# require 'objspace'
|
9
|
+
#
|
10
|
+
# a = "A"
|
11
|
+
# b = "B"
|
12
|
+
#
|
13
|
+
# ObjectSpace.define_finalizer(a, proc {|id| puts "Finalizer one on #{id}" })
|
14
|
+
# ObjectSpace.define_finalizer(b, proc {|id| puts "Finalizer two on #{id}" })
|
15
|
+
#
|
16
|
+
# *produces:*
|
17
|
+
#
|
18
|
+
# Finalizer two on 537763470
|
19
|
+
# Finalizer one on 537763480
|
20
|
+
module ObjectSpace
|
21
|
+
def self._id2ref: (Integer id) -> untyped
|
22
|
+
|
23
|
+
# Counts all objects grouped by type.
|
24
|
+
#
|
25
|
+
# It returns a hash, such as:
|
26
|
+
# {
|
27
|
+
# :TOTAL=>10000,
|
28
|
+
# :FREE=>3011,
|
29
|
+
# :T_OBJECT=>6,
|
30
|
+
# :T_CLASS=>404,
|
31
|
+
# # ...
|
32
|
+
# }
|
33
|
+
#
|
34
|
+
# The contents of the returned hash are implementation specific. It may be
|
35
|
+
# changed in future.
|
36
|
+
#
|
37
|
+
# The keys starting with `:T_` means live objects. For example, `:T_ARRAY` is
|
38
|
+
# the number of arrays. `:FREE` means object slots which is not used now.
|
39
|
+
# `:TOTAL` means sum of above.
|
40
|
+
#
|
41
|
+
# If the optional argument `result_hash` is given, it is overwritten and
|
42
|
+
# returned. This is intended to avoid probe effect.
|
43
|
+
#
|
44
|
+
# h = {}
|
45
|
+
# ObjectSpace.count_objects(h)
|
46
|
+
# puts h
|
47
|
+
# # => { :TOTAL=>10000, :T_CLASS=>158280, :T_MODULE=>20672, :T_STRING=>527249 }
|
48
|
+
#
|
49
|
+
# This method is only expected to work on C Ruby.
|
50
|
+
#
|
51
|
+
def self.count_objects: (?Hash[Symbol, Integer] result_hash) -> Hash[Symbol, Integer]
|
52
|
+
|
53
|
+
# Adds *aProc* as a finalizer, to be called after *obj* was destroyed. The
|
54
|
+
# object ID of the *obj* will be passed as an argument to *aProc*. If *aProc* is
|
55
|
+
# a lambda or method, make sure it can be called with a single argument.
|
56
|
+
#
|
57
|
+
def self.define_finalizer: (untyped obj, ^(Integer id) -> void aProc) -> [ Integer, Proc ]
|
58
|
+
| (untyped obj) { (Integer id) -> void } -> [ Integer, Proc ]
|
59
|
+
|
60
|
+
# Calls the block once for each living, nonimmediate object in this Ruby
|
61
|
+
# process. If *module* is specified, calls the block for only those classes or
|
62
|
+
# modules that match (or are a subclass of) *module*. Returns the number of
|
63
|
+
# objects found. Immediate objects (`Fixnum`s, `Symbol`s `true`, `false`, and
|
64
|
+
# `nil`) are never returned. In the example below, #each_object returns both the
|
65
|
+
# numbers we defined and several constants defined in the Math module.
|
66
|
+
#
|
67
|
+
# If no block is given, an enumerator is returned instead.
|
68
|
+
#
|
69
|
+
# a = 102.7
|
70
|
+
# b = 95 # Won't be returned
|
71
|
+
# c = 12345678987654321
|
72
|
+
# count = ObjectSpace.each_object(Numeric) {|x| p x }
|
73
|
+
# puts "Total count: #{count}"
|
74
|
+
#
|
75
|
+
# *produces:*
|
76
|
+
#
|
77
|
+
# 12345678987654321
|
78
|
+
# 102.7
|
79
|
+
# 2.71828182845905
|
80
|
+
# 3.14159265358979
|
81
|
+
# 2.22044604925031e-16
|
82
|
+
# 1.7976931348623157e+308
|
83
|
+
# 2.2250738585072e-308
|
84
|
+
# Total count: 7
|
85
|
+
#
|
86
|
+
def self.each_object: (?Module `module`) -> Enumerator[untyped, Integer]
|
87
|
+
| (?Module `module`) { (untyped obj) -> void } -> Integer
|
88
|
+
|
89
|
+
def self.garbage_collect: (?full_mark: bool, ?immediate_mark: bool, ?immediate_sweep: bool) -> void
|
90
|
+
|
91
|
+
# Removes all finalizers for *obj*.
|
92
|
+
#
|
93
|
+
def self.undefine_finalizer: [X] (X obj) -> X
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def garbage_collect: (?full_mark: bool, ?immediate_mark: bool, ?immediate_sweep: bool) -> void
|
98
|
+
end
|
File without changes
|
File without changes
|
@@ -246,7 +246,7 @@ module Random::Formatter
|
|
246
246
|
#
|
247
247
|
# See RFC 3548 for the definition of URL-safe base64.
|
248
248
|
#
|
249
|
-
def urlsafe_base64: (?Integer? n, ?
|
249
|
+
def urlsafe_base64: (?Integer? n, ?boolish padding) -> String
|
250
250
|
|
251
251
|
# SecureRandom.uuid generates a random v4 UUID (Universally Unique IDentifier).
|
252
252
|
#
|
@@ -88,7 +88,7 @@
|
|
88
88
|
# r.member?(Xs.new(5)) #=> true
|
89
89
|
# ```
|
90
90
|
class Range[out Elem] < Object
|
91
|
-
include Enumerable[Elem
|
91
|
+
include Enumerable[Elem]
|
92
92
|
|
93
93
|
def ==: (untyped obj) -> bool
|
94
94
|
|
@@ -101,7 +101,7 @@ class Range[out Elem] < Object
|
|
101
101
|
# ```
|
102
102
|
def begin: () -> Elem
|
103
103
|
|
104
|
-
def bsearch: [U] () { (Elem
|
104
|
+
def bsearch: [U] () { (Elem) -> boolish } -> U?
|
105
105
|
|
106
106
|
def cover?: (untyped obj) -> bool
|
107
107
|
|
@@ -144,7 +144,7 @@ class Range[out Elem] < Object
|
|
144
144
|
|
145
145
|
def `include?`: (untyped obj) -> bool
|
146
146
|
|
147
|
-
def initialize: (Elem from, Elem to, ?
|
147
|
+
def initialize: (Elem from, Elem to, ?boolish exclude_end) -> void
|
148
148
|
|
149
149
|
# Convert this range object to a printable form (using `inspect` to
|
150
150
|
# convert the begin and end objects).
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -317,7 +317,7 @@ class String
|
|
317
317
|
# "foo".casecmp?(2) #=> nil
|
318
318
|
# "\u{e4 f6 fc}".encode("ISO-8859-1").casecmp?("\u{c4 d6 dc}") #=> nil
|
319
319
|
#
|
320
|
-
def casecmp?: (untyped other) -> bool
|
320
|
+
def casecmp?: (untyped other) -> bool?
|
321
321
|
|
322
322
|
# Centers `str` in `width`. If `width` is greater than the length of `str`,
|
323
323
|
# returns a new String of length `width` with `str` centered and padded with
|
@@ -698,8 +698,8 @@ class String
|
|
698
698
|
# # "o\nwor"
|
699
699
|
# # "d"
|
700
700
|
#
|
701
|
-
def each_line: (?string separator, ?chomp:
|
702
|
-
| (?string separator, ?chomp:
|
701
|
+
def each_line: (?string separator, ?chomp: boolish) { (String line) -> void } -> self
|
702
|
+
| (?string separator, ?chomp: boolish) -> Enumerator[String, self]
|
703
703
|
|
704
704
|
# Returns `true` if *str* has a length of zero.
|
705
705
|
#
|
@@ -948,7 +948,7 @@ class String
|
|
948
948
|
# If a block is given, which is a deprecated form, works the same as
|
949
949
|
# `each_line`.
|
950
950
|
#
|
951
|
-
def lines: (?string separator, ?chomp:
|
951
|
+
def lines: (?string separator, ?chomp: boolish) -> Array[String]
|
952
952
|
|
953
953
|
# If *integer* is greater than the length of *str*, returns a new String of
|
954
954
|
# length *integer* with *str* left justified and padded with *padstr*;
|
@@ -1861,8 +1861,8 @@ class String
|
|
1861
1861
|
# "25".upto("5").to_a #=> []
|
1862
1862
|
# "07".upto("11").to_a #=> ["07", "08", "09", "10", "11"]
|
1863
1863
|
#
|
1864
|
-
def upto: (string other_str, ?
|
1865
|
-
| (string other_str, ?
|
1864
|
+
def upto: (string other_str, ?boolish exclusive) -> Enumerator[String, self]
|
1865
|
+
| (string other_str, ?boolish exclusive) { (String s) -> void } -> self
|
1866
1866
|
|
1867
1867
|
# Returns true for a string which is encoded correctly.
|
1868
1868
|
#
|