rbs 0.18.1 → 1.0.0.pre2

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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -0
  3. data/Rakefile +12 -0
  4. data/Steepfile +2 -1
  5. data/bin/annotate-with-rdoc +0 -4
  6. data/core/builtin.rbs +4 -0
  7. data/core/file.rbs +3 -4
  8. data/core/hash.rbs +1 -3
  9. data/core/io.rbs +165 -7
  10. data/core/kernel.rbs +1 -1
  11. data/core/module.rbs +41 -0
  12. data/core/time.rbs +0 -12
  13. data/docs/syntax.md +0 -17
  14. data/goodcheck.yml +22 -2
  15. data/lib/rbs.rb +2 -0
  16. data/lib/rbs/ast/declarations.rb +7 -49
  17. data/lib/rbs/ast/members.rb +10 -4
  18. data/lib/rbs/cli.rb +10 -10
  19. data/lib/rbs/definition.rb +70 -3
  20. data/lib/rbs/definition_builder.rb +573 -984
  21. data/lib/rbs/definition_builder/ancestor_builder.rb +525 -0
  22. data/lib/rbs/definition_builder/method_builder.rb +217 -0
  23. data/lib/rbs/environment.rb +6 -8
  24. data/lib/rbs/environment_loader.rb +8 -4
  25. data/lib/rbs/errors.rb +88 -121
  26. data/lib/rbs/method_type.rb +1 -31
  27. data/lib/rbs/parser.rb +1082 -1014
  28. data/lib/rbs/parser.y +108 -76
  29. data/lib/rbs/prototype/rb.rb +18 -3
  30. data/lib/rbs/prototype/rbi.rb +6 -6
  31. data/lib/rbs/prototype/runtime.rb +71 -35
  32. data/lib/rbs/substitution.rb +4 -0
  33. data/lib/rbs/test.rb +3 -1
  34. data/lib/rbs/test/hook.rb +26 -8
  35. data/lib/rbs/types.rb +68 -7
  36. data/lib/rbs/validator.rb +4 -2
  37. data/lib/rbs/variance_calculator.rb +5 -1
  38. data/lib/rbs/version.rb +1 -1
  39. data/lib/rbs/writer.rb +13 -4
  40. data/schema/members.json +5 -1
  41. data/sig/ancestor_builder.rbs +98 -0
  42. data/sig/declarations.rbs +4 -16
  43. data/sig/definition.rbs +6 -1
  44. data/sig/definition_builder.rbs +15 -67
  45. data/sig/errors.rbs +159 -0
  46. data/sig/members.rbs +4 -1
  47. data/sig/method_builder.rbs +71 -0
  48. data/sig/method_types.rbs +3 -16
  49. data/sig/substitution.rbs +3 -0
  50. data/sig/type_name_resolver.rbs +4 -2
  51. data/sig/types.rbs +17 -15
  52. data/sig/validator.rbs +12 -0
  53. data/stdlib/csv/0/csv.rbs +3 -0
  54. data/stdlib/dbm/0/dbm.rbs +0 -2
  55. data/stdlib/logger/0/log_device.rbs +1 -2
  56. data/stdlib/monitor/0/monitor.rbs +119 -0
  57. data/stdlib/pathname/0/pathname.rbs +1 -1
  58. data/stdlib/prime/0/prime.rbs +6 -0
  59. data/stdlib/securerandom/0/securerandom.rbs +2 -0
  60. data/stdlib/time/0/time.rbs +327 -0
  61. data/stdlib/tsort/0/tsort.rbs +8 -0
  62. data/stdlib/uri/0/common.rbs +401 -0
  63. data/stdlib/uri/0/rfc2396_parser.rbs +9 -0
  64. data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
  65. data/steep/Gemfile.lock +13 -14
  66. metadata +16 -5
@@ -142,6 +142,8 @@ module TSort[Node] : TSort::_Sortable[Node]
142
142
  #
