rbs 3.6.1 → 3.9.5
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 -2
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +34 -10
- data/.github/workflows/windows.yml +20 -3
- data/.gitignore +1 -0
- data/.rubocop.yml +26 -1
- data/CHANGELOG.md +241 -0
- data/Rakefile +54 -4
- data/config.yml +317 -0
- data/core/array.rbs +1756 -1591
- data/core/basic_object.rbs +38 -35
- data/core/comparable.rbs +1 -1
- data/core/complex.rbs +166 -94
- data/core/data.rbs +2 -2
- data/core/dir.rbs +2 -18
- data/core/encoding.rbs +12 -32
- data/core/enumerable.rbs +270 -266
- data/core/enumerator.rbs +14 -4
- data/core/env.rbs +1 -1
- data/core/errno.rbs +33 -16
- data/core/errors.rbs +6 -2
- data/core/exception.rbs +342 -167
- data/core/fiber.rbs +3 -2
- data/core/file.rbs +26 -75
- data/core/float.rbs +125 -72
- data/core/gc.rbs +158 -42
- data/core/hash.rbs +122 -143
- data/core/integer.rbs +79 -50
- data/core/io/buffer.rbs +49 -43
- data/core/io.rbs +108 -151
- data/core/kernel.rbs +341 -209
- data/core/match_data.rbs +76 -2
- data/core/math.rbs +0 -36
- data/core/method.rbs +2 -2
- data/core/module.rbs +32 -27
- data/core/nil_class.rbs +2 -2
- data/core/numeric.rbs +101 -104
- data/core/object.rbs +1 -5
- data/core/object_space/weak_key_map.rbs +3 -4
- data/core/object_space.rbs +3 -3
- data/core/proc.rbs +82 -14
- data/core/process.rbs +110 -58
- data/core/ractor.rbs +57 -4
- data/core/range.rbs +114 -87
- data/core/rational.rbs +0 -2
- data/core/rbs/unnamed/argf.rbs +237 -36
- data/core/rbs/unnamed/env_class.rbs +35 -53
- data/core/rbs/unnamed/random.rbs +1 -2
- data/core/regexp.rbs +10 -56
- data/core/ruby_vm.rbs +88 -9
- data/core/rubygems/config_file.rbs +3 -0
- data/core/rubygems/errors.rbs +3 -6
- data/core/rubygems/platform.rbs +0 -9
- data/core/rubygems/rubygems.rbs +3 -6
- data/core/rubygems/version.rbs +8 -8
- data/core/set.rbs +4 -16
- data/core/string.rbs +271 -264
- data/core/struct.rbs +6 -18
- data/core/symbol.rbs +14 -21
- data/core/thread.rbs +32 -35
- data/core/time.rbs +131 -50
- data/core/trace_point.rbs +124 -113
- data/core/true_class.rbs +0 -1
- data/core/unbound_method.rbs +1 -1
- data/core/warning.rbs +9 -2
- data/docs/architecture.md +1 -1
- data/docs/syntax.md +17 -10
- data/ext/rbs_extension/extconf.rb +11 -0
- data/ext/rbs_extension/location.c +61 -29
- data/ext/rbs_extension/location.h +4 -3
- data/ext/rbs_extension/main.c +23 -1
- data/ext/rbs_extension/parser.c +506 -517
- data/ext/rbs_extension/parserstate.c +109 -30
- data/ext/rbs_extension/parserstate.h +6 -4
- data/ext/rbs_extension/rbs_extension.h +1 -10
- data/{ext/rbs_extension → include/rbs}/constants.h +21 -19
- data/include/rbs/ruby_objs.h +72 -0
- data/include/rbs/util/rbs_constant_pool.h +219 -0
- data/include/rbs.h +7 -0
- data/lib/rbs/annotate/annotations.rb +3 -3
- data/lib/rbs/annotate/rdoc_source.rb +2 -2
- data/lib/rbs/ast/declarations.rb +9 -4
- data/lib/rbs/ast/directives.rb +10 -0
- data/lib/rbs/ast/members.rb +2 -0
- data/lib/rbs/ast/type_param.rb +2 -12
- data/lib/rbs/cli/diff.rb +3 -3
- data/lib/rbs/cli/validate.rb +2 -1
- data/lib/rbs/cli.rb +16 -16
- data/lib/rbs/collection/config/lockfile_generator.rb +58 -8
- data/lib/rbs/collection/config.rb +5 -3
- data/lib/rbs/collection/sources/rubygems.rb +1 -1
- data/lib/rbs/collection.rb +1 -0
- data/lib/rbs/definition.rb +51 -34
- data/lib/rbs/definition_builder/ancestor_builder.rb +5 -3
- data/lib/rbs/definition_builder.rb +83 -24
- data/lib/rbs/environment.rb +33 -18
- data/lib/rbs/environment_loader.rb +6 -1
- data/lib/rbs/errors.rb +24 -0
- data/lib/rbs/locator.rb +2 -0
- data/lib/rbs/method_type.rb +2 -0
- data/lib/rbs/namespace.rb +1 -0
- data/lib/rbs/parser_aux.rb +40 -3
- data/lib/rbs/prototype/rb.rb +20 -12
- data/lib/rbs/prototype/rbi.rb +11 -6
- data/lib/rbs/prototype/runtime/value_object_generator.rb +7 -5
- data/lib/rbs/prototype/runtime.rb +7 -5
- data/lib/rbs/subtractor.rb +3 -3
- data/lib/rbs/test/hook.rb +47 -42
- data/lib/rbs/test/type_check.rb +7 -5
- data/lib/rbs/type_name.rb +14 -9
- data/lib/rbs/types.rb +63 -14
- data/lib/rbs/unit_test/spy.rb +4 -2
- data/lib/rbs/unit_test/type_assertions.rb +19 -13
- data/lib/rbs/unit_test/with_aliases.rb +3 -1
- data/lib/rbs/validator.rb +7 -1
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +10 -5
- data/lib/rbs.rb +1 -0
- data/lib/rdoc_plugin/parser.rb +2 -2
- data/rbs.gemspec +6 -2
- data/sig/ancestor_graph.rbs +5 -5
- data/sig/annotate/rdoc_source.rbs +2 -0
- data/sig/cli.rbs +2 -0
- data/sig/collection/config/lockfile_generator.rbs +9 -1
- data/sig/declarations.rbs +10 -3
- data/sig/definition.rbs +80 -12
- data/sig/definition_builder.rbs +18 -4
- data/sig/directives.rbs +17 -1
- data/sig/environment.rbs +3 -1
- data/sig/errors.rbs +19 -0
- data/sig/namespace.rbs +2 -3
- data/sig/parser.rbs +5 -1
- data/sig/prototype/rb.rbs +1 -1
- data/sig/resolver/constant_resolver.rbs +2 -2
- data/sig/resolver/context.rbs +1 -1
- data/sig/subtractor.rbs +1 -1
- data/sig/test/type_check.rbs +2 -2
- data/sig/type_alias_dependency.rbs +2 -2
- data/sig/type_alias_regularity.rbs +6 -6
- data/sig/type_param.rbs +4 -4
- data/sig/typename.rbs +8 -5
- data/sig/types.rbs +1 -1
- data/sig/unit_test/spy.rbs +2 -0
- data/sig/unit_test/type_assertions.rbs +2 -0
- data/sig/use_map.rbs +1 -1
- data/sig/validator.rbs +6 -2
- data/sig/vendorer.rbs +1 -1
- data/sig/writer.rbs +1 -1
- data/{ext/rbs_extension → src}/constants.c +35 -36
- data/src/ruby_objs.c +799 -0
- data/src/util/rbs_constant_pool.c +342 -0
- data/stdlib/base64/0/base64.rbs +0 -9
- data/stdlib/benchmark/0/benchmark.rbs +11 -2
- data/stdlib/bigdecimal/0/big_decimal.rbs +26 -182
- data/stdlib/cgi/0/core.rbs +60 -3
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/coverage/0/coverage.rbs +0 -3
- data/stdlib/csv/0/csv.rbs +18 -58
- data/stdlib/csv/0/manifest.yaml +1 -0
- data/stdlib/date/0/date.rbs +27 -42
- data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -6
- data/stdlib/digest/0/digest.rbs +25 -2
- data/stdlib/erb/0/erb.rbs +0 -1
- data/stdlib/etc/0/etc.rbs +51 -34
- data/stdlib/fileutils/0/fileutils.rbs +3 -44
- data/stdlib/io-console/0/io-console.rbs +69 -15
- data/stdlib/ipaddr/0/ipaddr.rbs +16 -4
- data/stdlib/json/0/json.rbs +107 -120
- data/stdlib/logger/0/log_device.rbs +1 -1
- data/stdlib/logger/0/logger.rbs +3 -18
- data/stdlib/minitest/0/kernel.rbs +2 -2
- data/stdlib/minitest/0/minitest/abstract_reporter.rbs +4 -1
- data/stdlib/minitest/0/minitest/assertion.rbs +1 -0
- data/stdlib/minitest/0/minitest/assertions.rbs +58 -13
- data/stdlib/minitest/0/minitest/backtrace_filter.rbs +7 -0
- data/stdlib/minitest/0/minitest/bench_spec.rbs +8 -8
- data/stdlib/minitest/0/minitest/benchmark.rbs +17 -16
- data/stdlib/minitest/0/minitest/compress.rbs +13 -0
- data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
- data/stdlib/minitest/0/minitest/mock.rbs +9 -5
- data/stdlib/minitest/0/minitest/parallel/executor.rbs +4 -0
- data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +0 -1
- data/stdlib/minitest/0/minitest/pride_io.rbs +8 -0
- data/stdlib/minitest/0/minitest/pride_lol.rbs +2 -0
- data/stdlib/minitest/0/minitest/progress_reporter.rbs +1 -1
- data/stdlib/minitest/0/minitest/reportable.rbs +2 -0
- data/stdlib/minitest/0/minitest/runnable.rbs +33 -1
- data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +1 -1
- data/stdlib/minitest/0/minitest/spec/dsl.rbs +10 -6
- data/stdlib/minitest/0/minitest/spec.rbs +1 -1
- data/stdlib/minitest/0/minitest/statistics_reporter.rbs +5 -0
- data/stdlib/minitest/0/minitest/summary_reporter.rbs +0 -7
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +1 -1
- data/stdlib/minitest/0/minitest/test.rbs +7 -14
- data/stdlib/minitest/0/minitest/unexpected_error.rbs +2 -0
- data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
- data/stdlib/minitest/0/minitest/unit.rbs +1 -2
- data/stdlib/minitest/0/minitest.rbs +41 -892
- data/stdlib/monitor/0/monitor.rbs +13 -4
- data/stdlib/net-http/0/net-http.rbs +42 -109
- data/stdlib/nkf/0/nkf.rbs +30 -0
- data/stdlib/objspace/0/objspace.rbs +1 -2
- data/stdlib/observable/0/observable.rbs +1 -1
- data/stdlib/open-uri/0/manifest.yaml +1 -0
- data/stdlib/open-uri/0/open-uri.rbs +52 -0
- data/stdlib/open3/0/open3.rbs +0 -8
- data/stdlib/openssl/0/manifest.yaml +1 -0
- data/stdlib/openssl/0/openssl.rbs +235 -143
- data/stdlib/optparse/0/optparse.rbs +58 -18
- data/stdlib/pathname/0/pathname.rbs +2 -8
- data/stdlib/pp/0/pp.rbs +3 -1
- data/stdlib/prettyprint/0/prettyprint.rbs +0 -4
- data/stdlib/pstore/0/pstore.rbs +0 -6
- data/stdlib/psych/0/core_ext.rbs +12 -0
- data/stdlib/psych/0/psych.rbs +15 -4
- data/stdlib/pty/0/pty.rbs +46 -4
- data/stdlib/rdoc/0/code_object.rbs +0 -4
- data/stdlib/rdoc/0/markup.rbs +10 -12
- data/stdlib/rdoc/0/rdoc.rbs +13 -8
- data/stdlib/resolv/0/resolv.rbs +21 -12
- data/stdlib/ripper/0/ripper.rbs +0 -2
- data/stdlib/securerandom/0/securerandom.rbs +7 -2
- data/stdlib/shellwords/0/shellwords.rbs +11 -12
- data/stdlib/singleton/0/singleton.rbs +0 -1
- data/stdlib/socket/0/addrinfo.rbs +1 -2
- data/stdlib/socket/0/basic_socket.rbs +0 -5
- data/stdlib/socket/0/socket.rbs +32 -27
- data/stdlib/socket/0/tcp_server.rbs +0 -3
- data/stdlib/socket/0/tcp_socket.rbs +36 -3
- data/stdlib/socket/0/udp_socket.rbs +0 -1
- data/stdlib/socket/0/unix_server.rbs +0 -3
- data/stdlib/socket/0/unix_socket.rbs +4 -2
- data/{core/string_io.rbs → stdlib/stringio/0/stringio.rbs} +1 -1
- data/stdlib/strscan/0/string_scanner.rbs +1265 -422
- data/stdlib/tempfile/0/tempfile.rbs +135 -28
- data/stdlib/time/0/time.rbs +48 -35
- data/stdlib/timeout/0/timeout.rbs +11 -8
- data/stdlib/tmpdir/0/tmpdir.rbs +10 -3
- data/stdlib/tsort/0/tsort.rbs +0 -4
- data/stdlib/uri/0/common.rbs +28 -30
- data/stdlib/uri/0/ftp.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +22 -18
- data/stdlib/uri/0/http.rbs +2 -2
- data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
- data/stdlib/zlib/0/buf_error.rbs +1 -70
- data/stdlib/zlib/0/data_error.rbs +1 -70
- data/stdlib/zlib/0/deflate.rbs +8 -72
- data/stdlib/zlib/0/error.rbs +1 -70
- data/stdlib/zlib/0/gzip_file/crc_error.rbs +2 -105
- data/stdlib/zlib/0/gzip_file/error.rbs +2 -105
- data/stdlib/zlib/0/gzip_file/length_error.rbs +2 -105
- data/stdlib/zlib/0/gzip_file/no_footer.rbs +2 -105
- data/stdlib/zlib/0/gzip_file.rbs +1 -71
- data/stdlib/zlib/0/gzip_reader.rbs +3 -74
- data/stdlib/zlib/0/gzip_writer.rbs +1 -70
- data/stdlib/zlib/0/inflate.rbs +4 -71
- data/stdlib/zlib/0/mem_error.rbs +1 -70
- data/stdlib/zlib/0/need_dict.rbs +1 -70
- data/stdlib/zlib/0/stream_end.rbs +1 -70
- data/stdlib/zlib/0/stream_error.rbs +1 -70
- data/stdlib/zlib/0/version_error.rbs +1 -70
- data/stdlib/zlib/0/zlib.rbs +0 -2
- data/stdlib/zlib/0/zstream.rbs +4 -72
- metadata +17 -13
- data/ext/rbs_extension/ruby_objs.c +0 -602
- data/ext/rbs_extension/ruby_objs.h +0 -51
- data/stdlib/minitest/0/manifest.yaml +0 -2
data/core/kernel.rbs
CHANGED
@@ -25,7 +25,6 @@
|
|
25
25
|
# * [Random Values](rdoc-ref:Kernel@Random+Values)
|
26
26
|
# * [Other](rdoc-ref:Kernel@Other)
|
27
27
|
#
|
28
|
-
#
|
29
28
|
# ### Converting
|
30
29
|
#
|
31
30
|
# * #Array: Returns an Array based on the given argument.
|
@@ -36,7 +35,6 @@
|
|
36
35
|
# * #Rational: Returns a Rational based on the given arguments.
|
37
36
|
# * #String: Returns a String based on the given argument.
|
38
37
|
#
|
39
|
-
#
|
40
38
|
# ### Querying
|
41
39
|
#
|
42
40
|
# * #__callee__: Returns the called name of the current method as a symbol.
|
@@ -56,7 +54,6 @@
|
|
56
54
|
# * #local_variables: Returns an array of local variables as symbols.
|
57
55
|
# * #test: Performs specified tests on the given single file or pair of files.
|
58
56
|
#
|
59
|
-
#
|
60
57
|
# ### Exiting
|
61
58
|
#
|
62
59
|
# * #abort: Exits the current process after printing the given arguments.
|
@@ -66,7 +63,6 @@
|
|
66
63
|
# * #exit!: Exits the current process without calling any registered `at_exit`
|
67
64
|
# handlers.
|
68
65
|
#
|
69
|
-
#
|
70
66
|
# ### Exceptions
|
71
67
|
#
|
72
68
|
# * #catch: Executes the given block, possibly catching a thrown object.
|
@@ -74,7 +70,6 @@
|
|
74
70
|
# arguments.
|
75
71
|
# * #throw: Returns from the active catch block waiting for the given tag.
|
76
72
|
#
|
77
|
-
#
|
78
73
|
# ### IO
|
79
74
|
#
|
80
75
|
# * ::pp: Prints the given objects in pretty form.
|
@@ -92,13 +87,11 @@
|
|
92
87
|
# input.
|
93
88
|
# * #select: Same as IO.select.
|
94
89
|
#
|
95
|
-
#
|
96
90
|
# ### Procs
|
97
91
|
#
|
98
92
|
# * #lambda: Returns a lambda proc for the given block.
|
99
93
|
# * #proc: Returns a new Proc; equivalent to Proc.new.
|
100
94
|
#
|
101
|
-
#
|
102
95
|
# ### Tracing
|
103
96
|
#
|
104
97
|
# * #set_trace_func: Sets the given proc as the handler for tracing, or
|
@@ -107,7 +100,6 @@
|
|
107
100
|
# * #untrace_var: Disables tracing of assignments to the given global
|
108
101
|
# variable.
|
109
102
|
#
|
110
|
-
#
|
111
103
|
# ### Subprocesses
|
112
104
|
#
|
113
105
|
# * [\`command`](rdoc-ref:Kernel#`): Returns the standard output of running
|
@@ -118,7 +110,6 @@
|
|
118
110
|
# completion.
|
119
111
|
# * #system: Executes the given command in a subshell.
|
120
112
|
#
|
121
|
-
#
|
122
113
|
# ### Loading
|
123
114
|
#
|
124
115
|
# * #autoload: Registers the given file to be loaded when the given constant
|
@@ -128,21 +119,18 @@
|
|
128
119
|
# * #require_relative: Loads the Ruby file path relative to the calling file,
|
129
120
|
# unless it has already been loaded.
|
130
121
|
#
|
131
|
-
#
|
132
122
|
# ### Yielding
|
133
123
|
#
|
134
124
|
# * #tap: Yields `self` to the given block; returns `self`.
|
135
125
|
# * #then (aliased as #yield_self): Yields `self` to the block and returns the
|
136
126
|
# result of the block.
|
137
127
|
#
|
138
|
-
#
|
139
128
|
# ### Random Values
|
140
129
|
#
|
141
130
|
# * #rand: Returns a pseudo-random floating point number strictly between 0.0
|
142
131
|
# and 1.0.
|
143
132
|
# * #srand: Seeds the pseudo-random number generator with the given number.
|
144
133
|
#
|
145
|
-
#
|
146
134
|
# ### Other
|
147
135
|
#
|
148
136
|
# * #eval: Evaluates the given string as Ruby code.
|
@@ -387,7 +375,6 @@ module Kernel : BasicObject
|
|
387
375
|
# * Once in the parent process, returning the pid of the child process.
|
388
376
|
# * Once in the child process, returning `nil`.
|
389
377
|
#
|
390
|
-
#
|
391
378
|
# Example:
|
392
379
|
#
|
393
380
|
# puts "This is the first line before the fork (pid #{Process.pid})"
|
@@ -410,7 +397,6 @@ module Kernel : BasicObject
|
|
410
397
|
# * Process.wait, to collect the termination statuses of its children.
|
411
398
|
# * Process.detach, to register disinterest in their status.
|
412
399
|
#
|
413
|
-
#
|
414
400
|
# The thread calling `fork` is the only thread in the created child process;
|
415
401
|
# `fork` doesn't copy other threads.
|
416
402
|
#
|
@@ -482,7 +468,6 @@ module Kernel : BasicObject
|
|
482
468
|
# Complex('+1i') # => (0+1i)
|
483
469
|
# Complex('-1i') # => (0-1i)
|
484
470
|
#
|
485
|
-
#
|
486
471
|
# * At-sign separated real and imaginary rational substrings, each of which
|
487
472
|
# specifies a Rational value, specifying [polar
|
488
473
|
# coordinates](rdoc-ref:Complex@Polar+Coordinates):
|
@@ -504,9 +489,9 @@ module Kernel : BasicObject
|
|
504
489
|
# - Float(arg, exception: true) -> float or nil
|
505
490
|
# -->
|
506
491
|
# Returns *arg* converted to a float. Numeric types are converted directly, and
|
507
|
-
# with exception to String and `nil
|
508
|
-
# Converting a String with invalid characters will result in
|
509
|
-
# Converting `nil` generates a TypeError.
|
492
|
+
# with exception to String and `nil`, the rest are converted using *arg*`.to_f`.
|
493
|
+
# Converting a String with invalid characters will result in an ArgumentError.
|
494
|
+
# Converting `nil` generates a TypeError. Exceptions can be suppressed by
|
510
495
|
# passing `exception: false`.
|
511
496
|
#
|
512
497
|
# Float(1) #=> 1.0
|
@@ -530,11 +515,9 @@ module Kernel : BasicObject
|
|
530
515
|
# * A hash, returns `object`.
|
531
516
|
# * An empty array or `nil`, returns an empty hash.
|
532
517
|
#
|
533
|
-
#
|
534
518
|
# * Otherwise, if `object.to_hash` returns a hash, returns that hash.
|
535
519
|
# * Otherwise, returns TypeError.
|
536
520
|
#
|
537
|
-
#
|
538
521
|
# Examples:
|
539
522
|
#
|
540
523
|
# Hash({foo: 0, bar: 1}) # => {:foo=>0, :bar=>1}
|
@@ -555,22 +538,22 @@ module Kernel : BasicObject
|
|
555
538
|
#
|
556
539
|
# With a non-zero `base`, `object` must be a string or convertible to a string.
|
557
540
|
#
|
558
|
-
# ####
|
541
|
+
# #### Numeric objects
|
559
542
|
#
|
560
|
-
# With integer argument `object` given, returns `object`:
|
543
|
+
# With an integer argument `object` given, returns `object`:
|
561
544
|
#
|
562
545
|
# Integer(1) # => 1
|
563
546
|
# Integer(-1) # => -1
|
564
547
|
#
|
565
|
-
# With floating-point argument `object` given, returns `object` truncated to
|
566
|
-
# integer:
|
548
|
+
# With a floating-point argument `object` given, returns `object` truncated to
|
549
|
+
# an integer:
|
567
550
|
#
|
568
551
|
# Integer(1.9) # => 1 # Rounds toward zero.
|
569
552
|
# Integer(-1.9) # => -1 # Rounds toward zero.
|
570
553
|
#
|
571
|
-
# ####
|
554
|
+
# #### String objects
|
572
555
|
#
|
573
|
-
# With string argument `object` and zero `base` given, returns `object`
|
556
|
+
# With a string argument `object` and zero `base` given, returns `object`
|
574
557
|
# converted to an integer in base 10:
|
575
558
|
#
|
576
559
|
# Integer('100') # => 100
|
@@ -580,7 +563,7 @@ module Kernel : BasicObject
|
|
580
563
|
# the actual base (radix indicator):
|
581
564
|
#
|
582
565
|
# Integer('0100') # => 64 # Leading '0' specifies base 8.
|
583
|
-
# Integer('0b100') # => 4 # Leading '0b'
|
566
|
+
# Integer('0b100') # => 4 # Leading '0b' specifies base 2.
|
584
567
|
# Integer('0x100') # => 256 # Leading '0x' specifies base 16.
|
585
568
|
#
|
586
569
|
# With a positive `base` (in range 2..36) given, returns `object` converted to
|
@@ -591,7 +574,7 @@ module Kernel : BasicObject
|
|
591
574
|
# Integer('-100', 16) # => -256
|
592
575
|
#
|
593
576
|
# With a negative `base` (in range -36..-2) given, returns `object` converted to
|
594
|
-
#
|
577
|
+
# the radix indicator if it exists or `base`:
|
595
578
|
#
|
596
579
|
# Integer('0x100', -2) # => 256
|
597
580
|
# Integer('100', -2) # => 4
|
@@ -600,7 +583,7 @@ module Kernel : BasicObject
|
|
600
583
|
# Integer('0o100', -10) # => 64
|
601
584
|
# Integer('100', -10) # => 100
|
602
585
|
#
|
603
|
-
# `base` -1 is
|
586
|
+
# `base` -1 is equivalent to the -10 case.
|
604
587
|
#
|
605
588
|
# When converting strings, surrounding whitespace and embedded underscores are
|
606
589
|
# allowed and ignored:
|
@@ -608,7 +591,7 @@ module Kernel : BasicObject
|
|
608
591
|
# Integer(' 100 ') # => 100
|
609
592
|
# Integer('-1_0_0', 16) # => -256
|
610
593
|
#
|
611
|
-
# ####
|
594
|
+
# #### Other classes
|
612
595
|
#
|
613
596
|
# Examples with `object` of various other classes:
|
614
597
|
#
|
@@ -616,14 +599,13 @@ module Kernel : BasicObject
|
|
616
599
|
# Integer(Complex(2, 0)) # => 2 # Imaginary part must be zero.
|
617
600
|
# Integer(Time.now) # => 1650974042
|
618
601
|
#
|
619
|
-
# ####
|
602
|
+
# #### Keywords
|
620
603
|
#
|
621
|
-
# With optional keyword argument `exception` given as `true` (the default):
|
604
|
+
# With the optional keyword argument `exception` given as `true` (the default):
|
622
605
|
#
|
623
606
|
# * Raises TypeError if `object` does not respond to `to_int` or `to_i`.
|
624
607
|
# * Raises TypeError if `object` is `nil`.
|
625
|
-
# *
|
626
|
-
#
|
608
|
+
# * Raises ArgumentError if `object` is an invalid string.
|
627
609
|
#
|
628
610
|
# With `exception` given as `false`, an exception of any kind is suppressed and
|
629
611
|
# `nil` is returned.
|
@@ -693,7 +675,7 @@ module Kernel : BasicObject
|
|
693
675
|
#
|
694
676
|
# String([0, 1, 2]) # => "[0, 1, 2]"
|
695
677
|
# String(0..5) # => "0..5"
|
696
|
-
# String({foo: 0, bar: 1}) # => "{:
|
678
|
+
# String({foo: 0, bar: 1}) # => "{foo: 0, bar: 1}"
|
697
679
|
#
|
698
680
|
# Raises `TypeError` if `object` cannot be converted to a string.
|
699
681
|
#
|
@@ -787,11 +769,10 @@ module Kernel : BasicObject
|
|
787
769
|
# rdoc-file=load.c
|
788
770
|
# - autoload(const, filename) -> nil
|
789
771
|
# -->
|
790
|
-
# Registers
|
791
|
-
#
|
792
|
-
# a symbol) is accessed.
|
772
|
+
# Registers *filename* to be loaded (using Kernel::require) the first time that
|
773
|
+
# *const* (which may be a String or a symbol) is accessed.
|
793
774
|
#
|
794
|
-
#
|
775
|
+
# autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")
|
795
776
|
#
|
796
777
|
# If *const* is defined as autoload, the file name to be loaded is replaced with
|
797
778
|
# *filename*. If *const* is defined but not as autoload, does nothing.
|
@@ -802,11 +783,24 @@ module Kernel : BasicObject
|
|
802
783
|
# rdoc-file=load.c
|
803
784
|
# - autoload?(name, inherit=true) -> String or nil
|
804
785
|
# -->
|
805
|
-
# Returns *filename* to be loaded if *name* is registered as `autoload
|
786
|
+
# Returns *filename* to be loaded if *name* is registered as `autoload` in the
|
787
|
+
# current namespace or one of its ancestors.
|
806
788
|
#
|
807
789
|
# autoload(:B, "b")
|
808
790
|
# autoload?(:B) #=> "b"
|
809
791
|
#
|
792
|
+
# module C
|
793
|
+
# autoload(:D, "d")
|
794
|
+
# autoload?(:D) #=> "d"
|
795
|
+
# autoload?(:B) #=> nil
|
796
|
+
# end
|
797
|
+
#
|
798
|
+
# class E
|
799
|
+
# autoload(:F, "f")
|
800
|
+
# autoload?(:F) #=> "f"
|
801
|
+
# autoload?(:B) #=> "b"
|
802
|
+
# end
|
803
|
+
#
|
810
804
|
def self?.autoload?: (interned name) -> String?
|
811
805
|
|
812
806
|
# <!--
|
@@ -912,53 +906,207 @@ module Kernel : BasicObject
|
|
912
906
|
def self?.exit!: (?int | bool status) -> bot
|
913
907
|
|
914
908
|
# <!-- rdoc-file=eval.c -->
|
915
|
-
#
|
916
|
-
#
|
917
|
-
#
|
918
|
-
#
|
919
|
-
#
|
920
|
-
#
|
921
|
-
#
|
922
|
-
#
|
923
|
-
#
|
924
|
-
#
|
925
|
-
#
|
926
|
-
#
|
927
|
-
#
|
928
|
-
#
|
929
|
-
#
|
930
|
-
#
|
909
|
+
# Raises an exception; see [Exceptions](rdoc-ref:exceptions.md).
|
910
|
+
#
|
911
|
+
# Argument `exception` sets the class of the new exception; it should be class
|
912
|
+
# Exception or one of its subclasses (most commonly, RuntimeError or
|
913
|
+
# StandardError), or an instance of one of those classes:
|
914
|
+
#
|
915
|
+
# begin
|
916
|
+
# raise(StandardError)
|
917
|
+
# rescue => x
|
918
|
+
# p x.class
|
919
|
+
# end
|
920
|
+
# # => StandardError
|
921
|
+
#
|
922
|
+
# Argument `message` sets the stored message in the new exception, which may be
|
923
|
+
# retrieved by method Exception#message; the message must be a
|
924
|
+
# [string-convertible
|
925
|
+
# object](rdoc-ref:implicit_conversion.rdoc@String-Convertible+Objects) or
|
926
|
+
# `nil`:
|
927
|
+
#
|
928
|
+
# begin
|
929
|
+
# raise(StandardError, 'Boom')
|
930
|
+
# rescue => x
|
931
|
+
# p x.message
|
932
|
+
# end
|
933
|
+
# # => "Boom"
|
934
|
+
#
|
935
|
+
# If argument `message` is not given, the message is the exception class name.
|
936
|
+
#
|
937
|
+
# See [Messages](rdoc-ref:exceptions.md@Messages).
|
938
|
+
#
|
939
|
+
# Argument `backtrace` might be used to modify the backtrace of the new
|
940
|
+
# exception, as reported by Exception#backtrace and
|
941
|
+
# Exception#backtrace_locations; the backtrace must be an array of
|
942
|
+
# Thread::Backtrace::Location, an array of strings, a single string, or `nil`.
|
943
|
+
#
|
944
|
+
# Using the array of Thread::Backtrace::Location instances is the most
|
945
|
+
# consistent option and should be preferred when possible. The necessary value
|
946
|
+
# might be obtained from #caller_locations, or copied from
|
947
|
+
# Exception#backtrace_locations of another error:
|
948
|
+
#
|
949
|
+
# begin
|
950
|
+
# do_some_work()
|
951
|
+
# rescue ZeroDivisionError => ex
|
952
|
+
# raise(LogicalError, "You have an error in your math", ex.backtrace_locations)
|
953
|
+
# end
|
954
|
+
#
|
955
|
+
# The ways, both Exception#backtrace and Exception#backtrace_locations of the
|
956
|
+
# raised error are set to the same backtrace.
|
957
|
+
#
|
958
|
+
# When the desired stack of locations is not available and should be constructed
|
959
|
+
# from scratch, an array of strings or a singular string can be used. In this
|
960
|
+
# case, only Exception#backtrace is set:
|
961
|
+
#
|
962
|
+
# begin
|
963
|
+
# raise(StandardError, 'Boom', %w[dsl.rb:3 framework.rb:1])
|
964
|
+
# rescue => ex
|
965
|
+
# p ex.backtrace
|
966
|
+
# # => ["dsl.rb:3", "framework.rb:1"]
|
967
|
+
# p ex.backtrace_locations
|
968
|
+
# # => nil
|
969
|
+
# end
|
970
|
+
#
|
971
|
+
# If argument `backtrace` is not given, the backtrace is set according to an
|
972
|
+
# array of Thread::Backtrace::Location objects, as derived from the call stack.
|
973
|
+
#
|
974
|
+
# See [Backtraces](rdoc-ref:exceptions.md@Backtraces).
|
975
|
+
#
|
976
|
+
# Keyword argument `cause` sets the stored cause in the new exception, which may
|
977
|
+
# be retrieved by method Exception#cause; the cause must be an exception object
|
978
|
+
# (Exception or one of its subclasses), or `nil`:
|
979
|
+
#
|
980
|
+
# begin
|
981
|
+
# raise(StandardError, cause: RuntimeError.new)
|
982
|
+
# rescue => x
|
983
|
+
# p x.cause
|
984
|
+
# end
|
985
|
+
# # => #<RuntimeError: RuntimeError>
|
986
|
+
#
|
987
|
+
# If keyword argument `cause` is not given, the cause is the value of `$!`.
|
988
|
+
#
|
989
|
+
# See [Cause](rdoc-ref:exceptions.md@Cause).
|
990
|
+
#
|
991
|
+
# In the alternate calling sequence, where argument `exception` *not* given,
|
992
|
+
# raises a new exception of the class given by `$!`, or of class RuntimeError if
|
993
|
+
# `$!` is `nil`:
|
994
|
+
#
|
995
|
+
# begin
|
996
|
+
# raise
|
997
|
+
# rescue => x
|
998
|
+
# p x
|
999
|
+
# end
|
1000
|
+
# # => RuntimeError
|
1001
|
+
#
|
1002
|
+
# With argument `exception` not given, argument `message` and keyword argument
|
1003
|
+
# `cause` may be given, but argument `backtrace` may not be given.
|
931
1004
|
#
|
932
1005
|
def self?.fail: () -> bot
|
933
1006
|
| (string message, ?cause: Exception?) -> bot
|
934
|
-
| (_Exception exception, ?_ToS? message, ?String | Array[String] | nil backtrace, ?cause: Exception?) -> bot
|
1007
|
+
| (_Exception exception, ?_ToS? message, ?String | Array[String] | Array[Thread::Backtrace::Location] | nil backtrace, ?cause: Exception?) -> bot
|
935
1008
|
| (_Exception exception, ?cause: Exception?, **untyped) -> bot
|
936
1009
|
|
937
1010
|
# <!--
|
938
1011
|
# rdoc-file=eval.c
|
939
|
-
# - raise
|
940
|
-
# - raise(
|
941
|
-
#
|
942
|
-
#
|
943
|
-
#
|
944
|
-
#
|
945
|
-
#
|
946
|
-
#
|
947
|
-
#
|
948
|
-
#
|
949
|
-
#
|
950
|
-
#
|
951
|
-
#
|
952
|
-
#
|
953
|
-
#
|
954
|
-
#
|
955
|
-
#
|
956
|
-
#
|
957
|
-
#
|
958
|
-
#
|
959
|
-
#
|
960
|
-
#
|
961
|
-
#
|
1012
|
+
# - raise(exception, message = exception.to_s, backtrace = nil, cause: $!)
|
1013
|
+
# - raise(message = nil, cause: $!)
|
1014
|
+
# -->
|
1015
|
+
# Raises an exception; see [Exceptions](rdoc-ref:exceptions.md).
|
1016
|
+
#
|
1017
|
+
# Argument `exception` sets the class of the new exception; it should be class
|
1018
|
+
# Exception or one of its subclasses (most commonly, RuntimeError or
|
1019
|
+
# StandardError), or an instance of one of those classes:
|
1020
|
+
#
|
1021
|
+
# begin
|
1022
|
+
# raise(StandardError)
|
1023
|
+
# rescue => x
|
1024
|
+
# p x.class
|
1025
|
+
# end
|
1026
|
+
# # => StandardError
|
1027
|
+
#
|
1028
|
+
# Argument `message` sets the stored message in the new exception, which may be
|
1029
|
+
# retrieved by method Exception#message; the message must be a
|
1030
|
+
# [string-convertible
|
1031
|
+
# object](rdoc-ref:implicit_conversion.rdoc@String-Convertible+Objects) or
|
1032
|
+
# `nil`:
|
1033
|
+
#
|
1034
|
+
# begin
|
1035
|
+
# raise(StandardError, 'Boom')
|
1036
|
+
# rescue => x
|
1037
|
+
# p x.message
|
1038
|
+
# end
|
1039
|
+
# # => "Boom"
|
1040
|
+
#
|
1041
|
+
# If argument `message` is not given, the message is the exception class name.
|
1042
|
+
#
|
1043
|
+
# See [Messages](rdoc-ref:exceptions.md@Messages).
|
1044
|
+
#
|
1045
|
+
# Argument `backtrace` might be used to modify the backtrace of the new
|
1046
|
+
# exception, as reported by Exception#backtrace and
|
1047
|
+
# Exception#backtrace_locations; the backtrace must be an array of
|
1048
|
+
# Thread::Backtrace::Location, an array of strings, a single string, or `nil`.
|
1049
|
+
#
|
1050
|
+
# Using the array of Thread::Backtrace::Location instances is the most
|
1051
|
+
# consistent option and should be preferred when possible. The necessary value
|
1052
|
+
# might be obtained from #caller_locations, or copied from
|
1053
|
+
# Exception#backtrace_locations of another error:
|
1054
|
+
#
|
1055
|
+
# begin
|
1056
|
+
# do_some_work()
|
1057
|
+
# rescue ZeroDivisionError => ex
|
1058
|
+
# raise(LogicalError, "You have an error in your math", ex.backtrace_locations)
|
1059
|
+
# end
|
1060
|
+
#
|
1061
|
+
# The ways, both Exception#backtrace and Exception#backtrace_locations of the
|
1062
|
+
# raised error are set to the same backtrace.
|
1063
|
+
#
|
1064
|
+
# When the desired stack of locations is not available and should be constructed
|
1065
|
+
# from scratch, an array of strings or a singular string can be used. In this
|
1066
|
+
# case, only Exception#backtrace is set:
|
1067
|
+
#
|
1068
|
+
# begin
|
1069
|
+
# raise(StandardError, 'Boom', %w[dsl.rb:3 framework.rb:1])
|
1070
|
+
# rescue => ex
|
1071
|
+
# p ex.backtrace
|
1072
|
+
# # => ["dsl.rb:3", "framework.rb:1"]
|
1073
|
+
# p ex.backtrace_locations
|
1074
|
+
# # => nil
|
1075
|
+
# end
|
1076
|
+
#
|
1077
|
+
# If argument `backtrace` is not given, the backtrace is set according to an
|
1078
|
+
# array of Thread::Backtrace::Location objects, as derived from the call stack.
|
1079
|
+
#
|
1080
|
+
# See [Backtraces](rdoc-ref:exceptions.md@Backtraces).
|
1081
|
+
#
|
1082
|
+
# Keyword argument `cause` sets the stored cause in the new exception, which may
|
1083
|
+
# be retrieved by method Exception#cause; the cause must be an exception object
|
1084
|
+
# (Exception or one of its subclasses), or `nil`:
|
1085
|
+
#
|
1086
|
+
# begin
|
1087
|
+
# raise(StandardError, cause: RuntimeError.new)
|
1088
|
+
# rescue => x
|
1089
|
+
# p x.cause
|
1090
|
+
# end
|
1091
|
+
# # => #<RuntimeError: RuntimeError>
|
1092
|
+
#
|
1093
|
+
# If keyword argument `cause` is not given, the cause is the value of `$!`.
|
1094
|
+
#
|
1095
|
+
# See [Cause](rdoc-ref:exceptions.md@Cause).
|
1096
|
+
#
|
1097
|
+
# In the alternate calling sequence, where argument `exception` *not* given,
|
1098
|
+
# raises a new exception of the class given by `$!`, or of class RuntimeError if
|
1099
|
+
# `$!` is `nil`:
|
1100
|
+
#
|
1101
|
+
# begin
|
1102
|
+
# raise
|
1103
|
+
# rescue => x
|
1104
|
+
# p x
|
1105
|
+
# end
|
1106
|
+
# # => RuntimeError
|
1107
|
+
#
|
1108
|
+
# With argument `exception` not given, argument `message` and keyword argument
|
1109
|
+
# `cause` may be given, but argument `backtrace` may not be given.
|
962
1110
|
#
|
963
1111
|
alias raise fail
|
964
1112
|
|
@@ -1015,7 +1163,7 @@ module Kernel : BasicObject
|
|
1015
1163
|
# The style of programming using `$_` as an implicit parameter is gradually
|
1016
1164
|
# losing favor in the Ruby community.
|
1017
1165
|
#
|
1018
|
-
def self?.gets: (?String
|
1166
|
+
def self?.gets: (?String sep, ?Integer limit, ?chomp: boolish) -> String?
|
1019
1167
|
|
1020
1168
|
# <!--
|
1021
1169
|
# rdoc-file=eval.c
|
@@ -1051,10 +1199,10 @@ module Kernel : BasicObject
|
|
1051
1199
|
# will be raised.
|
1052
1200
|
#
|
1053
1201
|
# If the optional *wrap* parameter is `true`, the loaded script will be executed
|
1054
|
-
# under an anonymous module
|
1055
|
-
#
|
1056
|
-
#
|
1057
|
-
#
|
1202
|
+
# under an anonymous module. If the optional *wrap* parameter is a module, the
|
1203
|
+
# loaded script will be executed under the given module. In no circumstance will
|
1204
|
+
# any local variables in the loaded file be propagated to the loading
|
1205
|
+
# environment.
|
1058
1206
|
#
|
1059
1207
|
def self?.load: (String filename, ?Module | bool) -> bool
|
1060
1208
|
|
@@ -1074,8 +1222,8 @@ module Kernel : BasicObject
|
|
1074
1222
|
# # ...
|
1075
1223
|
# end
|
1076
1224
|
#
|
1077
|
-
# StopIteration raised in the block breaks the loop.
|
1078
|
-
# the "result" value stored in the exception.
|
1225
|
+
# A StopIteration raised in the block breaks the loop. In this case, loop
|
1226
|
+
# returns the "result" value stored in the exception.
|
1079
1227
|
#
|
1080
1228
|
# enum = Enumerator.new { |y|
|
1081
1229
|
# y << "one"
|
@@ -1135,7 +1283,6 @@ module Kernel : BasicObject
|
|
1135
1283
|
# * If not the last object, writes the output field separator
|
1136
1284
|
# `$OUTPUT_FIELD_SEPARATOR` (`$,` if it is not `nil`.
|
1137
1285
|
#
|
1138
|
-
#
|
1139
1286
|
# With default separators:
|
1140
1287
|
#
|
1141
1288
|
# objects = [0, 0.0, Rational(0, 1), Complex(0, 0), :zero, 'zero']
|
@@ -1209,7 +1356,7 @@ module Kernel : BasicObject
|
|
1209
1356
|
# -->
|
1210
1357
|
# Equivalent to Proc.new.
|
1211
1358
|
#
|
1212
|
-
def self?.proc: () { () -> untyped } -> Proc
|
1359
|
+
def self?.proc: () { (?) -> untyped } -> Proc
|
1213
1360
|
|
1214
1361
|
# <!--
|
1215
1362
|
# rdoc-file=proc.c
|
@@ -1282,7 +1429,7 @@ module Kernel : BasicObject
|
|
1282
1429
|
# -->
|
1283
1430
|
# prints arguments in pretty form.
|
1284
1431
|
#
|
1285
|
-
# pp returns argument(s).
|
1432
|
+
# `#pp` returns argument(s).
|
1286
1433
|
#
|
1287
1434
|
def self?.pp: [T] (T arg0) -> T
|
1288
1435
|
| (untyped, untyped, *untyped) -> Array[untyped]
|
@@ -1339,7 +1486,7 @@ module Kernel : BasicObject
|
|
1339
1486
|
# Optional keyword argument `chomp` specifies whether line separators are to be
|
1340
1487
|
# omitted.
|
1341
1488
|
#
|
1342
|
-
def self?.readline: (?String arg0, ?Integer arg1) -> String
|
1489
|
+
def self?.readline: (?String arg0, ?Integer arg1, ?chomp: boolish) -> String
|
1343
1490
|
|
1344
1491
|
# <!--
|
1345
1492
|
# rdoc-file=io.c
|
@@ -1382,8 +1529,8 @@ module Kernel : BasicObject
|
|
1382
1529
|
# $cat t.txt | ruby -e "p readlines 12"
|
1383
1530
|
# ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"]
|
1384
1531
|
#
|
1385
|
-
# With arguments `sep` and `limit` given, combines the two behaviors
|
1386
|
-
# Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit).
|
1532
|
+
# With arguments `sep` and `limit` given, combines the two behaviors (see [Line
|
1533
|
+
# Separator and Line Limit](rdoc-ref:IO@Line+Separator+and+Line+Limit)).
|
1387
1534
|
#
|
1388
1535
|
# Optional keyword argument `chomp` specifies whether line separators are to be
|
1389
1536
|
# omitted:
|
@@ -1394,7 +1541,7 @@ module Kernel : BasicObject
|
|
1394
1541
|
# Optional keyword arguments `enc_opts` specify encoding options; see [Encoding
|
1395
1542
|
# options](rdoc-ref:encodings.rdoc@Encoding+Options).
|
1396
1543
|
#
|
1397
|
-
def self?.readlines: (?
|
1544
|
+
def self?.readlines: (?string sep, ?int limit, ?chomp: boolish) -> ::Array[String]
|
1398
1545
|
|
1399
1546
|
# <!--
|
1400
1547
|
# rdoc-file=lib/rubygems/core_ext/kernel_require.rb
|
@@ -1408,7 +1555,6 @@ module Kernel : BasicObject
|
|
1408
1555
|
# * Otherwise, installed gems are searched for a file that matches. If it's
|
1409
1556
|
# found in gem 'y', that gem is activated (added to the loadpath).
|
1410
1557
|
#
|
1411
|
-
#
|
1412
1558
|
# The normal `require` functionality of returning false if that file has already
|
1413
1559
|
# been loaded is preserved.
|
1414
1560
|
#
|
@@ -1438,7 +1584,8 @@ module Kernel : BasicObject
|
|
1438
1584
|
# Each of the arguments `read_ios`, `write_ios`, and `error_ios` is an array of
|
1439
1585
|
# IO objects.
|
1440
1586
|
#
|
1441
|
-
# Argument `timeout` is
|
1587
|
+
# Argument `timeout` is a numeric value (such as integer or float) timeout
|
1588
|
+
# interval in seconds.
|
1442
1589
|
#
|
1443
1590
|
# The method monitors the IO objects given in all three arrays, waiting for some
|
1444
1591
|
# to be ready; returns a 3-element array whose elements are:
|
@@ -1447,7 +1594,6 @@ module Kernel : BasicObject
|
|
1447
1594
|
# * An array of the objects in `write_ios` that are ready for writing.
|
1448
1595
|
# * An array of the objects in `error_ios` have pending exceptions.
|
1449
1596
|
#
|
1450
|
-
#
|
1451
1597
|
# If no object becomes ready within the given `timeout`, `nil` is returned.
|
1452
1598
|
#
|
1453
1599
|
# IO.select peeks the buffer of IO objects for testing readability. If the IO
|
@@ -1583,7 +1729,7 @@ module Kernel : BasicObject
|
|
1583
1729
|
def self?.sleep: (?nil) -> bot
|
1584
1730
|
| (Time::_Timeout duration) -> Integer
|
1585
1731
|
|
1586
|
-
%a{
|
1732
|
+
%a{deprecated}
|
1587
1733
|
interface _Divmod
|
1588
1734
|
def divmod: (Numeric) -> [ Numeric, Numeric ]
|
1589
1735
|
end
|
@@ -1616,59 +1762,69 @@ module Kernel : BasicObject
|
|
1616
1762
|
|
1617
1763
|
# <!--
|
1618
1764
|
# rdoc-file=file.c
|
1619
|
-
# - test(
|
1620
|
-
# -->
|
1621
|
-
#
|
1622
|
-
#
|
1623
|
-
#
|
1624
|
-
#
|
1625
|
-
#
|
1626
|
-
#
|
1627
|
-
#
|
1628
|
-
#
|
1629
|
-
#
|
1630
|
-
#
|
1631
|
-
#
|
1632
|
-
#
|
1633
|
-
#
|
1634
|
-
#
|
1635
|
-
#
|
1636
|
-
#
|
1637
|
-
#
|
1638
|
-
#
|
1639
|
-
#
|
1640
|
-
#
|
1641
|
-
#
|
1642
|
-
#
|
1643
|
-
#
|
1644
|
-
#
|
1645
|
-
#
|
1646
|
-
#
|
1647
|
-
#
|
1648
|
-
#
|
1649
|
-
#
|
1650
|
-
#
|
1651
|
-
#
|
1652
|
-
#
|
1653
|
-
#
|
1654
|
-
#
|
1655
|
-
#
|
1656
|
-
#
|
1657
|
-
#
|
1658
|
-
#
|
1659
|
-
#
|
1660
|
-
#
|
1661
|
-
#
|
1662
|
-
#
|
1663
|
-
#
|
1664
|
-
#
|
1665
|
-
#
|
1666
|
-
#
|
1667
|
-
#
|
1668
|
-
#
|
1669
|
-
#
|
1670
|
-
#
|
1671
|
-
#
|
1765
|
+
# - test(char, path0, path1 = nil) -> object
|
1766
|
+
# -->
|
1767
|
+
# Performs a test on one or both of the *filesystem entities* at the given paths
|
1768
|
+
# `path0` and `path1`:
|
1769
|
+
# * Each path `path0` or `path1` points to a file, directory, device, pipe,
|
1770
|
+
# etc.
|
1771
|
+
# * Character `char` selects a specific test.
|
1772
|
+
# The tests:
|
1773
|
+
# * Each of these tests operates only on the entity at `path0`,
|
1774
|
+
# and returns `true` or `false`;
|
1775
|
+
# for a non-existent entity, returns `false` (does not raise exception):
|
1776
|
+
# Character |Test
|
1777
|
+
# ------------|-------------------------------------------------------------------------
|
1778
|
+
# <tt>'b'</tt>|Whether the entity is a block device.
|
1779
|
+
# <tt>'c'</tt>|Whether the entity is a character device.
|
1780
|
+
# <tt>'d'</tt>|Whether the entity is a directory.
|
1781
|
+
# <tt>'e'</tt>|Whether the entity is an existing entity.
|
1782
|
+
# <tt>'f'</tt>|Whether the entity is an existing regular file.
|
1783
|
+
# <tt>'g'</tt>|Whether the entity's setgid bit is set.
|
1784
|
+
# <tt>'G'</tt>|Whether the entity's group ownership is equal to the caller's.
|
1785
|
+
# <tt>'k'</tt>|Whether the entity's sticky bit is set.
|
1786
|
+
# <tt>'l'</tt>|Whether the entity is a symbolic link.
|
1787
|
+
# <tt>'o'</tt>|Whether the entity is owned by the caller's effective uid.
|
1788
|
+
# <tt>'O'</tt>|Like <tt>'o'</tt>, but uses the real uid (not the effective uid).
|
1789
|
+
# <tt>'p'</tt>|Whether the entity is a FIFO device (named pipe).
|
1790
|
+
# <tt>'r'</tt>|Whether the entity is readable by the caller's effective uid/gid.
|
1791
|
+
# <tt>'R'</tt>|Like <tt>'r'</tt>, but uses the real uid/gid (not the effective uid/gid).
|
1792
|
+
# <tt>'S'</tt>|Whether the entity is a socket.
|
1793
|
+
# <tt>'u'</tt>|Whether the entity's setuid bit is set.
|
1794
|
+
# <tt>'w'</tt>|Whether the entity is writable by the caller's effective uid/gid.
|
1795
|
+
# <tt>'W'</tt>|Like <tt>'w'</tt>, but uses the real uid/gid (not the effective uid/gid).
|
1796
|
+
# <tt>'x'</tt>|Whether the entity is executable by the caller's effective uid/gid.
|
1797
|
+
# <tt>'X'</tt>|Like <tt>'x'</tt>, but uses the real uid/gid (not the effective uid/git).
|
1798
|
+
# <tt>'z'</tt>|Whether the entity exists and is of length zero.
|
1799
|
+
# * This test operates only on the entity at `path0`,
|
1800
|
+
# and returns an integer size or `nil`:
|
1801
|
+
# Character |Test
|
1802
|
+
# ------------|--------------------------------------------------------------------------------------------
|
1803
|
+
# <tt>'s'</tt>|Returns positive integer size if the entity exists and has non-zero length, +nil+ otherwise.
|
1804
|
+
# * Each of these tests operates only on the entity at `path0`,
|
1805
|
+
# and returns a Time object;
|
1806
|
+
# raises an exception if the entity does not exist:
|
1807
|
+
# Character |Test
|
1808
|
+
# ------------|--------------------------------------
|
1809
|
+
# <tt>'A'</tt>|Last access time for the entity.
|
1810
|
+
# <tt>'C'</tt>|Last change time for the entity.
|
1811
|
+
# <tt>'M'</tt>|Last modification time for the entity.
|
1812
|
+
# * Each of these tests operates on the modification time (`mtime`)
|
1813
|
+
# of each of the entities at `path0` and `path1`,
|
1814
|
+
# and returns a `true` or `false`;
|
1815
|
+
# returns `false` if either entity does not exist:
|
1816
|
+
# Character |Test
|
1817
|
+
# ------------|---------------------------------------------------------------
|
1818
|
+
# <tt>'<'</tt>|Whether the `mtime` at `path0` is less than that at `path1`.
|
1819
|
+
# <tt>'='</tt>|Whether the `mtime` at `path0` is equal to that at `path1`.
|
1820
|
+
# <tt>'>'</tt>|Whether the `mtime` at `path0` is greater than that at `path1`.
|
1821
|
+
# * This test operates on the content of each of the entities at `path0` and
|
1822
|
+
# `path1`,
|
1823
|
+
# and returns a `true` or `false`;
|
1824
|
+
# returns `false` if either entity does not exist:
|
1825
|
+
# Character |Test
|
1826
|
+
# ------------|---------------------------------------------
|
1827
|
+
# <tt>'-'</tt>|Whether the entities exist and are identical.
|
1672
1828
|
#
|
1673
1829
|
def self?.test: (String | Integer cmd, String | IO file1, ?String | IO file2) -> (TrueClass | FalseClass | Time | nil | Integer)
|
1674
1830
|
|
@@ -1719,15 +1875,19 @@ module Kernel : BasicObject
|
|
1719
1875
|
# baz.rb:6: warning: invalid call to foo
|
1720
1876
|
#
|
1721
1877
|
# If `category` keyword argument is given, passes the category to
|
1722
|
-
# `Warning.warn`. The category given must be
|
1723
|
-
# categories:
|
1878
|
+
# `Warning.warn`. The category given must be one of the following categories:
|
1724
1879
|
#
|
1725
1880
|
# :deprecated
|
1726
1881
|
# : Used for warning for deprecated functionality that may be removed in the
|
1727
1882
|
# future.
|
1883
|
+
#
|
1728
1884
|
# :experimental
|
1729
1885
|
# : Used for experimental features that may change in future releases.
|
1730
1886
|
#
|
1887
|
+
# :performance
|
1888
|
+
# : Used for warning about APIs or pattern that have negative performance
|
1889
|
+
# impact
|
1890
|
+
#
|
1731
1891
|
def self?.warn: (*_ToS msg, ?uplevel: int?, ?category: Warning::category?) -> nil
|
1732
1892
|
|
1733
1893
|
# <!--
|
@@ -1740,7 +1900,6 @@ module Kernel : BasicObject
|
|
1740
1900
|
# * Passing string `command_line` to the shell.
|
1741
1901
|
# * Invoking the executable at `exe_path`.
|
1742
1902
|
#
|
1743
|
-
#
|
1744
1903
|
# This method has potential security vulnerabilities if called with untrusted
|
1745
1904
|
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
1746
1905
|
#
|
@@ -1761,7 +1920,6 @@ module Kernel : BasicObject
|
|
1761
1920
|
# word or special built-in, or if it contains one or more meta characters.
|
1762
1921
|
# * `exe_path` otherwise.
|
1763
1922
|
#
|
1764
|
-
#
|
1765
1923
|
# **Argument `command_line`**
|
1766
1924
|
#
|
1767
1925
|
# String argument `command_line` is a command line to be passed to a shell; it
|
@@ -1769,7 +1927,7 @@ module Kernel : BasicObject
|
|
1769
1927
|
# contain meta characters:
|
1770
1928
|
#
|
1771
1929
|
# exec('if true; then echo "Foo"; fi') # Shell reserved word.
|
1772
|
-
# exec('
|
1930
|
+
# exec('exit') # Built-in.
|
1773
1931
|
# exec('date > date.tmp') # Contains meta character.
|
1774
1932
|
#
|
1775
1933
|
# The command line may also contain arguments and options for the command:
|
@@ -1793,7 +1951,6 @@ module Kernel : BasicObject
|
|
1793
1951
|
# * A 2-element array containing the path to an executable and the string to
|
1794
1952
|
# be used as the name of the executing process.
|
1795
1953
|
#
|
1796
|
-
#
|
1797
1954
|
# Example:
|
1798
1955
|
#
|
1799
1956
|
# exec('/usr/bin/date')
|
@@ -1802,7 +1959,8 @@ module Kernel : BasicObject
|
|
1802
1959
|
#
|
1803
1960
|
# Sat Aug 26 09:38:00 AM CDT 2023
|
1804
1961
|
#
|
1805
|
-
# Ruby invokes the executable directly
|
1962
|
+
# Ruby invokes the executable directly. This form does not use the shell; see
|
1963
|
+
# [Arguments args](rdoc-ref:Process@Arguments+args) for caveats.
|
1806
1964
|
#
|
1807
1965
|
# exec('doesnt_exist') # Raises Errno::ENOENT
|
1808
1966
|
#
|
@@ -1834,7 +1992,6 @@ module Kernel : BasicObject
|
|
1834
1992
|
# * Passing string `command_line` to the shell.
|
1835
1993
|
# * Invoking the executable at `exe_path`.
|
1836
1994
|
#
|
1837
|
-
#
|
1838
1995
|
# This method has potential security vulnerabilities if called with untrusted
|
1839
1996
|
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
1840
1997
|
#
|
@@ -1846,7 +2003,6 @@ module Kernel : BasicObject
|
|
1846
2003
|
# * Process.wait, to collect the termination statuses of its children.
|
1847
2004
|
# * Process.detach, to register disinterest in their status.
|
1848
2005
|
#
|
1849
|
-
#
|
1850
2006
|
# The new process is created using the [exec system
|
1851
2007
|
# call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/e
|
1852
2008
|
# xecve.html); it may inherit some of its environment from the calling program
|
@@ -1864,7 +2020,6 @@ module Kernel : BasicObject
|
|
1864
2020
|
# word or special built-in, or if it contains one or more meta characters.
|
1865
2021
|
# * `exe_path` otherwise.
|
1866
2022
|
#
|
1867
|
-
#
|
1868
2023
|
# **Argument `command_line`**
|
1869
2024
|
#
|
1870
2025
|
# String argument `command_line` is a command line to be passed to a shell; it
|
@@ -1873,7 +2028,7 @@ module Kernel : BasicObject
|
|
1873
2028
|
#
|
1874
2029
|
# spawn('if true; then echo "Foo"; fi') # => 798847 # Shell reserved word.
|
1875
2030
|
# Process.wait # => 798847
|
1876
|
-
# spawn('
|
2031
|
+
# spawn('exit') # => 798848 # Built-in.
|
1877
2032
|
# Process.wait # => 798848
|
1878
2033
|
# spawn('date > /tmp/date.tmp') # => 798879 # Contains meta character.
|
1879
2034
|
# Process.wait # => 798849
|
@@ -1898,27 +2053,19 @@ module Kernel : BasicObject
|
|
1898
2053
|
#
|
1899
2054
|
# Argument `exe_path` is one of the following:
|
1900
2055
|
#
|
1901
|
-
# * The string path to an executable to be called
|
2056
|
+
# * The string path to an executable to be called.
|
2057
|
+
# * A 2-element array containing the path to an executable to be called, and
|
2058
|
+
# the string to be used as the name of the executing process.
|
1902
2059
|
#
|
1903
2060
|
# spawn('/usr/bin/date') # Path to date on Unix-style system.
|
1904
2061
|
# Process.wait
|
1905
2062
|
#
|
1906
2063
|
# Output:
|
1907
2064
|
#
|
1908
|
-
#
|
1909
|
-
#
|
1910
|
-
# * A 2-element array containing the path to an executable and the string to
|
1911
|
-
# be used as the name of the executing process:
|
1912
|
-
#
|
1913
|
-
# pid = spawn(['sleep', 'Hello!'], '1') # 2-element array.
|
1914
|
-
# p `ps -p #{pid} -o command=`
|
1915
|
-
#
|
1916
|
-
# Output:
|
1917
|
-
#
|
1918
|
-
# "Hello! 1\n"
|
2065
|
+
# Mon Aug 28 11:43:10 AM CDT 2023
|
1919
2066
|
#
|
1920
|
-
#
|
1921
|
-
#
|
2067
|
+
# Ruby invokes the executable directly. This form does not use the shell; see
|
2068
|
+
# [Arguments args](rdoc-ref:Process@Arguments+args) for caveats.
|
1922
2069
|
#
|
1923
2070
|
# If one or more `args` is given, each is an argument or option to be passed to
|
1924
2071
|
# the executable:
|
@@ -1948,7 +2095,6 @@ module Kernel : BasicObject
|
|
1948
2095
|
# * Passing string `command_line` to the shell.
|
1949
2096
|
# * Invoking the executable at `exe_path`.
|
1950
2097
|
#
|
1951
|
-
#
|
1952
2098
|
# This method has potential security vulnerabilities if called with untrusted
|
1953
2099
|
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
1954
2100
|
#
|
@@ -1958,7 +2104,6 @@ module Kernel : BasicObject
|
|
1958
2104
|
# * `false` if the exit status is a non-zero integer.
|
1959
2105
|
# * `nil` if the command could not execute.
|
1960
2106
|
#
|
1961
|
-
#
|
1962
2107
|
# Raises an exception (instead of returning `false` or `nil`) if keyword
|
1963
2108
|
# argument `exception` is set to `true`.
|
1964
2109
|
#
|
@@ -1981,7 +2126,6 @@ module Kernel : BasicObject
|
|
1981
2126
|
# word or special built-in, or if it contains one or more meta characters.
|
1982
2127
|
# * `exe_path` otherwise.
|
1983
2128
|
#
|
1984
|
-
#
|
1985
2129
|
# **Argument `command_line`**
|
1986
2130
|
#
|
1987
2131
|
# String argument `command_line` is a command line to be passed to a shell; it
|
@@ -1989,14 +2133,14 @@ module Kernel : BasicObject
|
|
1989
2133
|
# contain meta characters:
|
1990
2134
|
#
|
1991
2135
|
# system('if true; then echo "Foo"; fi') # => true # Shell reserved word.
|
1992
|
-
# system('
|
2136
|
+
# system('exit') # => true # Built-in.
|
1993
2137
|
# system('date > /tmp/date.tmp') # => true # Contains meta character.
|
1994
2138
|
# system('date > /nop/date.tmp') # => false
|
1995
2139
|
# system('date > /nop/date.tmp', exception: true) # Raises RuntimeError.
|
1996
2140
|
#
|
1997
2141
|
# Assigns the command's error status to `$?`:
|
1998
2142
|
#
|
1999
|
-
# system('
|
2143
|
+
# system('exit') # => true # Built-in.
|
2000
2144
|
# $? # => #<Process::Status: pid 640610 exit 0>
|
2001
2145
|
# system('date > /nop/date.tmp') # => false
|
2002
2146
|
# $? # => #<Process::Status: pid 640742 exit 2>
|
@@ -2022,7 +2166,6 @@ module Kernel : BasicObject
|
|
2022
2166
|
# * A 2-element array containing the path to an executable and the string to
|
2023
2167
|
# be used as the name of the executing process.
|
2024
2168
|
#
|
2025
|
-
#
|
2026
2169
|
# Example:
|
2027
2170
|
#
|
2028
2171
|
# system('/usr/bin/date') # => true # Path to date on Unix-style system.
|
@@ -2039,7 +2182,8 @@ module Kernel : BasicObject
|
|
2039
2182
|
# system('foo') # => nil
|
2040
2183
|
# $? # => #<Process::Status: pid 645608 exit 127>
|
2041
2184
|
#
|
2042
|
-
# Ruby invokes the executable directly
|
2185
|
+
# Ruby invokes the executable directly. This form does not use the shell; see
|
2186
|
+
# [Arguments args](rdoc-ref:Process@Arguments+args) for caveats.
|
2043
2187
|
#
|
2044
2188
|
# system('doesnt_exist') # => nil
|
2045
2189
|
#
|
@@ -2056,8 +2200,8 @@ module Kernel : BasicObject
|
|
2056
2200
|
#
|
2057
2201
|
# Raises an exception if the new process could not execute.
|
2058
2202
|
#
|
2059
|
-
def self?.system: (String command, *String args, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: redirect_fd, ?out: redirect_fd, ?err: redirect_fd, ?close_others: boolish, ?chdir: String) -> (NilClass | FalseClass | TrueClass)
|
2060
|
-
| (Hash[string, string?] env, String command, *String args, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: redirect_fd, ?out: redirect_fd, ?err: redirect_fd, ?close_others: boolish, ?chdir: String) -> (NilClass | FalseClass | TrueClass)
|
2203
|
+
def self?.system: (String command, *String args, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: redirect_fd, ?out: redirect_fd, ?err: redirect_fd, ?close_others: boolish, ?chdir: String, ?exception: bool) -> (NilClass | FalseClass | TrueClass)
|
2204
|
+
| (Hash[string, string?] env, String command, *String args, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: redirect_fd, ?out: redirect_fd, ?err: redirect_fd, ?close_others: boolish, ?chdir: String, ?exception: bool) -> (NilClass | FalseClass | TrueClass)
|
2061
2205
|
|
2062
2206
|
# <!--
|
2063
2207
|
# rdoc-file=object.c
|
@@ -2117,7 +2261,7 @@ module Kernel : BasicObject
|
|
2117
2261
|
# s1.inspect #=> "#<Klass:0x401b3a38 @str=\"Hi\">"
|
2118
2262
|
# s2.inspect #=> "#<Klass:0x401b3998 @str=\"Hi\">"
|
2119
2263
|
#
|
2120
|
-
# This method may have class-specific behavior.
|
2264
|
+
# This method may have class-specific behavior. If so, that behavior will be
|
2121
2265
|
# documented under the #`initialize_copy` method of the class.
|
2122
2266
|
#
|
2123
2267
|
def clone: (?freeze: bool?) -> self
|
@@ -2153,7 +2297,7 @@ module Kernel : BasicObject
|
|
2153
2297
|
# chris.greet("Hi") #=> "Hi, I'm Chris!"
|
2154
2298
|
#
|
2155
2299
|
def define_singleton_method: (interned name, Method | UnboundMethod | Proc method) -> Symbol
|
2156
|
-
| (interned name) { (?) -> untyped } -> Symbol
|
2300
|
+
| (interned name) { (?) [self: self] -> untyped } -> Symbol
|
2157
2301
|
|
2158
2302
|
# <!--
|
2159
2303
|
# rdoc-file=io.c
|
@@ -2885,7 +3029,7 @@ module Kernel : BasicObject
|
|
2885
3029
|
# rdoc-file=kernel.rb
|
2886
3030
|
# - obj.tap {|x| block } -> obj
|
2887
3031
|
# -->
|
2888
|
-
# Yields self to the block
|
3032
|
+
# Yields self to the block and then returns self. The primary purpose of this
|
2889
3033
|
# method is to "tap into" a method chain, in order to perform operations on
|
2890
3034
|
# intermediate results within the chain.
|
2891
3035
|
#
|
@@ -2909,11 +3053,8 @@ module Kernel : BasicObject
|
|
2909
3053
|
|
2910
3054
|
# <!--
|
2911
3055
|
# rdoc-file=kernel.rb
|
2912
|
-
# -
|
3056
|
+
# - yield_self()
|
2913
3057
|
# -->
|
2914
|
-
# Yields self to the block and returns the result of the block.
|
2915
|
-
#
|
2916
|
-
# "my string".yield_self {|s| s.upcase } #=> "MY STRING"
|
2917
3058
|
#
|
2918
3059
|
def yield_self: () -> Enumerator[self, untyped]
|
2919
3060
|
| [T] () { (self) -> T } -> T
|
@@ -2926,32 +3067,23 @@ module Kernel : BasicObject
|
|
2926
3067
|
#
|
2927
3068
|
# 3.next.then {|x| x**x }.to_s #=> "256"
|
2928
3069
|
#
|
2929
|
-
#
|
3070
|
+
# A good use of `then` is value piping in method chains:
|
2930
3071
|
#
|
2931
3072
|
# require 'open-uri'
|
2932
3073
|
# require 'json'
|
2933
3074
|
#
|
2934
|
-
# construct_url(arguments)
|
2935
|
-
# then {|url| URI(url).read }
|
2936
|
-
# then {|response| JSON.parse(response) }
|
3075
|
+
# construct_url(arguments)
|
3076
|
+
# .then {|url| URI(url).read }
|
3077
|
+
# .then {|response| JSON.parse(response) }
|
2937
3078
|
#
|
2938
|
-
# When called without block, the method returns `Enumerator`, which can be
|
2939
|
-
# for example, for conditional circuit-breaking:
|
3079
|
+
# When called without a block, the method returns an `Enumerator`, which can be
|
3080
|
+
# used, for example, for conditional circuit-breaking:
|
2940
3081
|
#
|
2941
|
-
# #
|
3082
|
+
# # Meets condition, no-op
|
2942
3083
|
# 1.then.detect(&:odd?) # => 1
|
2943
|
-
# #
|
3084
|
+
# # Does not meet condition, drop value
|
2944
3085
|
# 2.then.detect(&:odd?) # => nil
|
2945
3086
|
#
|
2946
|
-
# Good usage for `then` is value piping in method chains:
|
2947
|
-
#
|
2948
|
-
# require 'open-uri'
|
2949
|
-
# require 'json'
|
2950
|
-
#
|
2951
|
-
# construct_url(arguments).
|
2952
|
-
# then {|url| URI(url).read }.
|
2953
|
-
# then {|response| JSON.parse(response) }
|
2954
|
-
#
|
2955
3087
|
alias then yield_self
|
2956
3088
|
|
2957
3089
|
private
|