rbs 2.6.0 → 2.7.0.pre.1
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/.gitignore +2 -0
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +48 -1
- data/Gemfile.lock +10 -9
- data/Rakefile +0 -5
- data/Steepfile +1 -0
- data/core/basic_object.rbs +2 -2
- data/core/fiber.rbs +304 -14
- data/core/float.rbs +2 -0
- data/core/io.rbs +95 -1
- data/core/kernel.rbs +1 -1
- data/core/module.rbs +1 -1
- data/core/regexp.rbs +1 -1
- data/core/string_io.rbs +1 -1
- data/core/warning.rbs +1 -1
- data/ext/rbs_extension/parser.c +36 -10
- data/ext/rbs_extension/ruby_objs.c +4 -2
- data/ext/rbs_extension/ruby_objs.h +2 -2
- data/lib/rbs/ancestor_graph.rb +2 -0
- data/lib/rbs/annotate/annotations.rb +2 -0
- data/lib/rbs/annotate/formatter.rb +4 -2
- data/lib/rbs/annotate/rdoc_annotator.rb +2 -0
- data/lib/rbs/annotate/rdoc_source.rb +2 -0
- data/lib/rbs/annotate.rb +2 -0
- data/lib/rbs/ast/annotation.rb +2 -0
- data/lib/rbs/ast/comment.rb +2 -0
- data/lib/rbs/ast/declarations.rb +2 -0
- data/lib/rbs/ast/members.rb +2 -0
- data/lib/rbs/ast/type_param.rb +3 -1
- data/lib/rbs/buffer.rb +2 -0
- data/lib/rbs/builtin_names.rb +2 -0
- data/lib/rbs/cli.rb +39 -2
- data/lib/rbs/collection/cleaner.rb +2 -0
- data/lib/rbs/collection/config/lockfile_generator.rb +8 -3
- data/lib/rbs/collection/config.rb +2 -0
- data/lib/rbs/collection/installer.rb +2 -0
- data/lib/rbs/collection/sources/base.rb +14 -0
- data/lib/rbs/collection/sources/git.rb +3 -0
- data/lib/rbs/collection/sources/rubygems.rb +3 -0
- data/lib/rbs/collection/sources/stdlib.rb +12 -7
- data/lib/rbs/collection/sources.rb +3 -0
- data/lib/rbs/collection.rb +2 -0
- data/lib/rbs/constant.rb +2 -0
- data/lib/rbs/constant_table.rb +5 -3
- data/lib/rbs/definition.rb +13 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +2 -0
- data/lib/rbs/definition_builder/method_builder.rb +2 -0
- data/lib/rbs/definition_builder.rb +75 -13
- data/lib/rbs/environment.rb +2 -0
- data/lib/rbs/environment_loader.rb +25 -5
- data/lib/rbs/environment_walker.rb +2 -0
- data/lib/rbs/errors.rb +3 -1
- data/lib/rbs/factory.rb +2 -0
- data/lib/rbs/location_aux.rb +3 -1
- data/lib/rbs/locator.rb +2 -0
- data/lib/rbs/method_type.rb +7 -5
- data/lib/rbs/namespace.rb +9 -5
- data/lib/rbs/parser_aux.rb +2 -0
- data/lib/rbs/parser_compat/lexer_error.rb +2 -0
- data/lib/rbs/parser_compat/located_value.rb +2 -0
- data/lib/rbs/parser_compat/semantics_error.rb +2 -0
- data/lib/rbs/parser_compat/syntax_error.rb +2 -0
- data/lib/rbs/prototype/helpers.rb +13 -8
- data/lib/rbs/prototype/rb.rb +2 -0
- data/lib/rbs/prototype/rbi.rb +11 -6
- data/lib/rbs/prototype/runtime.rb +13 -4
- data/lib/rbs/repository.rb +4 -4
- data/lib/rbs/resolver/constant_resolver.rb +2 -0
- data/lib/rbs/resolver/type_name_resolver.rb +2 -0
- data/lib/rbs/sorter.rb +168 -0
- data/lib/rbs/substitution.rb +2 -0
- data/lib/rbs/test/errors.rb +2 -0
- data/lib/rbs/test/hook.rb +2 -0
- data/lib/rbs/test/observer.rb +2 -0
- data/lib/rbs/test/setup.rb +2 -0
- data/lib/rbs/test/setup_helper.rb +2 -0
- data/lib/rbs/test/spy.rb +2 -0
- data/lib/rbs/test/tester.rb +2 -0
- data/lib/rbs/test/type_check.rb +2 -0
- data/lib/rbs/test.rb +2 -0
- data/lib/rbs/type_alias_dependency.rb +2 -0
- data/lib/rbs/type_alias_regularity.rb +2 -0
- data/lib/rbs/type_name.rb +2 -0
- data/lib/rbs/type_name_resolver.rb +4 -2
- data/lib/rbs/types.rb +68 -18
- data/lib/rbs/validator.rb +2 -0
- data/lib/rbs/variance_calculator.rb +2 -0
- data/lib/rbs/vendorer.rb +2 -0
- data/lib/rbs/version.rb +3 -1
- data/lib/rbs/writer.rb +3 -1
- data/lib/rbs.rb +4 -2
- data/lib/rdoc/discover.rb +20 -0
- data/lib/rdoc_plugin/parser.rb +163 -0
- data/schema/methodType.json +7 -1
- data/schema/types.json +13 -1
- data/sig/ancestor_builder.rbs +66 -7
- data/sig/annotation.rbs +7 -6
- data/sig/builtin_names.rbs +2 -0
- data/sig/cli.rbs +8 -0
- data/sig/collection/config.rbs +13 -4
- data/sig/collection/installer.rbs +2 -0
- data/sig/collection/sources.rbs +23 -4
- data/sig/definition.rbs +8 -0
- data/sig/definition_builder.rbs +64 -7
- data/sig/environment.rbs +4 -0
- data/sig/environment_loader.rbs +4 -2
- data/sig/location.rbs +8 -4
- data/sig/manifest.yaml +1 -0
- data/sig/members.rbs +1 -1
- data/sig/method_builder.rbs +10 -0
- data/sig/namespace.rbs +54 -31
- data/sig/prototype/rb.rbs +4 -0
- data/sig/rbs.rbs +8 -6
- data/sig/rdoc/rbs.rbs +63 -0
- data/sig/{polyfill.rbs → shims.rbs} +1 -31
- data/sig/sorter.rbs +23 -0
- data/sig/types.rbs +14 -2
- data/sig/vendorer.rbs +32 -25
- data/stdlib/bigdecimal/0/big_decimal.rbs +250 -0
- data/stdlib/erb/0/erb.rbs +107 -0
- data/stdlib/logger/0/logger.rbs +2 -2
- data/stdlib/rdoc/0/rdoc.rbs +758 -0
- data/steep/Gemfile.lock +8 -8
- metadata +12 -6
- data/stdlib/fiber/0/fiber.rbs +0 -99
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aeae92c94238c9c1b417f2efd334c6af1435c94b6f43480f6979b413694936b4
|
|
4
|
+
data.tar.gz: 8abf8d32d6ce0b2103696436698fe5687bef05a677da6f46a317f83adfe73380
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6bdb78cad95578cf94728625e0d20ca211a1ed8140a728f5f723b2331731733d73bc6d33e0ec4f914782ff1cde52d52079c5625afe008a297c1952b115870075
|
|
7
|
+
data.tar.gz: 0c56b8f9ce630cc77ec080ca5ad172611005fb2cd6cfcc18ea239dc5a8490aa11f74a0f4bd9d3045a8e71f6920b41d203fb7d228207696ea92d0c74c9069b317
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
## master
|
|
4
4
|
|
|
5
|
+
## 2.7.0.pre.1 (2022-09-02)
|
|
6
|
+
|
|
7
|
+
See [Release Note 2.7](https://github.com/ruby/rbs/wiki/Release-Note-2.7) for the highlights of this release.
|
|
8
|
+
|
|
9
|
+
### Signature updates
|
|
10
|
+
|
|
11
|
+
* fiber ([#1071](https://github.com/ruby/rbs/pull/1071))
|
|
12
|
+
* `BigDecimal` ([#1053](https://github.com/ruby/rbs/pull/1053))
|
|
13
|
+
* `ERB::Util`, `ERB::DefMethod` ([#1074](https://github.com/ruby/rbs/pull/1074))
|
|
14
|
+
* `Float::Infinity` ([#1095](https://github.com/ruby/rbs/pull/1095))
|
|
15
|
+
* `Logger` ([#1046](https://github.com/ruby/rbs/pull/1046))
|
|
16
|
+
* `IO.pipe`, `IO.foreach` ([#1057](https://github.com/ruby/rbs/pull/1057))
|
|
17
|
+
* `Module#refine` ([#1064](https://github.com/ruby/rbs/pull/1064))
|
|
18
|
+
* `Regexp.new` ([#1059](https://github.com/ruby/rbs/pull/1059))
|
|
19
|
+
* `StringIO#write` ([#1065](https://github.com/ruby/rbs/pull/1065))
|
|
20
|
+
* `Warning.#warn`, `Kernel.#warn` ([#1056](https://github.com/ruby/rbs/pull/1056))
|
|
21
|
+
|
|
22
|
+
### Language updates
|
|
23
|
+
|
|
24
|
+
* Type of `self` in blocks/procs ([#1077](https://github.com/ruby/rbs/issues/1077), [#1101](https://github.com/ruby/rbs/pull/1101))
|
|
25
|
+
|
|
26
|
+
### Library changes
|
|
27
|
+
|
|
28
|
+
* RDoc plugin ([#1048](https://github.com/ruby/rbs/pull/1048))
|
|
29
|
+
* Dedupe method comments ([#1103](https://github.com/ruby/rbs/pull/1103))
|
|
30
|
+
* Reduce object allocations for GC ([#1102](https://github.com/ruby/rbs/pull/1102))
|
|
31
|
+
* Add `frozen_string_literal: true` ([#1100](https://github.com/ruby/rbs/pull/1100))
|
|
32
|
+
* Load dependencies on `-r` option also ([#1013](https://github.com/ruby/rbs/pull/1013))
|
|
33
|
+
* Fix DefinitionBuilder for methods aliased from module self constraints ([#1099](https://github.com/ruby/rbs/pull/1099))
|
|
34
|
+
* Fix RBS type definitions ([#1098](https://github.com/ruby/rbs/pull/1098))
|
|
35
|
+
* Give aliases of `.new` methods correct type ([#1097](https://github.com/ruby/rbs/pull/1097))
|
|
36
|
+
* `nil` versions are discouraged and will be deprecated in Rubygems 4 ([#1091](https://github.com/ruby/rbs/pull/1091))
|
|
37
|
+
* Fixes towards Rubygems 4.0 ([#1090](https://github.com/ruby/rbs/pull/1090))
|
|
38
|
+
* Remove redundant `add` for `Repository.default` ([#1062](https://github.com/ruby/rbs/pull/1062))
|
|
39
|
+
* Refactor: Use Repository in stdlib source ([#1063](https://github.com/ruby/rbs/pull/1063))
|
|
40
|
+
* Move `bin/sort` implementation to under `lib/` ([#1051](https://github.com/ruby/rbs/pull/1051))
|
|
41
|
+
|
|
42
|
+
#### rbs prototype
|
|
43
|
+
|
|
44
|
+
* Fix some error on `prototype runtime` ([#1055](https://github.com/ruby/rbs/pull/1055))
|
|
45
|
+
* Skip existing RBS files from batch `prototype` ([#1060](https://github.com/ruby/rbs/pull/1060))
|
|
46
|
+
|
|
47
|
+
### Miscellaneous
|
|
48
|
+
|
|
49
|
+
* Discard outputs from test code ([#1093](https://github.com/ruby/rbs/pull/1093))
|
|
50
|
+
* Skip testing visibility methods with Ruby 3.2 ([#1082](https://github.com/ruby/rbs/pull/1082))
|
|
51
|
+
|
|
5
52
|
## 2.6.0 (2022-06-22)
|
|
6
53
|
|
|
7
54
|
RBS 2.6 ships with `rbs prototype` commands improvements and signature updates.
|
|
@@ -44,7 +91,7 @@ New minitest RBS definitions will help you to type check your tests.
|
|
|
44
91
|
* Fix type errors ([\#1023](https://github.com/ruby/rbs/pull/1023))
|
|
45
92
|
* Clarify GHA step name for rake annotate ([\#1024](https://github.com/ruby/rbs/pull/1024))
|
|
46
93
|
* Silence parser warning ([\#1039](https://github.com/ruby/rbs/pull/1039))
|
|
47
|
-
* Fix warnings ([\#1035](https://github.com/ruby/rbs/pull/1035)
|
|
94
|
+
* Fix warnings ([\#1035](https://github.com/ruby/rbs/pull/1035))
|
|
48
95
|
|
|
49
96
|
## 2.5.1 (2022-06-19)
|
|
50
97
|
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rbs (2.
|
|
4
|
+
rbs (2.7.0.pre.1)
|
|
5
5
|
|
|
6
6
|
PATH
|
|
7
7
|
remote: test/assets/test-gem
|
|
@@ -30,9 +30,9 @@ GEM
|
|
|
30
30
|
json-schema (3.0.0)
|
|
31
31
|
addressable (>= 2.8)
|
|
32
32
|
marcel (1.0.2)
|
|
33
|
-
minitest (5.16.
|
|
33
|
+
minitest (5.16.3)
|
|
34
34
|
parallel (1.22.1)
|
|
35
|
-
parser (3.1.2.
|
|
35
|
+
parser (3.1.2.1)
|
|
36
36
|
ast (~> 2.4.1)
|
|
37
37
|
power_assert (2.0.1)
|
|
38
38
|
prime (0.1.2)
|
|
@@ -62,16 +62,17 @@ GEM
|
|
|
62
62
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
63
63
|
rspec-support (~> 3.11.0)
|
|
64
64
|
rspec-support (3.11.0)
|
|
65
|
-
rubocop (1.
|
|
65
|
+
rubocop (1.35.1)
|
|
66
|
+
json (~> 2.3)
|
|
66
67
|
parallel (~> 1.10)
|
|
67
|
-
parser (>= 3.1.
|
|
68
|
+
parser (>= 3.1.2.1)
|
|
68
69
|
rainbow (>= 2.2.2, < 4.0)
|
|
69
70
|
regexp_parser (>= 1.8, < 3.0)
|
|
70
71
|
rexml (>= 3.2.5, < 4.0)
|
|
71
|
-
rubocop-ast (>= 1.
|
|
72
|
+
rubocop-ast (>= 1.20.1, < 2.0)
|
|
72
73
|
ruby-progressbar (~> 1.7)
|
|
73
74
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
74
|
-
rubocop-ast (1.
|
|
75
|
+
rubocop-ast (1.21.0)
|
|
75
76
|
parser (>= 3.1.1.0)
|
|
76
77
|
rubocop-rubycw (0.1.6)
|
|
77
78
|
rubocop (~> 1.0)
|
|
@@ -79,13 +80,13 @@ GEM
|
|
|
79
80
|
rake (>= 0.8.1)
|
|
80
81
|
ruby-progressbar (1.11.0)
|
|
81
82
|
singleton (0.1.1)
|
|
82
|
-
stackprof (0.2.
|
|
83
|
+
stackprof (0.2.21)
|
|
83
84
|
stringio (3.0.2)
|
|
84
85
|
strong_json (2.1.2)
|
|
85
86
|
tempfile (0.1.2)
|
|
86
87
|
test-unit (3.5.3)
|
|
87
88
|
power_assert
|
|
88
|
-
unicode-display_width (2.
|
|
89
|
+
unicode-display_width (2.2.0)
|
|
89
90
|
|
|
90
91
|
PLATFORMS
|
|
91
92
|
ruby
|
data/Rakefile
CHANGED
|
@@ -60,11 +60,6 @@ task :validate => :compile do
|
|
|
60
60
|
|
|
61
61
|
FileList["stdlib/*"].each do |path|
|
|
62
62
|
lib = [File.basename(path).to_s]
|
|
63
|
-
if File.exist?("#{path}/0/manifest.yaml")
|
|
64
|
-
YAML.load_file("#{path}/0/manifest.yaml")["dependencies"].each do |dep|
|
|
65
|
-
lib << dep["name"]
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
63
|
|
|
69
64
|
sh "#{ruby} #{rbs} #{lib.map {|l| "-r #{l}"}.join(" ")} validate --silent"
|
|
70
65
|
end
|
data/Steepfile
CHANGED
data/core/basic_object.rbs
CHANGED
|
@@ -257,7 +257,7 @@ class BasicObject
|
|
|
257
257
|
# k.instance_eval {|obj| obj == self } #=> true
|
|
258
258
|
#
|
|
259
259
|
def instance_eval: (String, ?String filename, ?Integer lineno) -> untyped
|
|
260
|
-
| [U] () { (self) -> U } -> U
|
|
260
|
+
| [U] () { (self) [self: self] -> U } -> U
|
|
261
261
|
|
|
262
262
|
# <!--
|
|
263
263
|
# rdoc-file=vm_eval.c
|
|
@@ -276,7 +276,7 @@ class BasicObject
|
|
|
276
276
|
# k = KlassWithSecret.new
|
|
277
277
|
# k.instance_exec(5) {|x| @secret+x } #=> 104
|
|
278
278
|
#
|
|
279
|
-
def instance_exec: [U, V] (*V args) { (*V args) -> U } -> U
|
|
279
|
+
def instance_exec: [U, V] (*V args) { (*V args) [self: self] -> U } -> U
|
|
280
280
|
|
|
281
281
|
# <!--
|
|
282
282
|
# rdoc-file=object.c
|
data/core/fiber.rbs
CHANGED
|
@@ -76,6 +76,114 @@
|
|
|
76
76
|
# the scheduler.
|
|
77
77
|
#
|
|
78
78
|
class Fiber < Object
|
|
79
|
+
# <!--
|
|
80
|
+
# rdoc-file=cont.c
|
|
81
|
+
# - Fiber.blocking? -> false or 1
|
|
82
|
+
# -->
|
|
83
|
+
# Returns `false` if the current fiber is non-blocking. Fiber is non-blocking if
|
|
84
|
+
# it was created via passing `blocking: false` to Fiber.new, or via
|
|
85
|
+
# Fiber.schedule.
|
|
86
|
+
#
|
|
87
|
+
# If the current Fiber is blocking, the method returns 1. Future developments
|
|
88
|
+
# may allow for situations where larger integers could be returned.
|
|
89
|
+
#
|
|
90
|
+
# Note that, even if the method returns `false`, Fiber behaves differently only
|
|
91
|
+
# if Fiber.scheduler is set in the current thread.
|
|
92
|
+
#
|
|
93
|
+
# See the "Non-blocking fibers" section in class docs for details.
|
|
94
|
+
#
|
|
95
|
+
def self.blocking?: () -> untyped
|
|
96
|
+
|
|
97
|
+
# <!--
|
|
98
|
+
# rdoc-file=cont.c
|
|
99
|
+
# - Fiber.current -> fiber
|
|
100
|
+
# -->
|
|
101
|
+
# Returns the current fiber. If you are not running in the context of a fiber
|
|
102
|
+
# this method will return the root fiber.
|
|
103
|
+
#
|
|
104
|
+
def self.current: () -> Fiber
|
|
105
|
+
|
|
106
|
+
# <!--
|
|
107
|
+
# rdoc-file=cont.c
|
|
108
|
+
# - Fiber.current_scheduler -> obj or nil
|
|
109
|
+
# -->
|
|
110
|
+
# Returns the Fiber scheduler, that was last set for the current thread with
|
|
111
|
+
# Fiber.set_scheduler if and only if the current fiber is non-blocking.
|
|
112
|
+
#
|
|
113
|
+
def self.current_scheduler: () -> untyped?
|
|
114
|
+
|
|
115
|
+
# <!--
|
|
116
|
+
# rdoc-file=cont.c
|
|
117
|
+
# - Fiber.schedule { |*args| ... } -> fiber
|
|
118
|
+
# -->
|
|
119
|
+
# The method is *expected* to immediately run the provided block of code in a
|
|
120
|
+
# separate non-blocking fiber.
|
|
121
|
+
#
|
|
122
|
+
# puts "Go to sleep!"
|
|
123
|
+
#
|
|
124
|
+
# Fiber.set_scheduler(MyScheduler.new)
|
|
125
|
+
#
|
|
126
|
+
# Fiber.schedule do
|
|
127
|
+
# puts "Going to sleep"
|
|
128
|
+
# sleep(1)
|
|
129
|
+
# puts "I slept well"
|
|
130
|
+
# end
|
|
131
|
+
#
|
|
132
|
+
# puts "Wakey-wakey, sleepyhead"
|
|
133
|
+
#
|
|
134
|
+
# Assuming MyScheduler is properly implemented, this program will produce:
|
|
135
|
+
#
|
|
136
|
+
# Go to sleep!
|
|
137
|
+
# Going to sleep
|
|
138
|
+
# Wakey-wakey, sleepyhead
|
|
139
|
+
# ...1 sec pause here...
|
|
140
|
+
# I slept well
|
|
141
|
+
#
|
|
142
|
+
# ...e.g. on the first blocking operation inside the Fiber (`sleep(1)`), the
|
|
143
|
+
# control is yielded to the outside code (main fiber), and *at the end of that
|
|
144
|
+
# execution*, the scheduler takes care of properly resuming all the blocked
|
|
145
|
+
# fibers.
|
|
146
|
+
#
|
|
147
|
+
# Note that the behavior described above is how the method is *expected* to
|
|
148
|
+
# behave, actual behavior is up to the current scheduler's implementation of
|
|
149
|
+
# Fiber::SchedulerInterface#fiber method. Ruby doesn't enforce this method to
|
|
150
|
+
# behave in any particular way.
|
|
151
|
+
#
|
|
152
|
+
# If the scheduler is not set, the method raises `RuntimeError (No scheduler is
|
|
153
|
+
# available!)`.
|
|
154
|
+
#
|
|
155
|
+
def self.schedule: () { () -> void } -> Fiber
|
|
156
|
+
|
|
157
|
+
# <!--
|
|
158
|
+
# rdoc-file=cont.c
|
|
159
|
+
# - Fiber.scheduler -> obj or nil
|
|
160
|
+
# -->
|
|
161
|
+
# Returns the Fiber scheduler, that was last set for the current thread with Fiber.set_scheduler.
|
|
162
|
+
# Returns +nil+ if no scheduler is set (which is the default), and non-blocking fibers'
|
|
163
|
+
#
|
|
164
|
+
# # behavior is the same as blocking.
|
|
165
|
+
# (see "Non-blocking fibers" section in class docs for details about the scheduler concept).
|
|
166
|
+
#
|
|
167
|
+
def self.scheduler: () -> untyped?
|
|
168
|
+
|
|
169
|
+
# <!--
|
|
170
|
+
# rdoc-file=cont.c
|
|
171
|
+
# - Fiber.set_scheduler(scheduler) -> scheduler
|
|
172
|
+
# -->
|
|
173
|
+
# Sets the Fiber scheduler for the current thread. If the scheduler is set,
|
|
174
|
+
# non-blocking fibers (created by Fiber.new with `blocking: false`, or by
|
|
175
|
+
# Fiber.schedule) call that scheduler's hook methods on potentially blocking
|
|
176
|
+
# operations, and the current thread will call scheduler's `close` method on
|
|
177
|
+
# finalization (allowing the scheduler to properly manage all non-finished
|
|
178
|
+
# fibers).
|
|
179
|
+
#
|
|
180
|
+
# `scheduler` can be an object of any class corresponding to
|
|
181
|
+
# Fiber::SchedulerInterface. Its implementation is up to the user.
|
|
182
|
+
#
|
|
183
|
+
# See also the "Non-blocking fibers" section in class docs.
|
|
184
|
+
#
|
|
185
|
+
def self.set_scheduler: (untyped) -> untyped
|
|
186
|
+
|
|
79
187
|
# <!--
|
|
80
188
|
# rdoc-file=cont.c
|
|
81
189
|
# - Fiber.yield(args, ...) -> obj
|
|
@@ -85,7 +193,7 @@ class Fiber < Object
|
|
|
85
193
|
# point when #resume is called next. Any arguments passed to the next #resume
|
|
86
194
|
# will be the value that this Fiber.yield expression evaluates to.
|
|
87
195
|
#
|
|
88
|
-
def self.yield: (*untyped
|
|
196
|
+
def self.yield: (*untyped) -> untyped
|
|
89
197
|
|
|
90
198
|
# <!--
|
|
91
199
|
# rdoc-file=cont.c
|
|
@@ -110,22 +218,106 @@ class Fiber < Object
|
|
|
110
218
|
# Fiber.scheduler defined, the Fiber becomes non-blocking (see "Non-blocking
|
|
111
219
|
# Fibers" section in class docs).
|
|
112
220
|
#
|
|
113
|
-
def initialize: () { () ->
|
|
221
|
+
def initialize: (?blocking: boolish) { (*untyped) -> void } -> void
|
|
114
222
|
|
|
115
223
|
# <!--
|
|
116
224
|
# rdoc-file=cont.c
|
|
117
|
-
# - fiber.
|
|
225
|
+
# - fiber.alive? -> true or false
|
|
118
226
|
# -->
|
|
119
|
-
#
|
|
120
|
-
#
|
|
121
|
-
# resume will be the value of the Fiber.yield expression or will be passed as
|
|
122
|
-
# block parameters to the fiber's block if this is the first #resume.
|
|
227
|
+
# Returns true if the fiber can still be resumed (or transferred to). After
|
|
228
|
+
# finishing execution of the fiber block this method will always return `false`.
|
|
123
229
|
#
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
#
|
|
230
|
+
def alive?: () -> bool
|
|
231
|
+
|
|
232
|
+
# <!--
|
|
233
|
+
# rdoc-file=cont.c
|
|
234
|
+
# - fiber.backtrace -> array
|
|
235
|
+
# - fiber.backtrace(start) -> array
|
|
236
|
+
# - fiber.backtrace(start, count) -> array
|
|
237
|
+
# - fiber.backtrace(start..end) -> array
|
|
238
|
+
# -->
|
|
239
|
+
# Returns the current execution stack of the fiber. `start`, `count` and `end`
|
|
240
|
+
# allow to select only parts of the backtrace.
|
|
241
|
+
#
|
|
242
|
+
# def level3
|
|
243
|
+
# Fiber.yield
|
|
244
|
+
# end
|
|
127
245
|
#
|
|
128
|
-
def
|
|
246
|
+
# def level2
|
|
247
|
+
# level3
|
|
248
|
+
# end
|
|
249
|
+
#
|
|
250
|
+
# def level1
|
|
251
|
+
# level2
|
|
252
|
+
# end
|
|
253
|
+
#
|
|
254
|
+
# f = Fiber.new { level1 }
|
|
255
|
+
#
|
|
256
|
+
# # It is empty before the fiber started
|
|
257
|
+
# f.backtrace
|
|
258
|
+
# #=> []
|
|
259
|
+
#
|
|
260
|
+
# f.resume
|
|
261
|
+
#
|
|
262
|
+
# f.backtrace
|
|
263
|
+
# #=> ["test.rb:2:in `yield'", "test.rb:2:in `level3'", "test.rb:6:in `level2'", "test.rb:10:in `level1'", "test.rb:13:in `block in <main>'"]
|
|
264
|
+
# p f.backtrace(1) # start from the item 1
|
|
265
|
+
# #=> ["test.rb:2:in `level3'", "test.rb:6:in `level2'", "test.rb:10:in `level1'", "test.rb:13:in `block in <main>'"]
|
|
266
|
+
# p f.backtrace(2, 2) # start from item 2, take 2
|
|
267
|
+
# #=> ["test.rb:6:in `level2'", "test.rb:10:in `level1'"]
|
|
268
|
+
# p f.backtrace(1..3) # take items from 1 to 3
|
|
269
|
+
# #=> ["test.rb:2:in `level3'", "test.rb:6:in `level2'", "test.rb:10:in `level1'"]
|
|
270
|
+
#
|
|
271
|
+
# f.resume
|
|
272
|
+
#
|
|
273
|
+
# # It is nil after the fiber is finished
|
|
274
|
+
# f.backtrace
|
|
275
|
+
# #=> nil
|
|
276
|
+
#
|
|
277
|
+
def backtrace: (?Integer start, ?Integer count) -> Array[String]?
|
|
278
|
+
| (Range[Integer]) -> Array[String]?
|
|
279
|
+
|
|
280
|
+
# <!--
|
|
281
|
+
# rdoc-file=cont.c
|
|
282
|
+
# - fiber.backtrace_locations -> array
|
|
283
|
+
# - fiber.backtrace_locations(start) -> array
|
|
284
|
+
# - fiber.backtrace_locations(start, count) -> array
|
|
285
|
+
# - fiber.backtrace_locations(start..end) -> array
|
|
286
|
+
# -->
|
|
287
|
+
# Like #backtrace, but returns each line of the execution stack as a
|
|
288
|
+
# Thread::Backtrace::Location. Accepts the same arguments as #backtrace.
|
|
289
|
+
#
|
|
290
|
+
# f = Fiber.new { Fiber.yield }
|
|
291
|
+
# f.resume
|
|
292
|
+
# loc = f.backtrace_locations.first
|
|
293
|
+
# loc.label #=> "yield"
|
|
294
|
+
# loc.path #=> "test.rb"
|
|
295
|
+
# loc.lineno #=> 1
|
|
296
|
+
#
|
|
297
|
+
def backtrace_locations: (?Integer start, ?Integer count) -> Array[Thread::Backtrace::Location]?
|
|
298
|
+
| (Range[Integer]) -> Array[Thread::Backtrace::Location]?
|
|
299
|
+
|
|
300
|
+
# <!--
|
|
301
|
+
# rdoc-file=cont.c
|
|
302
|
+
# - fiber.blocking? -> true or false
|
|
303
|
+
# -->
|
|
304
|
+
# Returns `true` if `fiber` is blocking and `false` otherwise. Fiber is
|
|
305
|
+
# non-blocking if it was created via passing `blocking: false` to Fiber.new, or
|
|
306
|
+
# via Fiber.schedule.
|
|
307
|
+
#
|
|
308
|
+
# Note that, even if the method returns `false`, the fiber behaves differently
|
|
309
|
+
# only if Fiber.scheduler is set in the current thread.
|
|
310
|
+
#
|
|
311
|
+
# See the "Non-blocking fibers" section in class docs for details.
|
|
312
|
+
#
|
|
313
|
+
def blocking?: () -> bool
|
|
314
|
+
|
|
315
|
+
# <!--
|
|
316
|
+
# rdoc-file=cont.c
|
|
317
|
+
# - inspect()
|
|
318
|
+
# -->
|
|
319
|
+
#
|
|
320
|
+
alias inspect to_s
|
|
129
321
|
|
|
130
322
|
# <!--
|
|
131
323
|
# rdoc-file=cont.c
|
|
@@ -147,7 +339,105 @@ class Fiber < Object
|
|
|
147
339
|
# parameter is an array of callback information. Exceptions are caught by the
|
|
148
340
|
# `rescue` clause of `begin...end` blocks.
|
|
149
341
|
#
|
|
150
|
-
def raise: () -> untyped
|
|
151
|
-
| (string
|
|
152
|
-
|
|
342
|
+
def raise: (?string msg) -> untyped
|
|
343
|
+
| (_Exception, ?string msg, ?Array[string] backtrace) -> untyped
|
|
344
|
+
|
|
345
|
+
# <!--
|
|
346
|
+
# rdoc-file=cont.c
|
|
347
|
+
# - fiber.resume(args, ...) -> obj
|
|
348
|
+
# -->
|
|
349
|
+
# Resumes the fiber from the point at which the last Fiber.yield was called, or
|
|
350
|
+
# starts running it if it is the first call to #resume. Arguments passed to
|
|
351
|
+
# resume will be the value of the Fiber.yield expression or will be passed as
|
|
352
|
+
# block parameters to the fiber's block if this is the first #resume.
|
|
353
|
+
#
|
|
354
|
+
# Alternatively, when resume is called it evaluates to the arguments passed to
|
|
355
|
+
# the next Fiber.yield statement inside the fiber's block or to the block value
|
|
356
|
+
# if it runs to completion without any Fiber.yield
|
|
357
|
+
#
|
|
358
|
+
def resume: (*untyped) -> untyped
|
|
359
|
+
|
|
360
|
+
# <!--
|
|
361
|
+
# rdoc-file=cont.c
|
|
362
|
+
# - to_s()
|
|
363
|
+
# -->
|
|
364
|
+
#
|
|
365
|
+
def to_s: () -> untyped
|
|
366
|
+
|
|
367
|
+
# <!--
|
|
368
|
+
# rdoc-file=cont.c
|
|
369
|
+
# - fiber.transfer(args, ...) -> obj
|
|
370
|
+
# -->
|
|
371
|
+
# Transfer control to another fiber, resuming it from where it last stopped or
|
|
372
|
+
# starting it if it was not resumed before. The calling fiber will be suspended
|
|
373
|
+
# much like in a call to Fiber.yield.
|
|
374
|
+
#
|
|
375
|
+
# The fiber which receives the transfer call treats it much like a resume call.
|
|
376
|
+
# Arguments passed to transfer are treated like those passed to resume.
|
|
377
|
+
#
|
|
378
|
+
# The two style of control passing to and from fiber (one is #resume and
|
|
379
|
+
# Fiber::yield, another is #transfer to and from fiber) can't be freely mixed.
|
|
380
|
+
#
|
|
381
|
+
# * If the Fiber's lifecycle had started with transfer, it will never be able
|
|
382
|
+
# to yield or be resumed control passing, only finish or transfer back. (It
|
|
383
|
+
# still can resume other fibers that are allowed to be resumed.)
|
|
384
|
+
# * If the Fiber's lifecycle had started with resume, it can yield or transfer
|
|
385
|
+
# to another Fiber, but can receive control back only the way compatible
|
|
386
|
+
# with the way it was given away: if it had transferred, it only can be
|
|
387
|
+
# transferred back, and if it had yielded, it only can be resumed back.
|
|
388
|
+
# After that, it again can transfer or yield.
|
|
389
|
+
#
|
|
390
|
+
#
|
|
391
|
+
# If those rules are broken FiberError is raised.
|
|
392
|
+
#
|
|
393
|
+
# For an individual Fiber design, yield/resume is easier to use (the Fiber just
|
|
394
|
+
# gives away control, it doesn't need to think about who the control is given
|
|
395
|
+
# to), while transfer is more flexible for complex cases, allowing to build
|
|
396
|
+
# arbitrary graphs of Fibers dependent on each other.
|
|
397
|
+
#
|
|
398
|
+
# Example:
|
|
399
|
+
#
|
|
400
|
+
# manager = nil # For local var to be visible inside worker block
|
|
401
|
+
#
|
|
402
|
+
# # This fiber would be started with transfer
|
|
403
|
+
# # It can't yield, and can't be resumed
|
|
404
|
+
# worker = Fiber.new { |work|
|
|
405
|
+
# puts "Worker: starts"
|
|
406
|
+
# puts "Worker: Performed #{work.inspect}, transferring back"
|
|
407
|
+
# # Fiber.yield # this would raise FiberError: attempt to yield on a not resumed fiber
|
|
408
|
+
# # manager.resume # this would raise FiberError: attempt to resume a resumed fiber (double resume)
|
|
409
|
+
# manager.transfer(work.capitalize)
|
|
410
|
+
# }
|
|
411
|
+
#
|
|
412
|
+
# # This fiber would be started with resume
|
|
413
|
+
# # It can yield or transfer, and can be transferred
|
|
414
|
+
# # back or resumed
|
|
415
|
+
# manager = Fiber.new {
|
|
416
|
+
# puts "Manager: starts"
|
|
417
|
+
# puts "Manager: transferring 'something' to worker"
|
|
418
|
+
# result = worker.transfer('something')
|
|
419
|
+
# puts "Manager: worker returned #{result.inspect}"
|
|
420
|
+
# # worker.resume # this would raise FiberError: attempt to resume a transferring fiber
|
|
421
|
+
# Fiber.yield # this is OK, the fiber transferred from and to, now it can yield
|
|
422
|
+
# puts "Manager: finished"
|
|
423
|
+
# }
|
|
424
|
+
#
|
|
425
|
+
# puts "Starting the manager"
|
|
426
|
+
# manager.resume
|
|
427
|
+
# puts "Resuming the manager"
|
|
428
|
+
# # manager.transfer # this would raise FiberError: attempt to transfer to a yielding fiber
|
|
429
|
+
# manager.resume
|
|
430
|
+
#
|
|
431
|
+
# *produces*
|
|
432
|
+
#
|
|
433
|
+
# Starting the manager
|
|
434
|
+
# Manager: starts
|
|
435
|
+
# Manager: transferring 'something' to worker
|
|
436
|
+
# Worker: starts
|
|
437
|
+
# Worker: Performed "something", transferring back
|
|
438
|
+
# Manager: worker returned "Something"
|
|
439
|
+
# Resuming the manager
|
|
440
|
+
# Manager: finished
|
|
441
|
+
#
|
|
442
|
+
def transfer: (*untyped) -> untyped
|
|
153
443
|
end
|
data/core/float.rbs
CHANGED
data/core/io.rbs
CHANGED
|
@@ -2383,6 +2383,100 @@ class IO < Object
|
|
|
2383
2383
|
#
|
|
2384
2384
|
def self.popen: (*untyped args) -> untyped
|
|
2385
2385
|
|
|
2386
|
+
# <!--
|
|
2387
|
+
# rdoc-file=io.c
|
|
2388
|
+
# - IO.foreach(name, sep=$/ [, getline_args, open_args]) {|line| block } -> nil
|
|
2389
|
+
# - IO.foreach(name, limit [, getline_args, open_args]) {|line| block } -> nil
|
|
2390
|
+
# - IO.foreach(name, sep, limit [, getline_args, open_args]) {|line| block } -> nil
|
|
2391
|
+
# - IO.foreach(...) -> an_enumerator
|
|
2392
|
+
# - File.foreach(name, sep=$/ [, getline_args, open_args]) {|line| block } -> nil
|
|
2393
|
+
# - File.foreach(name, limit [, getline_args, open_args]) {|line| block } -> nil
|
|
2394
|
+
# - File.foreach(name, sep, limit [, getline_args, open_args]) {|line| block } -> nil
|
|
2395
|
+
# - File.foreach(...) -> an_enumerator
|
|
2396
|
+
# -->
|
|
2397
|
+
# Executes the block for every line in the named I/O port, where lines are
|
|
2398
|
+
# separated by *sep*.
|
|
2399
|
+
#
|
|
2400
|
+
# If no block is given, an enumerator is returned instead.
|
|
2401
|
+
#
|
|
2402
|
+
# If `name` starts with a pipe character (`"|"`) and the receiver is the IO
|
|
2403
|
+
# class, a subprocess is created in the same way as Kernel#open, and its output
|
|
2404
|
+
# is returned. Consider to use File.foreach to disable the behavior of
|
|
2405
|
+
# subprocess invocation.
|
|
2406
|
+
#
|
|
2407
|
+
# File.foreach("testfile") {|x| print "GOT ", x }
|
|
2408
|
+
# IO.foreach("| cat testfile") {|x| print "GOT ", x }
|
|
2409
|
+
#
|
|
2410
|
+
# *produces:*
|
|
2411
|
+
#
|
|
2412
|
+
# GOT This is line one
|
|
2413
|
+
# GOT This is line two
|
|
2414
|
+
# GOT This is line three
|
|
2415
|
+
# GOT And so on...
|
|
2416
|
+
#
|
|
2417
|
+
# If the last argument is a hash, it's the keyword argument to open. See
|
|
2418
|
+
# IO.readlines for details about getline_args. And see also IO.read for details
|
|
2419
|
+
# about open_args.
|
|
2420
|
+
#
|
|
2421
|
+
def self.foreach: (string | _ToPath path, ?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, ?chomp: boolish) { (String line) -> void } -> nil
|
|
2422
|
+
| (string | _ToPath path, ?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, ?chomp: boolish) -> ::Enumerator[String, nil]
|
|
2423
|
+
|
|
2424
|
+
# <!--
|
|
2425
|
+
# rdoc-file=io.c
|
|
2426
|
+
# - IO.pipe -> [read_io, write_io]
|
|
2427
|
+
# - IO.pipe(ext_enc) -> [read_io, write_io]
|
|
2428
|
+
# - IO.pipe("ext_enc:int_enc" [, opt]) -> [read_io, write_io]
|
|
2429
|
+
# - IO.pipe(ext_enc, int_enc [, opt]) -> [read_io, write_io]
|
|
2430
|
+
# - IO.pipe(...) {|read_io, write_io| ... }
|
|
2431
|
+
# -->
|
|
2432
|
+
# Creates a pair of pipe endpoints (connected to each other) and returns them as
|
|
2433
|
+
# a two-element array of IO objects: `[` *read_io*, *write_io* `]`.
|
|
2434
|
+
#
|
|
2435
|
+
# If a block is given, the block is called and returns the value of the block.
|
|
2436
|
+
# *read_io* and *write_io* are sent to the block as arguments. If read_io and
|
|
2437
|
+
# write_io are not closed when the block exits, they are closed. i.e. closing
|
|
2438
|
+
# read_io and/or write_io doesn't cause an error.
|
|
2439
|
+
#
|
|
2440
|
+
# Not available on all platforms.
|
|
2441
|
+
#
|
|
2442
|
+
# If an encoding (encoding name or encoding object) is specified as an optional
|
|
2443
|
+
# argument, read string from pipe is tagged with the encoding specified. If the
|
|
2444
|
+
# argument is a colon separated two encoding names "A:B", the read string is
|
|
2445
|
+
# converted from encoding A (external encoding) to encoding B (internal
|
|
2446
|
+
# encoding), then tagged with B. If two optional arguments are specified, those
|
|
2447
|
+
# must be encoding objects or encoding names, and the first one is the external
|
|
2448
|
+
# encoding, and the second one is the internal encoding. If the external
|
|
2449
|
+
# encoding and the internal encoding is specified, optional hash argument
|
|
2450
|
+
# specify the conversion option.
|
|
2451
|
+
#
|
|
2452
|
+
# In the example below, the two processes close the ends of the pipe that they
|
|
2453
|
+
# are not using. This is not just a cosmetic nicety. The read end of a pipe will
|
|
2454
|
+
# not generate an end of file condition if there are any writers with the pipe
|
|
2455
|
+
# still open. In the case of the parent process, the `rd.read` will never return
|
|
2456
|
+
# if it does not first issue a `wr.close`.
|
|
2457
|
+
#
|
|
2458
|
+
# rd, wr = IO.pipe
|
|
2459
|
+
#
|
|
2460
|
+
# if fork
|
|
2461
|
+
# wr.close
|
|
2462
|
+
# puts "Parent got: <#{rd.read}>"
|
|
2463
|
+
# rd.close
|
|
2464
|
+
# Process.wait
|
|
2465
|
+
# else
|
|
2466
|
+
# rd.close
|
|
2467
|
+
# puts "Sending message to parent"
|
|
2468
|
+
# wr.write "Hi Dad"
|
|
2469
|
+
# wr.close
|
|
2470
|
+
# end
|
|
2471
|
+
#
|
|
2472
|
+
# *produces:*
|
|
2473
|
+
#
|
|
2474
|
+
# Sending message to parent
|
|
2475
|
+
# Parent got: <Hi Dad>
|
|
2476
|
+
#
|
|
2477
|
+
def self.pipe: (?String | Encoding ext_or_ext_int_enc, ?String | Encoding int_enc, ?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, ?chomp: boolish) -> [IO, IO]
|
|
2478
|
+
| [X] (?String | Encoding ext_or_ext_int_enc, ?String | Encoding int_enc, ?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, ?chomp: boolish) { (IO read_io, IO write_io) -> X } -> X
|
|
2479
|
+
|
|
2386
2480
|
# <!--
|
|
2387
2481
|
# rdoc-file=io.c
|
|
2388
2482
|
# - IO.read(name, [length [, offset]] [, opt]) -> string
|
|
@@ -2469,7 +2563,7 @@ class IO < Object
|
|
|
2469
2563
|
#
|
|
2470
2564
|
# See also IO.read for details about `name` and open_args.
|
|
2471
2565
|
#
|
|
2472
|
-
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, ?chomp: boolish) -> ::Array[String]
|
|
2566
|
+
def self.readlines: (String | _ToPath 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, ?chomp: boolish) -> ::Array[String]
|
|
2473
2567
|
|
|
2474
2568
|
# <!--
|
|
2475
2569
|
# rdoc-file=io.c
|
data/core/kernel.rbs
CHANGED
|
@@ -2135,7 +2135,7 @@ module Kernel : BasicObject
|
|
|
2135
2135
|
# :experimental
|
|
2136
2136
|
# : Used for experimental features that may change in future releases.
|
|
2137
2137
|
#
|
|
2138
|
-
def self?.warn: (*untyped msg, ?uplevel: Integer | nil) -> NilClass
|
|
2138
|
+
def self?.warn: (*untyped msg, ?uplevel: Integer | nil, ?category: :deprecated | :experimental | nil) -> NilClass
|
|
2139
2139
|
|
|
2140
2140
|
# <!--
|
|
2141
2141
|
# rdoc-file=process.c
|