143
143
  def self.each_strongly_connected_component: [T] (_EachNode[T] each_node, _EachChild[T] each_child) { (Array[T]) -> void } -> void
144
144
  | [T] (_EachNode[T] each_node, _EachChild[T] each_child) -> Enumerator[Array[T], void]
145
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) { (Array[T]) -> void } -> void
146
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) -> Enumerator[Array[T], void]
145
147
 
146
148
  # Iterates over strongly connected components in a graph. The graph is
147
149
  # represented by *node* and *each_child*.
@@ -165,6 +167,8 @@ module TSort[Node] : TSort::_Sortable[Node]
165
167
  #
166
168
  def self.each_strongly_connected_component_from: [T] (T node, _EachChild[T] each_child, ?untyped id_map, ?untyped stack) { (Array[T]) -> void } -> void
167
169
  | [T] (T node, _EachChild[T] each_child, ?untyped id_map, ?untyped stack) -> Enumerator[Array[T], void]
170
+ | [T] (T node, ^(T) { (T) -> void } -> void each_child, ?untyped id_map, ?untyped stack) { (Array[T]) -> void } -> void
171
+ | [T] (T node, ^(T) { (T) -> void } -> void each_child, ?untyped id_map, ?untyped stack) -> Enumerator[Array[T], void]
168
172
 
169
173
  # Returns strongly connected components as an array of arrays of nodes. The
170
174
  # array is sorted from children to parents. Each elements of the array
@@ -188,6 +192,7 @@ module TSort[Node] : TSort::_Sortable[Node]
188
192
  # #=> [[4], [2, 3], [1]]
189
193
  #
190
194
  def self.strongly_connected_components: [T] (_EachNode[T] each_node, _EachChild[T] each_child) -> Array[Array[T]]
195
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) -> Array[Array[T]]
191
196
 
192
197
  # Returns a topologically sorted array of nodes. The array is sorted from
193
198
  # children to parents, i.e. the first element has no child and the last node has
@@ -211,6 +216,7 @@ module TSort[Node] : TSort::_Sortable[Node]
211
216
  # p TSort.tsort(each_node, each_child) # raises TSort::Cyclic
212
217
  #
213
218
  def self.tsort: [T] (_EachNode[T] each_node, _EachChild[T] each_child) -> Array[T]
219
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) -> Array[T]
214
220
 
215
221
  # The iterator version of the TSort.tsort method.
216
222
  #
@@ -230,6 +236,8 @@ module TSort[Node] : TSort::_Sortable[Node]
230
236
  #
231
237
  def self.tsort_each: [T] (_EachNode[T] each_node, _EachChild[T] each_child) { (T) -> void } -> void
232
238
  | [T] (_EachNode[T] each_node, _EachChild[T] each_child) -> Enumerator[T, void]
239
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) { (T) -> void } -> void
240
+ | [T] (^() { (T) -> void } -> void each_node, ^(T) { (T) -> void } -> void each_child) -> Enumerator[T, void]
233
241
 
234
242
  # The iterator version of the #strongly_connected_components method.
235
243
  # *`obj*.each_strongly_connected_component` is similar to
