rbs 0.20.1 → 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/Rakefile +4 -0
- data/core/builtin.rbs +4 -0
- data/core/io.rbs +159 -6
- data/core/kernel.rbs +1 -1
- data/goodcheck.yml +20 -0
- data/lib/rbs.rb +2 -0
- data/lib/rbs/ast/declarations.rb +7 -2
- data/lib/rbs/ast/members.rb +1 -1
- data/lib/rbs/cli.rb +10 -10
- data/lib/rbs/definition.rb +70 -3
- data/lib/rbs/definition_builder.rb +542 -1006
- data/lib/rbs/definition_builder/ancestor_builder.rb +476 -0
- data/lib/rbs/definition_builder/method_builder.rb +217 -0
- data/lib/rbs/environment.rb +2 -1
- data/lib/rbs/errors.rb +71 -66
- data/lib/rbs/parser.rb +673 -627
- data/lib/rbs/parser.y +13 -2
- data/lib/rbs/prototype/rb.rb +1 -1
- data/lib/rbs/prototype/rbi.rb +1 -1
- data/lib/rbs/prototype/runtime.rb +52 -32
- data/lib/rbs/substitution.rb +4 -0
- data/lib/rbs/test.rb +3 -1
- data/lib/rbs/test/hook.rb +20 -6
- data/lib/rbs/validator.rb +4 -2
- data/lib/rbs/variance_calculator.rb +5 -1
- data/lib/rbs/version.rb +1 -1
- data/sig/definition.rbs +6 -1
- data/sig/errors.rbs +20 -0
- data/sig/type_name_resolver.rbs +4 -2
- data/sig/validator.rbs +12 -0
- data/stdlib/logger/0/log_device.rbs +1 -2
- data/stdlib/time/0/time.rbs +327 -0
- data/stdlib/uri/0/common.rbs +401 -0
- data/stdlib/uri/0/rfc2396_parser.rbs +9 -0
- data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
- data/steep/Gemfile.lock +10 -11
- metadata +13 -5
@@ -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
|
data/steep/Gemfile.lock
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (6.0
|
4
|
+
activesupport (6.1.0)
|
5
5
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
|
-
i18n (>=
|
7
|
-
minitest (
|
8
|
-
tzinfo (~>
|
9
|
-
zeitwerk (~> 2.
|
6
|
+
i18n (>= 1.6, < 2)
|
7
|
+
minitest (>= 5.1)
|
8
|
+
tzinfo (~> 2.0)
|
9
|
+
zeitwerk (~> 2.3)
|
10
10
|
ast (2.4.1)
|
11
11
|
ast_utils (0.3.0)
|
12
12
|
parser (~> 2.4)
|
@@ -26,19 +26,18 @@ GEM
|
|
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.20.1)
|
30
|
+
steep (0.38.0)
|
31
31
|
activesupport (>= 5.1)
|
32
32
|
ast_utils (~> 0.3.0)
|
33
33
|
language_server-protocol (~> 3.15.0.1)
|
34
34
|
listen (~> 3.0)
|
35
35
|
parser (~> 2.7.0)
|
36
36
|
rainbow (>= 2.2.2, < 4.0)
|
37
|
-
rbs (
|
37
|
+
rbs (>= 0.20.0)
|
38
38
|
thor (1.0.1)
|
39
|
-
|
40
|
-
|
41
|
-
thread_safe (~> 0.1)
|
39
|
+
tzinfo (2.0.3)
|
40
|
+
concurrent-ruby (~> 1.0)
|
42
41
|
zeitwerk (2.4.2)
|
43
42
|
|
44
43
|
PLATFORMS
|