steep 0.13.0 → 0.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +0 -3
- data/CHANGELOG.md +28 -0
- data/Rakefile +0 -13
- data/bin/setup +0 -2
- data/bin/smoke_runner.rb +0 -1
- data/exe/steep +0 -1
- data/lib/steep.rb +33 -1
- data/lib/steep/annotation_parser.rb +4 -4
- data/lib/steep/ast/buffer.rb +11 -7
- data/lib/steep/ast/builtin.rb +8 -0
- data/lib/steep/ast/types/factory.rb +124 -89
- data/lib/steep/cli.rb +16 -1
- data/lib/steep/drivers/annotations.rb +1 -1
- data/lib/steep/drivers/check.rb +20 -4
- data/lib/steep/drivers/init.rb +5 -5
- data/lib/steep/drivers/langserver.rb +13 -287
- data/lib/steep/drivers/utils/driver_helper.rb +1 -1
- data/lib/steep/drivers/vendor.rb +2 -2
- data/lib/steep/drivers/watch.rb +97 -85
- data/lib/steep/drivers/worker.rb +51 -0
- data/lib/steep/project.rb +9 -5
- data/lib/steep/project/completion_provider.rb +298 -0
- data/lib/steep/project/dsl.rb +14 -0
- data/lib/steep/project/file.rb +54 -47
- data/lib/steep/project/hover_content.rb +17 -8
- data/lib/steep/project/options.rb +25 -3
- data/lib/steep/project/target.rb +40 -24
- data/lib/steep/server/base_worker.rb +56 -0
- data/lib/steep/server/code_worker.rb +151 -0
- data/lib/steep/server/interaction_worker.rb +281 -0
- data/lib/steep/server/master.rb +196 -0
- data/lib/steep/server/signature_worker.rb +148 -0
- data/lib/steep/server/utils.rb +36 -0
- data/lib/steep/server/worker_process.rb +62 -0
- data/lib/steep/signature/errors.rb +1 -1
- data/lib/steep/signature/validator.rb +13 -13
- data/lib/steep/source.rb +1 -1
- data/lib/steep/type_construction.rb +1004 -727
- data/lib/steep/type_inference/constant_env.rb +3 -11
- data/lib/steep/type_inference/context.rb +8 -3
- data/lib/steep/type_inference/context_array.rb +111 -0
- data/lib/steep/type_inference/local_variable_type_env.rb +226 -0
- data/lib/steep/type_inference/logic.rb +130 -0
- data/lib/steep/type_inference/type_env.rb +5 -69
- data/lib/steep/typing.rb +91 -23
- data/lib/steep/version.rb +1 -1
- data/smoke/alias/Steepfile +1 -0
- data/smoke/alias/a.rb +1 -1
- data/smoke/and/Steepfile +1 -0
- data/smoke/array/Steepfile +1 -0
- data/smoke/array/b.rb +0 -2
- data/smoke/block/Steepfile +1 -0
- data/smoke/case/Steepfile +1 -0
- data/smoke/class/Steepfile +1 -0
- data/smoke/const/Steepfile +1 -0
- data/smoke/dstr/Steepfile +1 -0
- data/smoke/ensure/Steepfile +1 -0
- data/smoke/enumerator/Steepfile +1 -0
- data/smoke/extension/Steepfile +1 -0
- data/smoke/extension/c.rb +1 -0
- data/smoke/hash/Steepfile +1 -0
- data/smoke/hello/Steepfile +1 -0
- data/smoke/if/Steepfile +1 -0
- data/smoke/if/a.rb +1 -1
- data/smoke/implements/Steepfile +1 -0
- data/smoke/initialize/Steepfile +1 -0
- data/smoke/integer/Steepfile +1 -0
- data/smoke/interface/Steepfile +1 -0
- data/smoke/kwbegin/Steepfile +1 -0
- data/smoke/lambda/Steepfile +1 -0
- data/smoke/literal/Steepfile +1 -0
- data/smoke/map/Steepfile +1 -0
- data/smoke/method/Steepfile +1 -0
- data/smoke/module/Steepfile +1 -0
- data/smoke/regexp/Steepfile +1 -0
- data/smoke/regexp/b.rb +4 -4
- data/smoke/regression/Steepfile +1 -0
- data/smoke/rescue/Steepfile +1 -0
- data/smoke/rescue/a.rb +1 -1
- data/smoke/self/Steepfile +1 -0
- data/smoke/skip/Steepfile +1 -0
- data/smoke/stdout/Steepfile +1 -0
- data/smoke/super/Steepfile +1 -0
- data/smoke/type_case/Steepfile +1 -0
- data/smoke/yield/Steepfile +1 -0
- data/steep.gemspec +8 -8
- metadata +38 -138
- data/exe/rbs +0 -3
- data/exe/ruby-signature +0 -3
- data/vendor/ruby-signature/.github/workflows/ruby.yml +0 -27
- data/vendor/ruby-signature/.gitignore +0 -12
- data/vendor/ruby-signature/.rubocop.yml +0 -15
- data/vendor/ruby-signature/BSDL +0 -22
- data/vendor/ruby-signature/COPYING +0 -56
- data/vendor/ruby-signature/Gemfile +0 -6
- data/vendor/ruby-signature/README.md +0 -93
- data/vendor/ruby-signature/Rakefile +0 -66
- data/vendor/ruby-signature/bin/annotate-with-rdoc +0 -156
- data/vendor/ruby-signature/bin/console +0 -14
- data/vendor/ruby-signature/bin/query-rdoc +0 -103
- data/vendor/ruby-signature/bin/setup +0 -10
- data/vendor/ruby-signature/bin/sort +0 -88
- data/vendor/ruby-signature/bin/test_runner.rb +0 -17
- data/vendor/ruby-signature/docs/CONTRIBUTING.md +0 -97
- data/vendor/ruby-signature/docs/sigs.md +0 -148
- data/vendor/ruby-signature/docs/stdlib.md +0 -152
- data/vendor/ruby-signature/docs/syntax.md +0 -528
- data/vendor/ruby-signature/exe/rbs +0 -3
- data/vendor/ruby-signature/exe/ruby-signature +0 -7
- data/vendor/ruby-signature/lib/ruby/signature.rb +0 -64
- data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +0 -29
- data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +0 -29
- data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +0 -391
- data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +0 -364
- data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +0 -52
- data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +0 -54
- data/vendor/ruby-signature/lib/ruby/signature/cli.rb +0 -534
- data/vendor/ruby-signature/lib/ruby/signature/constant.rb +0 -28
- data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +0 -152
- data/vendor/ruby-signature/lib/ruby/signature/definition.rb +0 -172
- data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +0 -921
- data/vendor/ruby-signature/lib/ruby/signature/environment.rb +0 -283
- data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +0 -138
- data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +0 -126
- data/vendor/ruby-signature/lib/ruby/signature/errors.rb +0 -189
- data/vendor/ruby-signature/lib/ruby/signature/location.rb +0 -104
- data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +0 -125
- data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +0 -93
- data/vendor/ruby-signature/lib/ruby/signature/parser.y +0 -1343
- data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +0 -441
- data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +0 -579
- data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +0 -383
- data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +0 -48
- data/vendor/ruby-signature/lib/ruby/signature/test.rb +0 -28
- data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +0 -63
- data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +0 -290
- data/vendor/ruby-signature/lib/ruby/signature/test/setup.rb +0 -58
- data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +0 -324
- data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +0 -185
- data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +0 -256
- data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +0 -72
- data/vendor/ruby-signature/lib/ruby/signature/types.rb +0 -932
- data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +0 -140
- data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +0 -49
- data/vendor/ruby-signature/lib/ruby/signature/version.rb +0 -5
- data/vendor/ruby-signature/lib/ruby/signature/writer.rb +0 -271
- data/vendor/ruby-signature/ruby-signature.gemspec +0 -45
- data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +0 -3
- data/vendor/ruby-signature/stdlib/base64/base64.rbs +0 -15
- data/vendor/ruby-signature/stdlib/builtin/array.rbs +0 -1997
- data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +0 -280
- data/vendor/ruby-signature/stdlib/builtin/binding.rbs +0 -177
- data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +0 -35
- data/vendor/ruby-signature/stdlib/builtin/class.rbs +0 -145
- data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +0 -116
- data/vendor/ruby-signature/stdlib/builtin/complex.rbs +0 -400
- data/vendor/ruby-signature/stdlib/builtin/constants.rbs +0 -37
- data/vendor/ruby-signature/stdlib/builtin/data.rbs +0 -5
- data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +0 -2
- data/vendor/ruby-signature/stdlib/builtin/dir.rbs +0 -419
- data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +0 -606
- data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +0 -404
- data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +0 -260
- data/vendor/ruby-signature/stdlib/builtin/errno.rbs +0 -781
- data/vendor/ruby-signature/stdlib/builtin/errors.rbs +0 -582
- data/vendor/ruby-signature/stdlib/builtin/exception.rbs +0 -193
- data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +0 -40
- data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +0 -68
- data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +0 -12
- data/vendor/ruby-signature/stdlib/builtin/file.rbs +0 -476
- data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +0 -59
- data/vendor/ruby-signature/stdlib/builtin/float.rbs +0 -696
- data/vendor/ruby-signature/stdlib/builtin/gc.rbs +0 -121
- data/vendor/ruby-signature/stdlib/builtin/hash.rbs +0 -1029
- data/vendor/ruby-signature/stdlib/builtin/integer.rbs +0 -710
- data/vendor/ruby-signature/stdlib/builtin/io.rbs +0 -683
- data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +0 -574
- data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +0 -135
- data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +0 -141
- data/vendor/ruby-signature/stdlib/builtin/math.rbs +0 -66
- data/vendor/ruby-signature/stdlib/builtin/method.rbs +0 -182
- data/vendor/ruby-signature/stdlib/builtin/module.rbs +0 -248
- data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +0 -82
- data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +0 -409
- data/vendor/ruby-signature/stdlib/builtin/object.rbs +0 -824
- data/vendor/ruby-signature/stdlib/builtin/proc.rbs +0 -426
- data/vendor/ruby-signature/stdlib/builtin/process.rbs +0 -354
- data/vendor/ruby-signature/stdlib/builtin/random.rbs +0 -93
- data/vendor/ruby-signature/stdlib/builtin/range.rbs +0 -226
- data/vendor/ruby-signature/stdlib/builtin/rational.rbs +0 -424
- data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +0 -10
- data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +0 -131
- data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +0 -14
- data/vendor/ruby-signature/stdlib/builtin/signal.rbs +0 -55
- data/vendor/ruby-signature/stdlib/builtin/string.rbs +0 -770
- data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +0 -13
- data/vendor/ruby-signature/stdlib/builtin/struct.rbs +0 -40
- data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +0 -230
- data/vendor/ruby-signature/stdlib/builtin/thread.rbs +0 -1112
- data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +0 -23
- data/vendor/ruby-signature/stdlib/builtin/time.rbs +0 -739
- data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +0 -91
- data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +0 -46
- data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +0 -159
- data/vendor/ruby-signature/stdlib/builtin/warning.rbs +0 -17
- data/vendor/ruby-signature/stdlib/erb/erb.rbs +0 -18
- data/vendor/ruby-signature/stdlib/find/find.rbs +0 -44
- data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +0 -21
- data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +0 -23
- data/vendor/ruby-signature/stdlib/prime/prime.rbs +0 -188
- data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +0 -9
- data/vendor/ruby-signature/stdlib/set/set.rbs +0 -77
- data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +0 -53
@@ -1,574 +0,0 @@
|
|
1
|
-
# The [Kernel](Kernel) module is included by class
|
2
|
-
# [Object](https://ruby-doc.org/core-2.6.3/Object.html), so its methods
|
3
|
-
# are available in every Ruby object.
|
4
|
-
#
|
5
|
-
# The [Kernel](Kernel) instance methods are documented
|
6
|
-
# in class [Object](https://ruby-doc.org/core-2.6.3/Object.html) while the
|
7
|
-
# module methods are documented here. These methods are called without a
|
8
|
-
# receiver and thus can be called in functional form:
|
9
|
-
#
|
10
|
-
# ```ruby
|
11
|
-
# sprintf "%.1f", 1.234 #=> "1.2"
|
12
|
-
# ```
|
13
|
-
module Kernel
|
14
|
-
def caller: (?Integer start_or_range, ?Integer length) -> ::Array[String]?
|
15
|
-
| (?::Range[Integer] start_or_range) -> ::Array[String]?
|
16
|
-
| () -> ::Array[String]
|
17
|
-
|
18
|
-
def caller_locations: (?Integer start_or_range, ?Integer length) -> ::Array[Thread::Backtrace::Location]?
|
19
|
-
| (?::Range[Integer] start_or_range) -> ::Array[Thread::Backtrace::Location]?
|
20
|
-
|
21
|
-
def catch: [T] (T tag) { (T tag) -> untyped } -> untyped
|
22
|
-
| () { (Object tag) -> untyped } -> untyped
|
23
|
-
|
24
|
-
# In a perfect world this should be:
|
25
|
-
#
|
26
|
-
# returns(T.class_of(T.self_type))
|
27
|
-
#
|
28
|
-
# but that doesn't work (yet). Even making it:
|
29
|
-
#
|
30
|
-
# returns(Class)
|
31
|
-
#
|
32
|
-
# is very surprising since users expect their methods to be present.
|
33
|
-
# So we settle for untyped.
|
34
|
-
def `class`: () -> untyped
|
35
|
-
|
36
|
-
def define_singleton_method: (Symbol | String symbol, ?Proc | Method | UnboundMethod method) -> Symbol
|
37
|
-
| (Symbol | String symbol) { () -> untyped } -> Symbol
|
38
|
-
|
39
|
-
def eval: (String arg0, ?Binding arg1, ?String filename, ?Integer lineno) -> untyped
|
40
|
-
|
41
|
-
# Returns `true` if `yield` would execute a block in the current context.
|
42
|
-
# The `iterator?` form is mildly deprecated.
|
43
|
-
#
|
44
|
-
# ```ruby
|
45
|
-
# def try
|
46
|
-
# if block_given?
|
47
|
-
# yield
|
48
|
-
# else
|
49
|
-
# "no block"
|
50
|
-
# end
|
51
|
-
# end
|
52
|
-
# try #=> "no block"
|
53
|
-
# try { "hello" } #=> "hello"
|
54
|
-
# try do "hello" end #=> "hello"
|
55
|
-
# ```
|
56
|
-
def iterator?: () -> bool
|
57
|
-
alias block_given? iterator?
|
58
|
-
|
59
|
-
# Returns the names of the current local variables.
|
60
|
-
#
|
61
|
-
# ```ruby
|
62
|
-
# fred = 1
|
63
|
-
# for i in 1..10
|
64
|
-
# # ...
|
65
|
-
# end
|
66
|
-
# local_variables #=> [:fred, :i]
|
67
|
-
# ```
|
68
|
-
def local_variables: () -> ::Array[Symbol]
|
69
|
-
|
70
|
-
def srand: (?Numeric number) -> Numeric
|
71
|
-
|
72
|
-
def !~: (untyped other) -> bool
|
73
|
-
|
74
|
-
def <=>: (untyped other) -> Integer?
|
75
|
-
|
76
|
-
def ===: (untyped other) -> bool
|
77
|
-
|
78
|
-
def =~: (untyped other) -> NilClass
|
79
|
-
|
80
|
-
def clone: (?freeze: (TrueClass | FalseClass)) -> self
|
81
|
-
|
82
|
-
def display: (?IO port) -> NilClass
|
83
|
-
|
84
|
-
def dup: () -> self
|
85
|
-
|
86
|
-
def enum_for: (Symbol method, *untyped args) -> ::Enumerator[untyped, untyped]
|
87
|
-
| (Symbol method, *untyped args) { (*untyped args) -> (Integer|Float|nil) } -> ::Enumerator[untyped, untyped]
|
88
|
-
alias to_enum enum_for
|
89
|
-
|
90
|
-
def eql?: (untyped other) -> bool
|
91
|
-
|
92
|
-
def `extend`: (*Module mod) -> self
|
93
|
-
|
94
|
-
# Creates a subprocess. If a block is specified, that block is run in the
|
95
|
-
# subprocess, and the subprocess terminates with a status of zero.
|
96
|
-
# Otherwise, the `fork` call returns twice, once in the parent, returning
|
97
|
-
# the process ID of the child, and once in the child, returning *nil* .
|
98
|
-
# The child process can exit using `Kernel.exit!` to avoid running any
|
99
|
-
# `at_exit` functions. The parent process should use `Process.wait` to
|
100
|
-
# collect the termination statuses of its children or use `Process.detach`
|
101
|
-
# to register disinterest in their status; otherwise, the operating system
|
102
|
-
# may accumulate zombie processes.
|
103
|
-
#
|
104
|
-
# The thread calling fork is the only thread in the created child process.
|
105
|
-
# fork doesn’t copy other threads.
|
106
|
-
#
|
107
|
-
# If fork is not usable, Process.respond\_to?(:fork) returns false.
|
108
|
-
#
|
109
|
-
# Note that fork(2) is not available on some platforms like Windows and
|
110
|
-
# NetBSD 4. Therefore you should use spawn() instead of fork().
|
111
|
-
def fork: () -> Integer?
|
112
|
-
| () { () -> untyped } -> Integer?
|
113
|
-
|
114
|
-
def freeze: () -> self
|
115
|
-
|
116
|
-
def frozen?: () -> bool
|
117
|
-
|
118
|
-
def hash: () -> Integer
|
119
|
-
|
120
|
-
def initialize_copy: (self object) -> self
|
121
|
-
|
122
|
-
def inspect: () -> String
|
123
|
-
|
124
|
-
def instance_of?: (Class arg0) -> bool
|
125
|
-
|
126
|
-
def instance_variable_defined?: (Symbol | String arg0) -> bool
|
127
|
-
|
128
|
-
def instance_variable_get: (Symbol | String arg0) -> untyped
|
129
|
-
|
130
|
-
def instance_variable_set: [T] (Symbol | String arg0, T arg1) -> T
|
131
|
-
|
132
|
-
def instance_variables: () -> ::Array[Symbol]
|
133
|
-
|
134
|
-
def is_a?: (Class | Module arg0) -> bool
|
135
|
-
alias kind_of? is_a?
|
136
|
-
|
137
|
-
def method: (Symbol | String arg0) -> Method
|
138
|
-
|
139
|
-
def methods: (?bool regular) -> ::Array[Symbol]
|
140
|
-
|
141
|
-
def `nil?`: () -> FalseClass
|
142
|
-
|
143
|
-
def private_methods: (?bool all) -> ::Array[Symbol]
|
144
|
-
|
145
|
-
def protected_methods: (?bool all) -> ::Array[Symbol]
|
146
|
-
|
147
|
-
def public_method: (Symbol | String arg0) -> Method
|
148
|
-
|
149
|
-
def public_methods: (?bool all) -> ::Array[Symbol]
|
150
|
-
|
151
|
-
def `public_send`: (Symbol | String arg0, *untyped args) -> untyped
|
152
|
-
| (Symbol | String arg0, *untyped args) { (*untyped) -> untyped } -> untyped
|
153
|
-
|
154
|
-
def remove_instance_variable: (Symbol | String arg0) -> untyped
|
155
|
-
|
156
|
-
def `send`: (String | Symbol arg0, *untyped arg1) -> untyped
|
157
|
-
| (String | Symbol arg0, *untyped arg1) { (*untyped) -> untyped } -> untyped
|
158
|
-
|
159
|
-
def `singleton_class`: () -> Class
|
160
|
-
|
161
|
-
def singleton_method: (Symbol | String arg0) -> Method
|
162
|
-
|
163
|
-
def singleton_methods: (?bool all) -> ::Array[Symbol]
|
164
|
-
|
165
|
-
def taint: () -> self
|
166
|
-
alias untrust taint
|
167
|
-
|
168
|
-
def tainted?: () -> bool
|
169
|
-
alias untrusted? tainted?
|
170
|
-
|
171
|
-
def tap: () { (untyped x) -> void } -> self
|
172
|
-
|
173
|
-
def to_s: () -> String
|
174
|
-
|
175
|
-
def untaint: () -> self
|
176
|
-
alias trust untaint
|
177
|
-
|
178
|
-
# Returns `arg` as an [Array](https://ruby-doc.org/core-2.6.3/Array.html)
|
179
|
-
# .
|
180
|
-
#
|
181
|
-
# First tries to call `to_ary` on `arg`, then `to_a` . If `arg` does not
|
182
|
-
# respond to `to_ary` or `to_a`, returns an
|
183
|
-
# [Array](https://ruby-doc.org/core-2.6.3/Array.html) of length 1
|
184
|
-
# containing `arg` .
|
185
|
-
#
|
186
|
-
# If `to_ary` or `to_a` returns something other than an
|
187
|
-
# [Array](https://ruby-doc.org/core-2.6.3/Array.html), raises a
|
188
|
-
# `TypeError` .
|
189
|
-
#
|
190
|
-
# ```ruby
|
191
|
-
# Array(["a", "b"]) #=> ["a", "b"]
|
192
|
-
# Array(1..5) #=> [1, 2, 3, 4, 5]
|
193
|
-
# Array(key: :value) #=> [[:key, :value]]
|
194
|
-
# Array(nil) #=> []
|
195
|
-
# Array(1) #=> [1]
|
196
|
-
# ```
|
197
|
-
def Array: (NilClass x) -> [ ]
|
198
|
-
| [T] (::Array[T] x) -> ::Array[T]
|
199
|
-
| [T] (::Range[T] x) -> ::Array[T]
|
200
|
-
| [K, V] (::Hash[K, V] x) -> ::Array[[K, V]]
|
201
|
-
| [T] (T x) -> ::Array[T]
|
202
|
-
|
203
|
-
def Complex: (Numeric | String x, ?Numeric | String y, ?exception: bool exception) -> Complex
|
204
|
-
|
205
|
-
def Float: (Numeric | String x, ?exception: bool exception) -> Float
|
206
|
-
|
207
|
-
def Hash: [K, V] (Object x) -> ::Hash[K, V]
|
208
|
-
|
209
|
-
def Integer: (Numeric | String arg, ?exception: bool exception) -> Integer
|
210
|
-
| (String arg, ?Integer base, ?exception: bool exception) -> Integer
|
211
|
-
|
212
|
-
def Rational: (Numeric | String | Object x, ?Numeric | String y, ?exception: bool exception) -> Rational
|
213
|
-
|
214
|
-
def String: (Object x) -> String
|
215
|
-
|
216
|
-
# Returns the called name of the current method as a
|
217
|
-
# [Symbol](https://ruby-doc.org/core-2.6.3/Symbol.html). If called
|
218
|
-
# outside of a method, it returns `nil` .
|
219
|
-
def __callee__: () -> Symbol?
|
220
|
-
|
221
|
-
# Returns the canonicalized absolute path of the directory of the file
|
222
|
-
# from which this method is called. It means symlinks in the path is
|
223
|
-
# resolved. If `__FILE__` is `nil`, it returns `nil` . The return value
|
224
|
-
# equals to `File.dirname(File.realpath(__FILE__))` .
|
225
|
-
def __dir__: () -> String?
|
226
|
-
|
227
|
-
# Returns the name at the definition of the current method as a
|
228
|
-
# [Symbol](https://ruby-doc.org/core-2.6.3/Symbol.html). If called
|
229
|
-
# outside of a method, it returns `nil` .
|
230
|
-
def __method__: () -> Symbol?
|
231
|
-
|
232
|
-
def `: (String arg0) -> String
|
233
|
-
|
234
|
-
def abort: (?String msg) -> bot
|
235
|
-
|
236
|
-
def at_exit: () { () -> untyped } -> Proc
|
237
|
-
|
238
|
-
def autoload: (String | Symbol _module, String filename) -> NilClass
|
239
|
-
|
240
|
-
def autoload?: (Symbol | String name) -> String?
|
241
|
-
|
242
|
-
# Returns a `Binding` object, describing the variable and method bindings
|
243
|
-
# at the point of call. This object can be used when calling `eval` to
|
244
|
-
# execute the evaluated command in this environment. See also the
|
245
|
-
# description of class `Binding` .
|
246
|
-
#
|
247
|
-
# ```ruby
|
248
|
-
# def get_binding(param)
|
249
|
-
# binding
|
250
|
-
# end
|
251
|
-
# b = get_binding("hello")
|
252
|
-
# eval("param", b) #=> "hello"
|
253
|
-
# ```
|
254
|
-
def binding: () -> Binding
|
255
|
-
|
256
|
-
# Initiates the termination of the Ruby script by raising the `SystemExit`
|
257
|
-
# exception. This exception may be caught. The optional parameter is used
|
258
|
-
# to return a status code to the invoking environment. `true` and `FALSE`
|
259
|
-
# of *status* means success and failure respectively. The interpretation
|
260
|
-
# of other integer values are system dependent.
|
261
|
-
#
|
262
|
-
# ```ruby
|
263
|
-
# begin
|
264
|
-
# exit
|
265
|
-
# puts "never get here"
|
266
|
-
# rescue SystemExit
|
267
|
-
# puts "rescued a SystemExit exception"
|
268
|
-
# end
|
269
|
-
# puts "after begin block"
|
270
|
-
# ```
|
271
|
-
#
|
272
|
-
# *produces:*
|
273
|
-
#
|
274
|
-
# rescued a SystemExit exception
|
275
|
-
# after begin block
|
276
|
-
#
|
277
|
-
# Just prior to termination, Ruby executes any `at_exit` functions (see
|
278
|
-
# Kernel::at\_exit) and runs any object finalizers (see
|
279
|
-
# [ObjectSpace.define\_finalizer](https://ruby-doc.org/core-2.6.3/ObjectSpace.html#method-c-define_finalizer)
|
280
|
-
# ).
|
281
|
-
#
|
282
|
-
# ```ruby
|
283
|
-
# at_exit { puts "at_exit function" }
|
284
|
-
# ObjectSpace.define_finalizer("string", proc { puts "in finalizer" })
|
285
|
-
# exit
|
286
|
-
# ```
|
287
|
-
#
|
288
|
-
# *produces:*
|
289
|
-
#
|
290
|
-
# at_exit function
|
291
|
-
# in finalizer
|
292
|
-
def exit: () -> bot
|
293
|
-
| (?Integer | TrueClass | FalseClass status) -> bot
|
294
|
-
|
295
|
-
def exit!: (Integer | TrueClass | FalseClass status) -> bot
|
296
|
-
|
297
|
-
# With no arguments, raises the exception in `$!` or raises a
|
298
|
-
# `RuntimeError` if `$!` is `nil` . With a single `String` argument,
|
299
|
-
# raises a `RuntimeError` with the string as a message. Otherwise, the
|
300
|
-
# first parameter should be the name of an `Exception` class (or an object
|
301
|
-
# that returns an `Exception` object when sent an `exception` message).
|
302
|
-
# The optional second parameter sets the message associated with the
|
303
|
-
# exception, and the third parameter is an array of callback information.
|
304
|
-
# Exceptions are caught by the `rescue` clause of `begin...end` blocks.
|
305
|
-
#
|
306
|
-
# ```ruby
|
307
|
-
# raise "Failed to create socket"
|
308
|
-
# raise ArgumentError, "No parameters", caller
|
309
|
-
# ```
|
310
|
-
#
|
311
|
-
# The `cause` of the generated exception is automatically set to the
|
312
|
-
# “current” exception ( `$!` ) if any. An alternative value, either an
|
313
|
-
# `Exception` object or `nil`, can be specified via the `:cause`
|
314
|
-
# argument.
|
315
|
-
def fail: () -> bot
|
316
|
-
| (String arg0) -> bot
|
317
|
-
| (?Exception arg0, ?String arg1, ?::Array[String] arg2) -> bot
|
318
|
-
alias raise fail
|
319
|
-
|
320
|
-
def format: (String format, *untyped args) -> String
|
321
|
-
alias sprintf format
|
322
|
-
|
323
|
-
def gets: (?String arg0, ?Integer arg1) -> String?
|
324
|
-
|
325
|
-
# Returns an array of the names of global variables.
|
326
|
-
#
|
327
|
-
# ```ruby
|
328
|
-
# global_variables.grep /std/ #=> [:$stdin, :$stdout, :$stderr]
|
329
|
-
# ```
|
330
|
-
def global_variables: () -> ::Array[Symbol]
|
331
|
-
|
332
|
-
def load: (String filename, ?bool arg0) -> bool
|
333
|
-
|
334
|
-
# Repeatedly executes the block.
|
335
|
-
#
|
336
|
-
# If no block is given, an enumerator is returned instead.
|
337
|
-
#
|
338
|
-
# ```ruby
|
339
|
-
# loop do
|
340
|
-
# print "Input: "
|
341
|
-
# line = gets
|
342
|
-
# break if !line or line =~ /^qQ/
|
343
|
-
# # ...
|
344
|
-
# end
|
345
|
-
# ```
|
346
|
-
#
|
347
|
-
# [StopIteration](https://ruby-doc.org/core-2.6.3/StopIteration.html)
|
348
|
-
# raised in the block breaks the loop. In this case, loop returns the
|
349
|
-
# "result" value stored in the exception.
|
350
|
-
#
|
351
|
-
# ```ruby
|
352
|
-
# enum = Enumerator.new { |y|
|
353
|
-
# y << "one"
|
354
|
-
# y << "two"
|
355
|
-
# :ok
|
356
|
-
# }
|
357
|
-
#
|
358
|
-
# result = loop {
|
359
|
-
# puts enum.next
|
360
|
-
# } #=> :ok
|
361
|
-
# ```
|
362
|
-
def loop: () { (nil) -> untyped } -> bot
|
363
|
-
| () -> ::Enumerator[nil, bot]
|
364
|
-
|
365
|
-
def open: (String name, ?String mode, ?Integer perm) -> IO?
|
366
|
-
| [T] (String name, ?String mode, ?Integer perm) { (IO) -> T } -> T
|
367
|
-
|
368
|
-
# Prints each object in turn to `$stdout` . If the output field separator
|
369
|
-
# ( `$,` ) is not `nil`, its contents will appear between each field. If
|
370
|
-
# the output record separator ( `$\` ) is not `nil`, it will be appended
|
371
|
-
# to the output. If no arguments are given, prints `$_` . Objects that
|
372
|
-
# aren’t strings will be converted by calling their `to_s` method.
|
373
|
-
#
|
374
|
-
# ```ruby
|
375
|
-
# print "cat", [1,2,3], 99, "\n"
|
376
|
-
# $, = ", "
|
377
|
-
# $\ = "\n"
|
378
|
-
# print "cat", [1,2,3], 99
|
379
|
-
# ```
|
380
|
-
#
|
381
|
-
# *produces:*
|
382
|
-
#
|
383
|
-
# cat12399
|
384
|
-
# cat, 1, 2, 3, 99
|
385
|
-
def print: (*Kernel args) -> nil
|
386
|
-
|
387
|
-
def printf: (?IO arg0, ?String arg1, *untyped arg2) -> nil
|
388
|
-
|
389
|
-
def proc: () { () -> untyped } -> Proc
|
390
|
-
|
391
|
-
def lambda: () { () -> untyped } -> Proc
|
392
|
-
|
393
|
-
def putc: (Integer arg0) -> Integer
|
394
|
-
| (String arg0) -> String
|
395
|
-
|
396
|
-
def puts: (*untyped arg0) -> NilClass
|
397
|
-
|
398
|
-
def p: [T] (T arg0) -> T
|
399
|
-
| (*untyped arg0) -> Array[untyped]
|
400
|
-
|
401
|
-
def pp: [T] (T arg0) -> T
|
402
|
-
| (*untyped arg0) -> Array[untyped]
|
403
|
-
|
404
|
-
# If called without an argument, or if `max.to_i.abs == 0`, rand returns
|
405
|
-
# a pseudo-random floating point number between 0.0 and 1.0, including 0.0
|
406
|
-
# and excluding 1.0.
|
407
|
-
#
|
408
|
-
# ```ruby
|
409
|
-
# rand #=> 0.2725926052826416
|
410
|
-
# ```
|
411
|
-
#
|
412
|
-
# When `max.abs` is greater than or equal to 1, `rand` returns a
|
413
|
-
# pseudo-random integer greater than or equal to 0 and less than
|
414
|
-
# `max.to_i.abs` .
|
415
|
-
#
|
416
|
-
# ```ruby
|
417
|
-
# rand(100) #=> 12
|
418
|
-
# ```
|
419
|
-
#
|
420
|
-
# When `max` is a [Range](https://ruby-doc.org/core-2.6.3/Range.html),
|
421
|
-
# `rand` returns a random number where range.member?(number) == true.
|
422
|
-
#
|
423
|
-
# Negative or floating point values for `max` are allowed, but may give
|
424
|
-
# surprising results.
|
425
|
-
#
|
426
|
-
# ```ruby
|
427
|
-
# rand(-100) # => 87
|
428
|
-
# rand(-0.5) # => 0.8130921818028143
|
429
|
-
# rand(1.9) # equivalent to rand(1), which is always 0
|
430
|
-
# ```
|
431
|
-
#
|
432
|
-
# [\#srand](Kernel.downloaded.ruby_doc#method-i-srand) may be used to
|
433
|
-
# ensure that sequences of random numbers are reproducible between
|
434
|
-
# different runs of a program.
|
435
|
-
#
|
436
|
-
# See also
|
437
|
-
# [Random\#rand](https://ruby-doc.org/core-2.6.3/Random.html#method-i-rand)
|
438
|
-
# .
|
439
|
-
def rand: () -> Float
|
440
|
-
| (Integer arg0) -> Integer
|
441
|
-
| (::Range[Integer] arg0) -> Integer
|
442
|
-
| (::Range[Float] arg0) -> Float
|
443
|
-
|
444
|
-
def readline: (?String arg0, ?Integer arg1) -> String
|
445
|
-
|
446
|
-
def readlines: (?String arg0, ?Integer arg1) -> ::Array[String]
|
447
|
-
|
448
|
-
def require: (String path) -> bool
|
449
|
-
|
450
|
-
def require_relative: (String feature) -> bool
|
451
|
-
|
452
|
-
def select: (::Array[IO] read, ?::Array[IO] write, ?::Array[IO] error, ?Integer timeout) -> ::Array[String]
|
453
|
-
|
454
|
-
def sleep: () -> bot
|
455
|
-
| (Numeric duration) -> Integer
|
456
|
-
|
457
|
-
def syscall: (Integer num, *untyped args) -> untyped
|
458
|
-
|
459
|
-
def test: (String | Integer cmd, String | IO file1, ?String | IO file2) -> (TrueClass | FalseClass | Time | nil | Integer)
|
460
|
-
|
461
|
-
def throw: (Object tag, ?untyped obj) -> bot
|
462
|
-
|
463
|
-
def warn: (*untyped msg, ?uplevel: Integer | nil) -> NilClass
|
464
|
-
|
465
|
-
# Replaces the current process by running the given external *command* ,
|
466
|
-
# which can take one of the following forms:
|
467
|
-
#
|
468
|
-
# - `exec(commandline)`
|
469
|
-
# command line string which is passed to the standard shell
|
470
|
-
#
|
471
|
-
# - `exec(cmdname, arg1, ...)`
|
472
|
-
# command name and one or more arguments (no shell)
|
473
|
-
#
|
474
|
-
# - `exec([cmdname, argv0], arg1, ...)`
|
475
|
-
# command name, [argv](https://ruby-doc.org/core-2.6.3/0) and zero or
|
476
|
-
# more arguments (no shell)
|
477
|
-
#
|
478
|
-
# In the first form, the string is taken as a command line that is subject
|
479
|
-
# to shell expansion before being executed.
|
480
|
-
#
|
481
|
-
# The standard shell always means `"/bin/sh"` on Unix-like systems, same
|
482
|
-
# as `ENV["RUBYSHELL"]` (or `ENV["COMSPEC"]` on Windows NT series), and
|
483
|
-
# similar.
|
484
|
-
#
|
485
|
-
# If the string from the first form ( `exec("command")` ) follows these
|
486
|
-
# simple rules:
|
487
|
-
#
|
488
|
-
# - no meta characters
|
489
|
-
#
|
490
|
-
# - no shell reserved word and no special built-in
|
491
|
-
#
|
492
|
-
# - Ruby invokes the command directly without shell
|
493
|
-
#
|
494
|
-
# You can force shell invocation by adding “;” to the string (because “;”
|
495
|
-
# is a meta character).
|
496
|
-
#
|
497
|
-
# Note that this behavior is observable by pid obtained (return value of
|
498
|
-
# spawn() and
|
499
|
-
# [IO\#pid](https://ruby-doc.org/core-2.6.3/IO.html#method-i-pid) for
|
500
|
-
# [IO.popen](https://ruby-doc.org/core-2.6.3/IO.html#method-c-popen) ) is
|
501
|
-
# the pid of the invoked command, not shell.
|
502
|
-
#
|
503
|
-
# In the second form ( `exec("command1", "arg1", ...)` ), the first is
|
504
|
-
# taken as a command name and the rest are passed as parameters to command
|
505
|
-
# with no shell expansion.
|
506
|
-
#
|
507
|
-
# In the third form ( `exec(["command", "argv0"], "arg1", ...)` ),
|
508
|
-
# starting a two-element array at the beginning of the command, the first
|
509
|
-
# element is the command to be executed, and the second argument is used
|
510
|
-
# as the `argv[0]` value, which may show up in process listings.
|
511
|
-
#
|
512
|
-
# In order to execute the command, one of the `exec(2)` system calls are
|
513
|
-
# used, so the running command may inherit some of the environment of the
|
514
|
-
# original program (including open file descriptors).
|
515
|
-
#
|
516
|
-
# This behavior is modified by the given `env` and `options` parameters.
|
517
|
-
# See ::spawn for details.
|
518
|
-
#
|
519
|
-
# If the command fails to execute (typically `Errno::ENOENT` when it was
|
520
|
-
# not found) a
|
521
|
-
# [SystemCallError](https://ruby-doc.org/core-2.6.3/SystemCallError.html)
|
522
|
-
# exception is raised.
|
523
|
-
#
|
524
|
-
# This method modifies process attributes according to given `options`
|
525
|
-
# before `exec(2)` system call. See ::spawn for more details about the
|
526
|
-
# given `options` .
|
527
|
-
#
|
528
|
-
# The modified attributes may be retained when `exec(2)` system call
|
529
|
-
# fails.
|
530
|
-
#
|
531
|
-
# For example, hard resource limits are not restorable.
|
532
|
-
#
|
533
|
-
# Consider to create a child process using ::spawn or
|
534
|
-
# [\#system](Kernel.downloaded.ruby_doc#method-i-system) if this is not
|
535
|
-
# acceptable.
|
536
|
-
#
|
537
|
-
# ```ruby
|
538
|
-
# exec "echo *" # echoes list of files in current directory
|
539
|
-
# # never get here
|
540
|
-
#
|
541
|
-
# exec "echo", "*" # echoes an asterisk
|
542
|
-
# # never get here
|
543
|
-
# ```
|
544
|
-
def exec: (*String args) -> bot
|
545
|
-
|
546
|
-
# Executes *command…* in a subshell. *command…* is one of following forms.
|
547
|
-
#
|
548
|
-
# commandline : command line string which is passed to the standard shell
|
549
|
-
# cmdname, arg1, ... : command name and one or more arguments (no shell)
|
550
|
-
# [cmdname, argv0], arg1, ... : command name, argv[0] and zero or more arguments (no shell)
|
551
|
-
#
|
552
|
-
# system returns `true` if the command gives zero exit status, `false` for
|
553
|
-
# non zero exit status. Returns `nil` if command execution fails. An error
|
554
|
-
# status is available in `$?` . The arguments are processed in the same
|
555
|
-
# way as for `Kernel.spawn` .
|
556
|
-
#
|
557
|
-
# The hash arguments, env and options, are same as `exec` and `spawn` .
|
558
|
-
# See `Kernel.spawn` for details.
|
559
|
-
#
|
560
|
-
# ```ruby
|
561
|
-
# system("echo *")
|
562
|
-
# system("echo", "*")
|
563
|
-
# ```
|
564
|
-
#
|
565
|
-
# *produces:*
|
566
|
-
#
|
567
|
-
# config.h main.rb
|
568
|
-
# *
|
569
|
-
#
|
570
|
-
# See `Kernel.exec` for the standard shell.
|
571
|
-
def system: (*String args) -> (NilClass | FalseClass | TrueClass)
|
572
|
-
end
|
573
|
-
|
574
|
-
Kernel::RUBYGEMS_ACTIVATION_MONITOR: untyped
|