@@ -0,0 +1,401 @@
1
+ # URI is a module providing classes to handle Uniform Resource Identifiers
2
+ # ([RFC2396](http://tools.ietf.org/html/rfc2396)).
3
+ #
4
+ # ## Features
5
+ #
6
+ # * Uniform way of handling URIs.
7
+ # * Flexibility to introduce custom URI schemes.
8
+ # * Flexibility to have an alternate URI::Parser (or just different patterns
9
+ # and regexp's).
10
+ #
11
+ #
12
+ # ## Basic example
13
+ #
14
+ # require 'uri'
15
+ #
16
+ # uri = URI("http://foo.com/posts?id=30&limit=5#time=1305298413")
17
+ # #=> #<URI::HTTP http://foo.com/posts?id=30&limit=5#time=1305298413>
18
+ #
19
+ # uri.scheme #=> "http"
20
+ # uri.host #=> "foo.com"
21
+ # uri.path #=> "/posts"
22
+ # uri.query #=> "id=30&limit=5"
23
+ # uri.fragment #=> "time=1305298413"
24
+ #
25
+ # uri.to_s #=> "http://foo.com/posts?id=30&limit=5#time=1305298413"
26
+ #
27
+ # ## Adding custom URIs
28
+ #
29
+ # module URI
30
+ # class RSYNC < Generic
31
+ # DEFAULT_PORT = 873
32
+ # end
33
+ # @@schemes['RSYNC'] = RSYNC
34
+ # end
35
+ # #=> URI::RSYNC
36
+ #
37
+ # URI.scheme_list
38
+ # #=> {"FILE"=>URI::File, "FTP"=>URI::FTP, "HTTP"=>URI::HTTP,
39
+ # # "HTTPS"=>URI::HTTPS, "LDAP"=>URI::LDAP, "LDAPS"=>URI::LDAPS,
40
+ # # "MAILTO"=>URI::MailTo, "RSYNC"=>URI::RSYNC}
41
+ #
42
+ # uri = URI("rsync://rsync.foo.com")
43
+ # #=> #<URI::RSYNC rsync://rsync.foo.com>
44
+ #
45
+ # ## RFC References
46
+ #
47
+ # A good place to view an RFC spec is http://www.ietf.org/rfc.html.
48
+ #
49
+ # Here is a list of all related RFC's:
50
+ # * [RFC822](http://tools.ietf.org/html/rfc822)
51
+ # * [RFC1738](http://tools.ietf.org/html/rfc1738)
52
+ # * [RFC2255](http://tools.ietf.org/html/rfc2255)
53
+ # * [RFC2368](http://tools.ietf.org/html/rfc2368)
54
+ # * [RFC2373](http://tools.ietf.org/html/rfc2373)
55
+ # * [RFC2396](http://tools.ietf.org/html/rfc2396)
56
+ # * [RFC2732](http://tools.ietf.org/html/rfc2732)
57
+ # * [RFC3986](http://tools.ietf.org/html/rfc3986)
58
+ #
59
+ #
60
+ # ## Class tree
61
+ #
62
+ # * URI::Generic (in uri/generic.rb)
63
+ # * URI::File - (in uri/file.rb)
64
+ # * URI::FTP - (in uri/ftp.rb)
65
+ # * URI::HTTP - (in uri/http.rb)
66
+ # * URI::HTTPS - (in uri/https.rb)
67
+ #
68
+ # * URI::LDAP - (in uri/ldap.rb)
69
+ # * URI::LDAPS - (in uri/ldaps.rb)
70
+ #
71
+ # * URI::MailTo - (in uri/mailto.rb)
72
+ #
73
+ # * URI::Parser - (in uri/common.rb)
74
+ # * URI::REGEXP - (in uri/common.rb)
75
+ # * URI::REGEXP::PATTERN - (in uri/common.rb)
76
+ #
77
+ # * URI::Util - (in uri/common.rb)
78
+ # * URI::Escape - (in uri/common.rb)
79
+ # * URI::Error - (in uri/common.rb)
80
+ # * URI::InvalidURIError - (in uri/common.rb)
81
+ # * URI::InvalidComponentError - (in uri/common.rb)
82
+ # * URI::BadURIError - (in uri/common.rb)
83
+ #
84
+ #
85
+ #
86
+ # ## Copyright Info
87
+ #
88
+ # Author
89
+ # : Akira Yamada <akira@ruby-lang.org>
90
+ # Documentation
91
+ # : Akira Yamada <akira@ruby-lang.org> Dmitry V. Sabanin <sdmitry@lrn.ru>
92
+ # Vincent Batts <vbatts@hashbangbash.com>
93
+ # License
94
+ # : Copyright (c) 2001 akira yamada <akira@ruby-lang.org> You can redistribute
95
+ # it and/or modify it under the same term as Ruby.
96
+ # Revision
97
+ # : $Id$
98
+ #
99
+ module URI
100
+ include URI::RFC2396_REGEXP
101
+
102
+ # Decodes URL-encoded form data from given `str`.
103
+ #
104
+ # This decodes application/x-www-form-urlencoded data and returns an array of
105
+ # key-value arrays.
106
+ #
107
+ # This refers http://url.spec.whatwg.org/#concept-urlencoded-parser, so this
108
+ # supports only &-separator, and doesn't support ;-separator.
109
+ #
110
+ # ary = URI.decode_www_form("a=1&a=2&b=3")
111
+ # ary #=> [['a', '1'], ['a', '2'], ['b', '3']]
112
+ # ary.assoc('a').last #=> '1'
113
+ # ary.assoc('b').last #=> '3'
114
+ # ary.rassoc('a').last #=> '2'
115
+ # Hash[ary] #=> {"a"=>"2", "b"=>"3"}
116
+ #
117
+ # See URI.decode_www_form_component, URI.encode_www_form.
118
+ #
119
+ def self.decode_www_form: (String str, ?encoding enc, ?isindex: boolish, ?use__charset_: boolish, ?separator: String) -> Array[[ String, String ]]
120
+
121
+ # Decodes given `str` of URL-encoded form data.
122
+ #
123
+ # This decodes + to SP.
124
+ #
125
+ # See URI.encode_www_form_component, URI.decode_www_form.
126
+ #
127
+ def self.decode_www_form_component: (String str, ?encoding enc) -> String
128
+
129
+ # Generates URL-encoded form data from given `enum`.
130
+ #
131
+ # This generates application/x-www-form-urlencoded data defined in HTML5 from
132
+ # given an Enumerable object.
133
+ #
134
+ # This internally uses URI.encode_www_form_component(str).
135
+ #
136
+ # This method doesn't convert the encoding of given items, so convert them
137
+ # before calling this method if you want to send data as other than original
138
+ # encoding or mixed encoding data. (Strings which are encoded in an HTML5 ASCII
139
+ # incompatible encoding are converted to UTF-8.)
140
+ #
141
+ # This method doesn't handle files. When you send a file, use
142
+ # multipart/form-data.
143
+ #
144
+ # This refers http://url.spec.whatwg.org/#concept-urlencoded-serializer
145
+ #
146
+ # URI.encode_www_form([["q", "ruby"], ["lang", "en"]])
147
+ # #=> "q=ruby&lang=en"
148
+ # URI.encode_www_form("q" => "ruby", "lang" => "en")
149
+ # #=> "q=ruby&lang=en"
150
+ # URI.encode_www_form("q" => ["ruby", "perl"], "lang" => "en")
151
+ # #=> "q=ruby&q=perl&lang=en"
152
+ # URI.encode_www_form([["q", "ruby"], ["q", "perl"], ["lang", "en"]])
153
+ # #=> "q=ruby&q=perl&lang=en"
154
+ #
155
+ # See URI.encode_www_form_component, URI.decode_www_form.
156
+ #
157
+ def self.encode_www_form: (Enumerable[[ _ToS, _ToS ]] enum, ?encoding enc) -> String
158
+
159
+ # Encodes given `str` to URL-encoded form data.
160
+ #
161
+ # This method doesn't convert *, -, ., 0-9, A-Z, _, a-z, but does convert SP
162
+ # (ASCII space) to + and converts others to %XX.
163
+ #
164
+ # If `enc` is given, convert `str` to the encoding before percent encoding.
165
+ #
166
+ # This is an implementation of
167
+ # http://www.w3.org/TR/2013/CR-html5-20130806/forms.html#url-encoded-form-data.
168
+ #
169
+ # See URI.decode_www_form_component, URI.encode_www_form.
170
+ #
171
+ def self.encode_www_form_component: (String str, ?encoding enc) -> String
172
+
173
+ # ## Synopsis
174
+ #
175
+ # URI::extract(str[, schemes][,&blk])
176
+ #
177
+ # ## Args
178
+ #
179
+ # `str`
180
+ # : String to extract URIs from.
181
+ # `schemes`
182
+ # : Limit URI matching to specific schemes.
183
+ #
184
+ #
185
+ # ## Description
186
+ #
187
+ # Extracts URIs from a string. If block given, iterates through all matched
188
+ # URIs. Returns nil if block given or array with matches.
189
+ #
190
+ # ## Usage
191
+ #
192
+ # require "uri"
193
+ #
194
+ # URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.")
195
+ # # => ["http://foo.example.com/bla", "mailto:test@example.com"]
196
+ #
197
+ def self.extract: (String str, ?Array[String] schemes) -> Array[String]
198
+ | (String str, ?Array[String] schemes) { (String) -> void } -> nil
199
+
200
+ def self.get_encoding: (String label) -> Encoding?
201
+
202
+ # ## Synopsis
203
+ #
204
+ # URI::join(str[, str, ...])
205
+ #
206
+ # ## Args
207
+ #
208
+ # `str`
209
+ # : String(s) to work with, will be converted to RFC3986 URIs before merging.
210
+ #
211
+ #
212
+ # ## Description
213
+ #
214
+ # Joins URIs.
215
+ #
216
+ # ## Usage
217
+ #
218
+ # require 'uri'
219
+ #
220
+ # URI.join("http://example.com/","main.rbx")
221
+ # # => #<URI::HTTP http://example.com/main.rbx>
222
+ #
223
+ # URI.join('http://example.com', 'foo')
224
+ # # => #<URI::HTTP http://example.com/foo>
225
+ #
226
+ # URI.join('http://example.com', '/foo', '/bar')
227
+ # # => #<URI::HTTP http://example.com/bar>
228
+ #
229
+ # URI.join('http://example.com', '/foo', 'bar')
230
+ # # => #<URI::HTTP http://example.com/bar>
231
+ #
232
+ # URI.join('http://example.com', '/foo/', 'bar')
233
+ # # => #<URI::HTTP http://example.com/foo/bar>
234
+ #
235
+ def self.join: (String str, *String strs) -> URI::Generic
236
+
237
+ # ## Synopsis
238
+ #
239
+ # URI::parse(uri_str)
240
+ #
241
+ # ## Args
242
+ #
243
+ # `uri_str`
244
+ # : String with URI.
245
+ #
246
+ #
247
+ # ## Description
248
+ #
249
+ # Creates one of the URI's subclasses instance from the string.
250
+ #
251
+ # ## Raises
252
+ #
253
+ # URI::InvalidURIError
254
+ # : Raised if URI given is not a correct one.
255
+ #
256
+ #
257
+ # ## Usage
258
+ #
259
+ # require 'uri'
260
+ #
261
+ # uri = URI.parse("http://www.ruby-lang.org/")
262
+ # # => #<URI::HTTP http://www.ruby-lang.org/>
263
+ # uri.scheme
264
+ # # => "http"
265
+ # uri.host
266
+ # # => "www.ruby-lang.org"
267
+ #
268
+ # It's recommended to first ::escape the provided `uri_str` if there are any
269
+ # invalid URI characters.
270
+ #
271
+ def self.parse: (String uri) -> URI::Generic
272
+
273
+ # ## Synopsis
274
+ #
275
+ # URI::regexp([match_schemes])
276
+ #
277
+ # ## Args
278
+ #
279
+ # `match_schemes`
280
+ # : Array of schemes. If given, resulting regexp matches to URIs whose scheme
281
+ # is one of the match_schemes.
282
+ #
283
+ #
284
+ # ## Description
285
+ #
286
+ # Returns a Regexp object which matches to URI-like strings. The Regexp object
287
+ # returned by this method includes arbitrary number of capture group
288
+ # (parentheses). Never rely on it's number.
289
+ #
290
+ # ## Usage
291
+ #
292
+ # require 'uri'
293
+ #
294
+ # # extract first URI from html_string
295
+ # html_string.slice(URI.regexp)
296
+ #
297
+ # # remove ftp URIs
298
+ # html_string.sub(URI.regexp(['ftp']), '')
299
+ #
300
+ # # You should not rely on the number of parentheses
301
+ # html_string.scan(URI.regexp) do |*matches|
302
+ # p $&
303
+ # end
304
+ #
305
+ def self.regexp: (?Array[String] schemes) -> Regexp
306
+
307
+ # Returns a Hash of the defined schemes.
308
+ #
309
+ def self.scheme_list: () -> Hash[String, Class]
310
+
311
+ # ## Synopsis
312
+ #
313
+ # URI::split(uri)
314
+ #
315
+ # ## Args
316
+ #
317
+ # `uri`
318
+ # : String with URI.
319
+ #
320
+ #
321
+ # ## Description
322
+ #
323
+ # Splits the string on following parts and returns array with result:
324
+ #
325
+ # * Scheme
326
+ # * Userinfo
327
+ # * Host
328
+ # * Port
329
+ # * Registry
330
+ # * Path
331
+ # * Opaque
332
+ # * Query
333
+ # * Fragment
334
+ #
335
+ #
336
+ # ## Usage
337
+ #
338
+ # require 'uri'
339
+ #
340
+ # URI.split("http://www.ruby-lang.org/")
341
+ # # => ["http", nil, "www.ruby-lang.org", nil, nil, "/", nil, nil, nil]
342
+ #
343
+ def self.split: (String uri) -> [ String?, String?, String?, String?, String?, String?, String?, String?, String? ]
344
+ end
345
+
346
+ URI::ABS_PATH: Regexp
347
+
348
+ URI::ABS_URI: Regexp
349
+
350
+ URI::ABS_URI_REF: Regexp
351
+
352
+ # URI::Parser.new
353
+ URI::DEFAULT_PARSER: URI::RFC2396_Parser
354
+
355
+ URI::ESCAPED: Regexp
356
+
357
+ URI::FRAGMENT: Regexp
358
+
359
+ URI::HOST: Regexp
360
+
361
+ URI::OPAQUE: Regexp
362
+
363
+ URI::PORT: Regexp
364
+
365
+ URI::QUERY: Regexp
366
+
367
+ URI::REGISTRY: Regexp
368
+
369
+ URI::REL_PATH: Regexp
370
+
371
+ URI::REL_URI: Regexp
372
+
373
+ URI::REL_URI_REF: Regexp
374
+
375
+ URI::RFC3986_PARSER: URI::RFC3986_Parser
376
+
377
+ URI::SCHEME: Regexp
378
+
379
+ URI::TBLDECWWWCOMP_: Hash[String, String]
380
+
381
+ URI::TBLENCWWWCOMP_: Hash[String, String]
382
+
383
+ URI::UNSAFE: Regexp
384
+
385
+ URI::URI_REF: Regexp
386
+
387
+ URI::USERINFO: Regexp
388
+
389
+ URI::VERSION: String
390
+
391
+ URI::VERSION_CODE: String
392
+
393
+ URI::WEB_ENCODINGS_: Hash[String, String]
394
+
395
+ module Kernel
396
+ private
397
+
398
+ # Returns `uri` converted to an URI object.
399
+ #
400
+ def URI: (URI::Generic | String uri) -> URI::Generic
401
+ end
@@ -0,0 +1,9 @@
1
+ # Class that parses String's into URI's.
2
+ #
3
+ # It contains a Hash set of patterns and Regexp's that match and validate.
4
+ class URI::RFC2396_Parser
5
+ end
6
+
7
+ # Includes URI::REGEXP::PATTERN
8
+ module URI::RFC2396_REGEXP
9
+ end