rbs 0.13.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +9 -5
- data/.gitignore +0 -1
- data/CHANGELOG.md +33 -1
- data/Gemfile +4 -0
- data/README.md +9 -3
- data/Rakefile +14 -1
- data/Steepfile +1 -1
- data/bin/annotate-with-rdoc +1 -1
- data/bin/setup +0 -2
- data/bin/test_runner.rb +15 -1
- data/{stdlib/builtin → core}/array.rbs +124 -120
- data/{stdlib/builtin → core}/basic_object.rbs +54 -54
- data/{stdlib/builtin → core}/binding.rbs +42 -42
- data/core/builtin.rbs +70 -0
- data/{stdlib/builtin → core}/class.rbs +33 -33
- data/{stdlib/builtin → core}/comparable.rbs +0 -0
- data/{stdlib/builtin → core}/complex.rbs +90 -90
- data/{stdlib/builtin → core}/constants.rbs +0 -0
- data/{stdlib/builtin → core}/data.rbs +0 -0
- data/{stdlib/builtin → core}/deprecated.rbs +0 -0
- data/{stdlib/builtin → core}/dir.rbs +1 -1
- data/{stdlib/builtin → core}/encoding.rbs +33 -33
- data/{stdlib/builtin → core}/enumerable.rbs +99 -92
- data/{stdlib/builtin → core}/enumerator.rbs +40 -40
- data/{stdlib/builtin → core}/errno.rbs +0 -0
- data/{stdlib/builtin → core}/errors.rbs +2 -2
- data/{stdlib/builtin → core}/exception.rbs +50 -50
- data/{stdlib/builtin → core}/false_class.rbs +6 -6
- data/{stdlib/builtin → core}/fiber.rbs +14 -14
- data/{stdlib/builtin → core}/fiber_error.rbs +1 -1
- data/{stdlib/builtin → core}/file.rbs +0 -0
- data/{stdlib/builtin → core}/file_test.rbs +0 -0
- data/{stdlib/builtin → core}/float.rbs +161 -161
- data/{stdlib/builtin → core}/gc.rbs +3 -3
- data/{stdlib/builtin → core}/hash.rbs +15 -15
- data/{stdlib/builtin → core}/integer.rbs +0 -0
- data/{stdlib/builtin → core}/io.rbs +89 -89
- data/{stdlib/builtin → core}/kernel.rbs +70 -154
- data/{stdlib/builtin → core}/marshal.rbs +0 -0
- data/{stdlib/builtin → core}/match_data.rbs +1 -1
- data/{stdlib/builtin → core}/math.rbs +0 -0
- data/{stdlib/builtin → core}/method.rbs +19 -19
- data/{stdlib/builtin → core}/module.rbs +13 -13
- data/{stdlib/builtin → core}/nil_class.rbs +20 -20
- data/{stdlib/builtin → core}/numeric.rbs +101 -101
- data/{stdlib/builtin → core}/object.rbs +173 -173
- data/{stdlib/builtin → core}/proc.rbs +91 -91
- data/{stdlib/builtin → core}/process.rbs +0 -0
- data/{stdlib/builtin → core}/random.rbs +1 -1
- data/{stdlib/builtin → core}/range.rbs +4 -6
- data/{stdlib/builtin → core}/rational.rbs +83 -83
- data/{stdlib/builtin → core}/rb_config.rbs +0 -0
- data/{stdlib/builtin → core}/regexp.rbs +0 -0
- data/{stdlib/builtin → core}/ruby_vm.rbs +0 -0
- data/{stdlib/builtin → core}/signal.rbs +7 -7
- data/{stdlib/builtin → core}/string.rbs +10 -10
- data/{stdlib/builtin → core}/string_io.rbs +8 -8
- data/{stdlib/builtin → core}/struct.rbs +2 -2
- data/{stdlib/builtin → core}/symbol.rbs +1 -1
- data/{stdlib/builtin → core}/thread.rbs +189 -189
- data/{stdlib/builtin → core}/thread_group.rbs +2 -2
- data/{stdlib/builtin → core}/time.rbs +0 -0
- data/{stdlib/builtin → core}/trace_point.rbs +0 -0
- data/{stdlib/builtin → core}/true_class.rbs +10 -10
- data/{stdlib/builtin → core}/unbound_method.rbs +0 -0
- data/{stdlib/builtin → core}/warning.rbs +1 -1
- data/docs/CONTRIBUTING.md +1 -0
- data/docs/repo.md +125 -0
- data/docs/syntax.md +50 -6
- data/goodcheck.yml +22 -5
- data/lib/rbs.rb +1 -0
- data/lib/rbs/ast/comment.rb +1 -1
- data/lib/rbs/cli.rb +105 -103
- data/lib/rbs/definition.rb +9 -4
- data/lib/rbs/definition_builder.rb +54 -22
- data/lib/rbs/environment.rb +1 -1
- data/lib/rbs/environment_loader.rb +79 -105
- data/lib/rbs/namespace.rb +1 -1
- data/lib/rbs/parser.rb +3153 -0
- data/lib/rbs/parser.y +25 -11
- data/lib/rbs/prototype/rb.rb +47 -9
- data/lib/rbs/prototype/runtime.rb +17 -7
- data/lib/rbs/repository.rb +121 -0
- data/lib/rbs/test/hook.rb +2 -0
- data/lib/rbs/test/setup.rb +5 -3
- data/lib/rbs/test/setup_helper.rb +4 -4
- data/lib/rbs/test/tester.rb +4 -1
- data/lib/rbs/test/type_check.rb +12 -6
- data/lib/rbs/type_name.rb +3 -2
- data/lib/rbs/variance_calculator.rb +1 -1
- data/lib/rbs/vendorer.rb +38 -16
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +1 -1
- data/sig/cli.rbs +58 -0
- data/sig/constant.rbs +2 -2
- data/sig/constant_table.rbs +11 -11
- data/sig/declarations.rbs +2 -2
- data/sig/definition.rbs +10 -5
- data/sig/definition_builder.rbs +4 -1
- data/sig/environment_loader.rbs +92 -46
- data/sig/members.rbs +2 -2
- data/sig/method_types.rbs +1 -1
- data/sig/namespace.rbs +4 -4
- data/sig/parser.rbs +25 -0
- data/sig/polyfill.rbs +42 -0
- data/sig/rbs.rbs +8 -0
- data/sig/repository.rbs +79 -0
- data/sig/substitution.rbs +3 -3
- data/sig/typename.rbs +1 -1
- data/sig/types.rbs +1 -1
- data/sig/vendorer.rbs +44 -0
- data/sig/writer.rbs +15 -15
- data/stdlib/abbrev/{abbrev.rbs → 0/abbrev.rbs} +0 -0
- data/stdlib/base64/{base64.rbs → 0/base64.rbs} +1 -1
- data/stdlib/benchmark/{benchmark.rbs → 0/benchmark.rbs} +2 -2
- data/stdlib/{bigdecimal/math → bigdecimal-math/0}/big_math.rbs +0 -0
- data/stdlib/bigdecimal/{big_decimal.rbs → 0/big_decimal.rbs} +0 -0
- data/stdlib/coverage/{coverage.rbs → 0/coverage.rbs} +2 -2
- data/stdlib/csv/{csv.rbs → 0/csv.rbs} +4 -4
- data/stdlib/date/{date.rbs → 0/date.rbs} +4 -4
- data/stdlib/date/{date_time.rbs → 0/date_time.rbs} +1 -1
- data/stdlib/dbm/0/dbm.rbs +277 -0
- data/stdlib/erb/{erb.rbs → 0/erb.rbs} +0 -0
- data/stdlib/fiber/{fiber.rbs → 0/fiber.rbs} +0 -0
- data/stdlib/find/{find.rbs → 0/find.rbs} +12 -12
- data/stdlib/forwardable/{forwardable.rbs → 0/forwardable.rbs} +0 -0
- data/stdlib/ipaddr/{ipaddr.rbs → 0/ipaddr.rbs} +0 -0
- data/stdlib/json/{json.rbs → 0/json.rbs} +0 -0
- data/stdlib/logger/{formatter.rbs → 0/formatter.rbs} +0 -0
- data/stdlib/logger/{log_device.rbs → 0/log_device.rbs} +1 -1
- data/stdlib/logger/{logger.rbs → 0/logger.rbs} +1 -1
- data/stdlib/logger/{period.rbs → 0/period.rbs} +0 -0
- data/stdlib/logger/{severity.rbs → 0/severity.rbs} +0 -0
- data/stdlib/mutex_m/{mutex_m.rbs → 0/mutex_m.rbs} +0 -0
- data/stdlib/pathname/{pathname.rbs → 0/pathname.rbs} +40 -40
- data/stdlib/prime/{integer-extension.rbs → 0/integer-extension.rbs} +0 -0
- data/stdlib/prime/{prime.rbs → 0/prime.rbs} +1 -1
- data/stdlib/pstore/0/pstore.rbs +287 -0
- data/stdlib/pty/{pty.rbs → 0/pty.rbs} +1 -1
- data/stdlib/securerandom/{securerandom.rbs → 0/securerandom.rbs} +0 -0
- data/stdlib/set/{set.rbs → 0/set.rbs} +10 -10
- data/stdlib/tmpdir/{tmpdir.rbs → 0/tmpdir.rbs} +12 -12
- data/stdlib/tsort/0/cyclic.rbs +4 -0
- data/stdlib/tsort/0/interfaces.rbs +19 -0
- data/stdlib/tsort/0/tsort.rbs +363 -0
- data/stdlib/uri/{file.rbs → 0/file.rbs} +0 -0
- data/stdlib/uri/{generic.rbs → 0/generic.rbs} +1 -1
- data/stdlib/uri/{http.rbs → 0/http.rbs} +0 -0
- data/stdlib/uri/{https.rbs → 0/https.rbs} +0 -0
- data/stdlib/uri/{ldap.rbs → 0/ldap.rbs} +0 -0
- data/stdlib/uri/{ldaps.rbs → 0/ldaps.rbs} +0 -0
- data/stdlib/zlib/{zlib.rbs → 0/zlib.rbs} +0 -0
- data/steep/Gemfile.lock +9 -9
- metadata +104 -93
- data/stdlib/builtin/builtin.rbs +0 -42
@@ -0,0 +1,19 @@
|
|
1
|
+
module TSort[Node]
|
2
|
+
interface _Sortable[Node]
|
3
|
+
# #tsort_each_node is used to iterate for all nodes over a graph.
|
4
|
+
#
|
5
|
+
def tsort_each_node: () { (Node) -> void } -> void
|
6
|
+
|
7
|
+
# #tsort_each_child is used to iterate for child nodes of node.
|
8
|
+
#
|
9
|
+
def tsort_each_child: (Node) { (Node) -> void } -> void
|
10
|
+
end
|
11
|
+
|
12
|
+
interface _EachNode[Node]
|
13
|
+
def call: () { (Node) -> void } -> void
|
14
|
+
end
|
15
|
+
|
16
|
+
interface _EachChild[Node]
|
17
|
+
def call: (Node) { (Node) -> void } -> void
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,363 @@
|
|
1
|
+
# TSort implements topological sorting using Tarjan's algorithm for strongly
|
2
|
+
# connected components.
|
3
|
+
#
|
4
|
+
# TSort is designed to be able to be used with any object which can be
|
5
|
+
# interpreted as a directed graph.
|
6
|
+
#
|
7
|
+
# TSort requires two methods to interpret an object as a graph, tsort_each_node
|
8
|
+
# and tsort_each_child.
|
9
|
+
#
|
10
|
+
# * tsort_each_node is used to iterate for all nodes over a graph.
|
11
|
+
# * tsort_each_child is used to iterate for child nodes of a given node.
|
12
|
+
#
|
13
|
+
#
|
14
|
+
# The equality of nodes are defined by eql? and hash since TSort uses Hash
|
15
|
+
# internally.
|
16
|
+
#
|
17
|
+
# ## A Simple Example
|
18
|
+
#
|
19
|
+
# The following example demonstrates how to mix the TSort module into an
|
20
|
+
# existing class (in this case, Hash). Here, we're treating each key in the hash
|
21
|
+
# as a node in the graph, and so we simply alias the required #tsort_each_node
|
22
|
+
# method to Hash's #each_key method. For each key in the hash, the associated
|
23
|
+
# value is an array of the node's child nodes. This choice in turn leads to our
|
24
|
+
# implementation of the required #tsort_each_child method, which fetches the
|
25
|
+
# array of child nodes and then iterates over that array using the user-supplied
|
26
|
+
# block.
|
27
|
+
#
|
28
|
+
# require 'tsort'
|
29
|
+
#
|
30
|
+
# class Hash
|
31
|
+
# include TSort
|
32
|
+
# alias tsort_each_node each_key
|
33
|
+
# def tsort_each_child(node, &block)
|
34
|
+
# fetch(node).each(&block)
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# {1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort
|
39
|
+
# #=> [3, 2, 1, 4]
|
40
|
+
#
|
41
|
+
# {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_components
|
42
|
+
# #=> [[4], [2, 3], [1]]
|
43
|
+
#
|
44
|
+
# ## A More Realistic Example
|
45
|
+
#
|
46
|
+
# A very simple `make' like tool can be implemented as follows:
|
47
|
+
#
|
48
|
+
# require 'tsort'
|
49
|
+
#
|
50
|
+
# class Make
|
51
|
+
# def initialize
|
52
|
+
# @dep = {}
|
53
|
+
# @dep.default = []
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# def rule(outputs, inputs=[], &block)
|
57
|
+
# triple = [outputs, inputs, block]
|
58
|
+
# outputs.each {|f| @dep[f] = [triple]}
|
59
|
+
# @dep[triple] = inputs
|
60
|
+
# end
|
61
|
+
#
|
62
|
+
# def build(target)
|
63
|
+
# each_strongly_connected_component_from(target) {|ns|
|
64
|
+
# if ns.length != 1
|
65
|
+
# fs = ns.delete_if {|n| Array === n}
|
66
|
+
# raise TSort::Cyclic.new("cyclic dependencies: #{fs.join ', '}")
|
67
|
+
# end
|
68
|
+
# n = ns.first
|
69
|
+
# if Array === n
|
70
|
+
# outputs, inputs, block = n
|
71
|
+
# inputs_time = inputs.map {|f| File.mtime f}.max
|
72
|
+
# begin
|
73
|
+
# outputs_time = outputs.map {|f| File.mtime f}.min
|
74
|
+
# rescue Errno::ENOENT
|
75
|
+
# outputs_time = nil
|
76
|
+
# end
|
77
|
+
# if outputs_time == nil ||
|
78
|
+
# inputs_time != nil && outputs_time <= inputs_time
|
79
|
+
# sleep 1 if inputs_time != nil && inputs_time.to_i == Time.now.to_i
|
80
|
+
# block.call
|
81
|
+
# end
|
82
|
+
# end
|
83
|
+
# }
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# def tsort_each_child(node, &block)
|
87
|
+
# @dep[node].each(&block)
|
88
|
+
# end
|
89
|
+
# include TSort
|
90
|
+
# end
|
91
|
+
#
|
92
|
+
# def command(arg)
|
93
|
+
# print arg, "\n"
|
94
|
+
# system arg
|
95
|
+
# end
|
96
|
+
#
|
97
|
+
# m = Make.new
|
98
|
+
# m.rule(%w[t1]) { command 'date > t1' }
|
99
|
+
# m.rule(%w[t2]) { command 'date > t2' }
|
100
|
+
# m.rule(%w[t3]) { command 'date > t3' }
|
101
|
+
# m.rule(%w[t4], %w[t1 t3]) { command 'cat t1 t3 > t4' }
|
102
|
+
# m.rule(%w[t5], %w[t4 t2]) { command 'cat t4 t2 > t5' }
|
103
|
+
# m.build('t5')
|
104
|
+
#
|
105
|
+
# ## Bugs
|
106
|
+
#
|
107
|
+
# * 'tsort.rb' is wrong name because this library uses Tarjan's algorithm for
|
108
|
+
# strongly connected components. Although 'strongly_connected_components.rb'
|
109
|
+
# is correct but too long.
|
110
|
+
#
|
111
|
+
#
|
112
|
+
# ## References
|
113
|
+
#
|
114
|
+
# 1. Tarjan, "Depth First Search and Linear Graph Algorithms",
|
115
|
+
#
|
116
|
+
#
|
117
|
+
# *SIAM Journal on Computing*, Vol. 1, No. 2, pp. 146-160, June 1972.
|
118
|
+
module TSort[Node] : TSort::_Sortable[Node]
|
119
|
+
# The iterator version of the TSort.strongly_connected_components method.
|
120
|
+
#
|
121
|
+
# The graph is represented by *each_node* and *each_child*. *each_node* should
|
122
|
+
# have `call` method which yields for each node in the graph. *each_child*
|
123
|
+
# should have `call` method which takes a node argument and yields for each
|
124
|
+
# child node.
|
125
|
+
#
|
126
|
+
# g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
|
127
|
+
# each_node = lambda {|&b| g.each_key(&b) }
|
128
|
+
# each_child = lambda {|n, &b| g[n].each(&b) }
|
129
|
+
# TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc }
|
130
|
+
# #=> [4]
|
131
|
+
# # [2]
|
132
|
+
# # [3]
|
133
|
+
# # [1]
|
134
|
+
#
|
135
|
+
# g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
|
136
|
+
# each_node = lambda {|&b| g.each_key(&b) }
|
137
|
+
# each_child = lambda {|n, &b| g[n].each(&b) }
|
138
|
+
# TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc }
|
139
|
+
# #=> [4]
|
140
|
+
# # [2, 3]
|
141
|
+
# # [1]
|
142
|
+
#
|
143
|
+
def self.each_strongly_connected_component: [T] (_EachNode[T] each_node, _EachChild[T] each_child) { (Array[T]) -> void } -> void
|
144
|
+
| [T] (_EachNode[T] each_node, _EachChild[T] each_child) -> Enumerator[Array[T], void]
|
145
|
+
|
146
|
+
# Iterates over strongly connected components in a graph. The graph is
|
147
|
+
# represented by *node* and *each_child*.
|
148
|
+
#
|
149
|
+
# *node* is the first node. *each_child* should have `call` method which takes a
|
150
|
+
# node argument and yields for each child node.
|
151
|
+
#
|
152
|
+
# Return value is unspecified.
|
153
|
+
#
|
154
|
+
# #TSort.each_strongly_connected_component_from is a class method and it doesn't
|
155
|
+
# need a class to represent a graph which includes TSort.
|
156
|
+
#
|
157
|
+
# graph = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
|
158
|
+
# each_child = lambda {|n, &b| graph[n].each(&b) }
|
159
|
+
# TSort.each_strongly_connected_component_from(1, each_child) {|scc|
|
160
|
+
# p scc
|
161
|
+
# }
|
162
|
+
# #=> [4]
|
163
|
+
# # [2, 3]
|
164
|
+
# # [1]
|
165
|
+
#
|
166
|
+
def self.each_strongly_connected_component_from: [T] (T node, _EachChild[T] each_child, ?untyped id_map, ?untyped stack) { (Array[T]) -> void } -> void
|
167
|
+
| [T] (T node, _EachChild[T] each_child, ?untyped id_map, ?untyped stack) -> Enumerator[Array[T], void]
|
168
|
+
|
169
|
+
# Returns strongly connected components as an array of arrays of nodes. The
|
170
|
+
# array is sorted from children to parents. Each elements of the array
|
171
|
+
# represents a strongly connected component.
|
172
|
+
#
|
173
|
+
# The graph is represented by *each_node* and *each_child*. *each_node* should
|
174
|
+
# have `call` method which yields for each node in the graph. *each_child*
|
175
|
+
# should have `call` method which takes a node argument and yields for each
|
176
|
+
# child node.
|
177
|
+
#
|
178
|
+
# g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
|
179
|
+
# each_node = lambda {|&b| g.each_key(&b) }
|
180
|
+
# each_child = lambda {|n, &b| g[n].each(&b) }
|
181
|
+
# p TSort.strongly_connected_components(each_node, each_child)
|
182
|
+
# #=> [[4], [2], [3], [1]]
|
183
|
+
#
|
184
|
+
# g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
|
185
|
+
# each_node = lambda {|&b| g.each_key(&b) }
|
186
|
+
# each_child = lambda {|n, &b| g[n].each(&b) }
|
187
|
+
# p TSort.strongly_connected_components(each_node, each_child)
|
188
|
+
# #=> [[4], [2, 3], [1]]
|
189
|
+
#
|
190
|
+
def self.strongly_connected_components: [T] (_EachNode[T] each_node, _EachChild[T] each_child) -> Array[Array[T]]
|
191
|
+
|
192
|
+
# Returns a topologically sorted array of nodes. The array is sorted from
|
193
|
+
# children to parents, i.e. the first element has no child and the last node has
|
194
|
+
# no parent.
|
195
|
+
#
|
196
|
+
# The graph is represented by *each_node* and *each_child*. *each_node* should
|
197
|
+
# have `call` method which yields for each node in the graph. *each_child*
|
198
|
+
# should have `call` method which takes a node argument and yields for each
|
199
|
+
# child node.
|
200
|
+
#
|
201
|
+
# If there is a cycle, TSort::Cyclic is raised.
|
202
|
+
#
|
203
|
+
# g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
|
204
|
+
# each_node = lambda {|&b| g.each_key(&b) }
|
205
|
+
# each_child = lambda {|n, &b| g[n].each(&b) }
|
206
|
+
# p TSort.tsort(each_node, each_child) #=> [4, 2, 3, 1]
|
207
|
+
#
|
208
|
+
# g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
|
209
|
+
# each_node = lambda {|&b| g.each_key(&b) }
|
210
|
+
# each_child = lambda {|n, &b| g[n].each(&b) }
|
211
|
+
# p TSort.tsort(each_node, each_child) # raises TSort::Cyclic
|
212
|
+
#
|
213
|
+
def self.tsort: [T] (_EachNode[T] each_node, _EachChild[T] each_child) -> Array[T]
|
214
|
+
|
215
|
+
# The iterator version of the TSort.tsort method.
|
216
|
+
#
|
217
|
+
# The graph is represented by *each_node* and *each_child*. *each_node* should
|
218
|
+
# have `call` method which yields for each node in the graph. *each_child*
|
219
|
+
# should have `call` method which takes a node argument and yields for each
|
220
|
+
# child node.
|
221
|
+
#
|
222
|
+
# g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]}
|
223
|
+
# each_node = lambda {|&b| g.each_key(&b) }
|
224
|
+
# each_child = lambda {|n, &b| g[n].each(&b) }
|
225
|
+
# TSort.tsort_each(each_node, each_child) {|n| p n }
|
226
|
+
# #=> 4
|
227
|
+
# # 2
|
228
|
+
# # 3
|
229
|
+
# # 1
|
230
|
+
#
|
231
|
+
def self.tsort_each: [T] (_EachNode[T] each_node, _EachChild[T] each_child) { (T) -> void } -> void
|
232
|
+
| [T] (_EachNode[T] each_node, _EachChild[T] each_child) -> Enumerator[T, void]
|
233
|
+
|
234
|
+
# The iterator version of the #strongly_connected_components method.
|
235
|
+
# *`obj*.each_strongly_connected_component` is similar to
|
236
|
+
# *`obj*.strongly_connected_components.each`, but modification of *obj* during
|
237
|
+
# the iteration may lead to unexpected results.
|
238
|
+
#
|
239
|
+
# #each_strongly_connected_component returns `nil`.
|
240
|
+
#
|
241
|
+
# class G
|
242
|
+
# include TSort
|
243
|
+
# def initialize(g)
|
244
|
+
# @g = g
|
245
|
+
# end
|
246
|
+
# def tsort_each_child(n, &b) @g[n].each(&b) end
|
247
|
+
# def tsort_each_node(&b) @g.each_key(&b) end
|
248
|
+
# end
|
249
|
+
#
|
250
|
+
# graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
|
251
|
+
# graph.each_strongly_connected_component {|scc| p scc }
|
252
|
+
# #=> [4]
|
253
|
+
# # [2]
|
254
|
+
# # [3]
|
255
|
+
# # [1]
|
256
|
+
#
|
257
|
+
# graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
|
258
|
+
# graph.each_strongly_connected_component {|scc| p scc }
|
259
|
+
# #=> [4]
|
260
|
+
# # [2, 3]
|
261
|
+
# # [1]
|
262
|
+
#
|
263
|
+
def each_strongly_connected_component: () { (Array[Node]) -> void } -> void
|
264
|
+
| () -> Enumerator[Array[Node], void]
|
265
|
+
|
266
|
+
# Iterates over strongly connected component in the subgraph reachable from
|
267
|
+
# *node*.
|
268
|
+
#
|
269
|
+
# Return value is unspecified.
|
270
|
+
#
|
271
|
+
# #each_strongly_connected_component_from doesn't call #tsort_each_node.
|
272
|
+
#
|
273
|
+
# class G
|
274
|
+
# include TSort
|
275
|
+
# def initialize(g)
|
276
|
+
# @g = g
|
277
|
+
# end
|
278
|
+
# def tsort_each_child(n, &b) @g[n].each(&b) end
|
279
|
+
# def tsort_each_node(&b) @g.each_key(&b) end
|
280
|
+
# end
|
281
|
+
#
|
282
|
+
# graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
|
283
|
+
# graph.each_strongly_connected_component_from(2) {|scc| p scc }
|
284
|
+
# #=> [4]
|
285
|
+
# # [2]
|
286
|
+
#
|
287
|
+
# graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
|
288
|
+
# graph.each_strongly_connected_component_from(2) {|scc| p scc }
|
289
|
+
# #=> [4]
|
290
|
+
# # [2, 3]
|
291
|
+
#
|
292
|
+
def each_strongly_connected_component_from: (Node, ?untyped id_map, ?untyped stack) { (Array[Node]) -> void } -> void
|
293
|
+
| (Node, ?untyped id_map, ?untyped stack) -> Enumerator[Array[Node], void]
|
294
|
+
|
295
|
+
# Returns strongly connected components as an array of arrays of nodes. The
|
296
|
+
# array is sorted from children to parents. Each elements of the array
|
297
|
+
# represents a strongly connected component.
|
298
|
+
#
|
299
|
+
# class G
|
300
|
+
# include TSort
|
301
|
+
# def initialize(g)
|
302
|
+
# @g = g
|
303
|
+
# end
|
304
|
+
# def tsort_each_child(n, &b) @g[n].each(&b) end
|
305
|
+
# def tsort_each_node(&b) @g.each_key(&b) end
|
306
|
+
# end
|
307
|
+
#
|
308
|
+
# graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
|
309
|
+
# p graph.strongly_connected_components #=> [[4], [2], [3], [1]]
|
310
|
+
#
|
311
|
+
# graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
|
312
|
+
# p graph.strongly_connected_components #=> [[4], [2, 3], [1]]
|
313
|
+
#
|
314
|
+
def strongly_connected_components: () -> Array[Array[Node]]
|
315
|
+
|
316
|
+
# Returns a topologically sorted array of nodes. The array is sorted from
|
317
|
+
# children to parents, i.e. the first element has no child and the last node has
|
318
|
+
# no parent.
|
319
|
+
#
|
320
|
+
# If there is a cycle, TSort::Cyclic is raised.
|
321
|
+
#
|
322
|
+
# class G
|
323
|
+
# include TSort
|
324
|
+
# def initialize(g)
|
325
|
+
# @g = g
|
326
|
+
# end
|
327
|
+
# def tsort_each_child(n, &b) @g[n].each(&b) end
|
328
|
+
# def tsort_each_node(&b) @g.each_key(&b) end
|
329
|
+
# end
|
330
|
+
#
|
331
|
+
# graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
|
332
|
+
# p graph.tsort #=> [4, 2, 3, 1]
|
333
|
+
#
|
334
|
+
# graph = G.new({1=>[2], 2=>[3, 4], 3=>[2], 4=>[]})
|
335
|
+
# p graph.tsort # raises TSort::Cyclic
|
336
|
+
#
|
337
|
+
def tsort: () -> Array[Node]
|
338
|
+
|
339
|
+
# The iterator version of the #tsort method. *`obj*.tsort_each` is similar to
|
340
|
+
# *`obj*.tsort.each`, but modification of *obj* during the iteration may lead to
|
341
|
+
# unexpected results.
|
342
|
+
#
|
343
|
+
# #tsort_each returns `nil`. If there is a cycle, TSort::Cyclic is raised.
|
344
|
+
#
|
345
|
+
# class G
|
346
|
+
# include TSort
|
347
|
+
# def initialize(g)
|
348
|
+
# @g = g
|
349
|
+
# end
|
350
|
+
# def tsort_each_child(n, &b) @g[n].each(&b) end
|
351
|
+
# def tsort_each_node(&b) @g.each_key(&b) end
|
352
|
+
# end
|
353
|
+
#
|
354
|
+
# graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})
|
355
|
+
# graph.tsort_each {|n| p n }
|
356
|
+
# #=> 4
|
357
|
+
# # 2
|
358
|
+
# # 3
|
359
|
+
# # 1
|
360
|
+
#
|
361
|
+
def tsort_each: () { (Node) -> void } -> void
|
362
|
+
| () -> Enumerator[Node, void]
|
363
|
+
end
|
File without changes
|
@@ -193,7 +193,7 @@ module URI
|
|
193
193
|
#
|
194
194
|
# Creates a new URI::Generic instance from ``generic'' components without check.
|
195
195
|
#
|
196
|
-
def initialize: (String scheme, String userinfo, String host, Integer port, String? registry, String path, String? opaque, String query, String fragment, ?untyped parser, ?
|
196
|
+
def initialize: (String scheme, String userinfo, String host, Integer port, String? registry, String path, String? opaque, String query, String fragment, ?untyped parser, ?boolish arg_check) -> URI::Generic
|
197
197
|
|
198
198
|
#
|
199
199
|
# Returns the scheme component of the URI.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/steep/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (6.0.3.
|
4
|
+
activesupport (6.0.3.4)
|
5
5
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
6
|
i18n (>= 0.7, < 2)
|
7
7
|
minitest (~> 5.1)
|
@@ -15,31 +15,31 @@ GEM
|
|
15
15
|
ffi (1.13.1)
|
16
16
|
i18n (1.8.5)
|
17
17
|
concurrent-ruby (~> 1.0)
|
18
|
-
language_server-protocol (3.
|
18
|
+
language_server-protocol (3.15.0.1)
|
19
19
|
listen (3.2.1)
|
20
20
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
21
21
|
rb-inotify (~> 0.9, >= 0.9.10)
|
22
22
|
minitest (5.14.2)
|
23
|
-
parser (2.7.
|
23
|
+
parser (2.7.2.0)
|
24
24
|
ast (~> 2.4.1)
|
25
25
|
rainbow (3.0.0)
|
26
26
|
rb-fsevent (0.10.4)
|
27
27
|
rb-inotify (0.10.1)
|
28
28
|
ffi (~> 1.0)
|
29
|
-
rbs (0.
|
30
|
-
steep (0.
|
29
|
+
rbs (0.14.0)
|
30
|
+
steep (0.34.0)
|
31
31
|
activesupport (>= 5.1)
|
32
32
|
ast_utils (~> 0.3.0)
|
33
|
-
language_server-protocol (~> 3.
|
34
|
-
listen (~> 3.
|
33
|
+
language_server-protocol (~> 3.15.0.1)
|
34
|
+
listen (~> 3.0)
|
35
35
|
parser (~> 2.7.0)
|
36
36
|
rainbow (>= 2.2.2, < 4.0)
|
37
|
-
rbs (~> 0.
|
37
|
+
rbs (~> 0.14.0)
|
38
38
|
thor (1.0.1)
|
39
39
|
thread_safe (0.3.6)
|
40
40
|
tzinfo (1.2.7)
|
41
41
|
thread_safe (~> 0.1)
|
42
|
-
zeitwerk (2.4.
|
42
|
+
zeitwerk (2.4.1)
|
43
43
|
|
44
44
|
PLATFORMS
|
45
45
|
ruby
|