rbs 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/Rakefile +9 -4
  4. data/Steepfile +28 -0
  5. data/bin/steep +4 -0
  6. data/bin/test_runner.rb +10 -5
  7. data/lib/rbs/ast/comment.rb +7 -1
  8. data/lib/rbs/ast/declarations.rb +15 -9
  9. data/lib/rbs/buffer.rb +1 -1
  10. data/lib/rbs/definition.rb +22 -13
  11. data/lib/rbs/definition_builder.rb +79 -55
  12. data/lib/rbs/environment.rb +24 -10
  13. data/lib/rbs/location.rb +1 -5
  14. data/lib/rbs/method_type.rb +5 -5
  15. data/lib/rbs/namespace.rb +14 -3
  16. data/lib/rbs/parser.y +0 -8
  17. data/lib/rbs/prototype/rb.rb +3 -4
  18. data/lib/rbs/prototype/rbi.rb +1 -2
  19. data/lib/rbs/substitution.rb +4 -3
  20. data/lib/rbs/type_name.rb +18 -1
  21. data/lib/rbs/type_name_resolver.rb +10 -3
  22. data/lib/rbs/types.rb +27 -21
  23. data/lib/rbs/variance_calculator.rb +8 -5
  24. data/lib/rbs/version.rb +1 -1
  25. data/sig/annotation.rbs +26 -0
  26. data/sig/buffer.rbs +28 -0
  27. data/sig/builtin_names.rbs +41 -0
  28. data/sig/comment.rbs +26 -0
  29. data/sig/declarations.rbs +202 -0
  30. data/sig/definition.rbs +129 -0
  31. data/sig/definition_builder.rbs +95 -0
  32. data/sig/environment.rbs +94 -0
  33. data/sig/environment_loader.rbs +4 -0
  34. data/sig/location.rbs +52 -0
  35. data/sig/members.rbs +160 -0
  36. data/sig/method_types.rbs +40 -0
  37. data/sig/namespace.rbs +124 -0
  38. data/sig/polyfill.rbs +3 -0
  39. data/sig/rbs.rbs +3 -0
  40. data/sig/substitution.rbs +39 -0
  41. data/sig/type_name_resolver.rbs +24 -0
  42. data/sig/typename.rbs +70 -0
  43. data/sig/types.rbs +361 -0
  44. data/sig/util.rbs +13 -0
  45. data/sig/variance_calculator.rbs +35 -0
  46. data/stdlib/bigdecimal/big_decimal.rbs +887 -0
  47. data/stdlib/bigdecimal/math/big_math.rbs +142 -0
  48. data/stdlib/builtin/builtin.rbs +0 -3
  49. data/stdlib/builtin/math.rbs +26 -26
  50. data/stdlib/builtin/struct.rbs +9 -10
  51. data/stdlib/forwardable/forwardable.rbs +204 -0
  52. data/stdlib/set/set.rbs +1 -1
  53. data/stdlib/uri/file.rbs +167 -0
  54. data/stdlib/uri/generic.rbs +875 -0
  55. data/steep/Gemfile +3 -0
  56. data/steep/Gemfile.lock +55 -0
  57. metadata +36 -6
@@ -232,7 +232,7 @@ class Set[A]
232
232
  # Set[1, 2, 3].intersect? Set[4, 5] #=> false
233
233
  # Set[1, 2, 3].intersect? Set[3, 4] #=> true
234
234
  #
235
- def intersect?: () -> bool
235
+ def intersect?: (self) -> bool
236
236
 
237
237
  # Deletes every element of the set for which block evaluates to false, and
238
238
  # returns self. Returns an enumerator if no block is given.
@@ -0,0 +1,167 @@
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
+ #
100
+ module URI
101
+ #
102
+ # The "file" URI is defined by RFC8089.
103
+ #
104
+ class File < Generic
105
+ # A Default port of nil for URI::File.
106
+ DEFAULT_PORT: Integer?
107
+
108
+ #
109
+ # An Array of the available components for URI::File.
110
+ #
111
+ COMPONENT: Array[Symbol]
112
+
113
+ #
114
+ # == Description
115
+ #
116
+ # Creates a new URI::File object from components, with syntax checking.
117
+ #
118
+ # The components accepted are +host+ and +path+.
119
+ #
120
+ # The components should be provided either as an Array, or as a Hash
121
+ # with keys formed by preceding the component names with a colon.
122
+ #
123
+ # If an Array is used, the components must be passed in the
124
+ # order <code>[host, path]</code>.
125
+ #
126
+ # Examples:
127
+ #
128
+ # require 'uri'
129
+ #
130
+ # uri1 = URI::File.build(['host.example.com', '/path/file.zip'])
131
+ # uri1.to_s # => "file://host.example.com/path/file.zip"
132
+ #
133
+ # uri2 = URI::File.build({:host => 'host.example.com',
134
+ # :path => '/ruby/src'})
135
+ # uri2.to_s # => "file://host.example.com/ruby/src"
136
+ #
137
+ def self.build: (Array[String] args) -> URI::File
138
+ | ({ host: String, path: String }) -> URI::File
139
+
140
+ # Protected setter for the host component +v+.
141
+ #
142
+ # See also URI::Generic.host=.
143
+ #
144
+ def set_host: (String? v) -> String
145
+
146
+ # do nothing
147
+ def set_port: (Integer v) -> nil
148
+
149
+ # raise InvalidURIError
150
+ def check_userinfo: (String user) -> nil
151
+
152
+ # raise InvalidURIError
153
+ def check_user: (String user) -> nil
154
+
155
+ # raise InvalidURIError
156
+ def check_password: (String user) -> nil
157
+
158
+ # do nothing
159
+ def set_userinfo: (String v) -> nil
160
+
161
+ # do nothing
162
+ def set_user: (String v) -> nil
163
+
164
+ # do nothing
165
+ def set_password: (String v) -> nil
166
+ end
167
+ end
@@ -0,0 +1,875 @@
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
+ #
100
+ module URI
101
+ #
102
+ # Base class for all URI classes.
103
+ # Implements generic URI syntax as per RFC 2396.
104
+ #
105
+ class Generic
106
+ include URI
107
+
108
+ #
109
+ # A Default port of nil for URI::Generic.
110
+ #
111
+ DEFAULT_PORT: nil | Integer
112
+
113
+ #
114
+ # Returns default port.
115
+ #
116
+ def self.default_port: () -> (nil | Integer)
117
+
118
+ #
119
+ # Returns default port.
120
+ #
121
+ def default_port: () -> (nil | Integer)
122
+
123
+ #
124
+ # An Array of the available components for URI::Generic.
125
+ #
126
+ COMPONENT: Array[Symbol]
127
+
128
+ #
129
+ # Components of the URI in the order.
130
+ #
131
+ def self.component: () -> Array[Symbol]
132
+
133
+ USE_REGISTRY: bool
134
+
135
+ def self.use_registry: () -> bool
136
+
137
+ #
138
+ # == Synopsis
139
+ #
140
+ # See ::new.
141
+ #
142
+ # == Description
143
+ #
144
+ # At first, tries to create a new URI::Generic instance using
145
+ # URI::Generic::build. But, if exception URI::InvalidComponentError is raised,
146
+ # then it does URI::Escape.escape all URI components and tries again.
147
+ #
148
+ def self.build2: (Array[nil | String | Integer]) -> URI::Generic
149
+ | ({ scheme: String, userinfo: String, host: String, port: Integer, registry: String?, path: String, opaque: String?, query: String, fragment: String }) -> URI::Generic
150
+
151
+ #
152
+ # == Synopsis
153
+ #
154
+ # See ::new.
155
+ #
156
+ # == Description
157
+ #
158
+ # Creates a new URI::Generic instance from components of URI::Generic
159
+ # with check. Components are: scheme, userinfo, host, port, registry, path,
160
+ # opaque, query, and fragment. You can provide arguments either by an Array or a Hash.
161
+ # See ::new for hash keys to use or for order of array items.
162
+ #
163
+ def self.build: (Array[nil | String | Integer]) -> URI::Generic
164
+ | ({ scheme: String, userinfo: String, host: String, port: Integer, registry: String?, path: String, opaque: String?, query: String, fragment: String }) -> URI::Generic
165
+
166
+ #
167
+ # == Args
168
+ #
169
+ # +scheme+::
170
+ # Protocol scheme, i.e. 'http','ftp','mailto' and so on.
171
+ # +userinfo+::
172
+ # User name and password, i.e. 'sdmitry:bla'.
173
+ # +host+::
174
+ # Server host name.
175
+ # +port+::
176
+ # Server port.
177
+ # +registry+::
178
+ # Registry of naming authorities.
179
+ # +path+::
180
+ # Path on server.
181
+ # +opaque+::
182
+ # Opaque part.
183
+ # +query+::
184
+ # Query data.
185
+ # +fragment+::
186
+ # Part of the URI after '#' character.
187
+ # +parser+::
188
+ # Parser for internal use [URI::DEFAULT_PARSER by default].
189
+ # +arg_check+::
190
+ # Check arguments [false by default].
191
+ #
192
+ # == Description
193
+ #
194
+ # Creates a new URI::Generic instance from ``generic'' components without check.
195
+ #
196
+ def initialize: (String scheme, String userinfo, String host, Integer port, String? registry, String path, String? opaque, String query, String fragment, ?untyped parser, ?bool arg_check) -> URI::Generic
197
+
198
+ #
199
+ # Returns the scheme component of the URI.
200
+ #
201
+ # URI("http://foo/bar/baz").scheme #=> "http"
202
+ #
203
+ attr_reader scheme: String
204
+
205
+ # Returns the host component of the URI.
206
+ #
207
+ # URI("http://foo/bar/baz").host #=> "foo"
208
+ #
209
+ # It returns nil if no host component exists.
210
+ #
211
+ # URI("mailto:foo@example.org").host #=> nil
212
+ #
213
+ # The component does not contain the port number.
214
+ #
215
+ # URI("http://foo:8080/bar/baz").host #=> "foo"
216
+ #
217
+ # Since IPv6 addresses are wrapped with brackets in URIs,
218
+ # this method returns IPv6 addresses wrapped with brackets.
219
+ # This form is not appropriate to pass to socket methods such as TCPSocket.open.
220
+ # If unwrapped host names are required, use the #hostname method.
221
+ #
222
+ # URI("http://[::1]/bar/baz").host #=> "[::1]"
223
+ # URI("http://[::1]/bar/baz").hostname #=> "::1"
224
+ #
225
+ attr_reader host: String
226
+
227
+ # Returns the port component of the URI.
228
+ #
229
+ # URI("http://foo/bar/baz").port #=> 80
230
+ # URI("http://foo:8080/bar/baz").port #=> 8080
231
+ #
232
+ attr_reader port: Integer
233
+
234
+ def registry: () -> nil
235
+
236
+ # Returns the path component of the URI.
237
+ #
238
+ # URI("http://foo/bar/baz").path #=> "/bar/baz"
239
+ #
240
+ attr_reader path: String
241
+
242
+ # Returns the query component of the URI.
243
+ #
244
+ # URI("http://foo/bar/baz?search=FooBar").query #=> "search=FooBar"
245
+ #
246
+ attr_reader query: String
247
+
248
+ # Returns the opaque part of the URI.
249
+ #
250
+ # URI("mailto:foo@example.org").opaque #=> "foo@example.org"
251
+ # URI("http://foo/bar/baz").opaque #=> nil
252
+ #
253
+ # The portion of the path that does not make use of the slash '/'.
254
+ # The path typically refers to an absolute path or an opaque part.
255
+ # (See RFC2396 Section 3 and 5.2.)
256
+ #
257
+ attr_reader opaque: String?
258
+
259
+ # Returns the fragment component of the URI.
260
+ #
261
+ # URI("http://foo/bar/baz?search=FooBar#ponies").fragment #=> "ponies"
262
+ #
263
+ attr_reader fragment: String
264
+
265
+ # Returns the parser to be used.
266
+ #
267
+ # Unless a URI::Parser is defined, DEFAULT_PARSER is used.
268
+ #
269
+ def parser: () -> untyped
270
+
271
+ # Replaces self by other URI object.
272
+ #
273
+ def replace!: (URI::Generic oth) -> URI::Generic
274
+
275
+ #
276
+ # Components of the URI in the order.
277
+ #
278
+ def component: () -> Array[Symbol]
279
+
280
+ #
281
+ # Checks the scheme +v+ component against the URI::Parser Regexp for :SCHEME.
282
+ #
283
+ def check_scheme: (String v) -> true
284
+
285
+ # Protected setter for the scheme component +v+.
286
+ #
287
+ # See also URI::Generic.scheme=.
288
+ #
289
+ def set_scheme: (String v) -> String
290
+
291
+ #
292
+ # == Args
293
+ #
294
+ # +v+::
295
+ # String
296
+ #
297
+ # == Description
298
+ #
299
+ # Public setter for the scheme component +v+
300
+ # (with validation).
301
+ #
302
+ # See also URI::Generic.check_scheme.
303
+ #
304
+ # == Usage
305
+ #
306
+ # require 'uri'
307
+ #
308
+ # uri = URI.parse("http://my.example.com")
309
+ # uri.scheme = "https"
310
+ # uri.to_s #=> "https://my.example.com"
311
+ #
312
+ def scheme=: (String v) -> String
313
+
314
+ #
315
+ # Checks the +user+ and +password+.
316
+ #
317
+ # If +password+ is not provided, then +user+ is
318
+ # split, using URI::Generic.split_userinfo, to
319
+ # pull +user+ and +password.
320
+ #
321
+ # See also URI::Generic.check_user, URI::Generic.check_password.
322
+ #
323
+ def check_userinfo: (String user, ?String? password) -> true
324
+
325
+ #
326
+ # Checks the user +v+ component for RFC2396 compliance
327
+ # and against the URI::Parser Regexp for :USERINFO.
328
+ #
329
+ # Can not have a registry or opaque component defined,
330
+ # with a user component defined.
331
+ #
332
+ def check_user: (String v) -> (String | true)
333
+
334
+ #
335
+ # Checks the password +v+ component for RFC2396 compliance
336
+ # and against the URI::Parser Regexp for :USERINFO.
337
+ #
338
+ # Can not have a registry or opaque component defined,
339
+ # with a user component defined.
340
+ #
341
+ def check_password: (String v, ?String user) -> (String | true)
342
+
343
+ #
344
+ # Sets userinfo, argument is string like 'name:pass'.
345
+ #
346
+ def userinfo=: (String? userinfo) -> Array[String | nil]?
347
+
348
+ #
349
+ # == Args
350
+ #
351
+ # +v+::
352
+ # String
353
+ #
354
+ # == Description
355
+ #
356
+ # Public setter for the +user+ component
357
+ # (with validation).
358
+ #
359
+ # See also URI::Generic.check_user.
360
+ #
361
+ # == Usage
362
+ #
363
+ # require 'uri'
364
+ #
365
+ # uri = URI.parse("http://john:S3nsit1ve@my.example.com")
366
+ # uri.user = "sam"
367
+ # uri.to_s #=> "http://sam:V3ry_S3nsit1ve@my.example.com"
368
+ #
369
+ def user=: (String user) -> String
370
+
371
+ #
372
+ # == Args
373
+ #
374
+ # +v+::
375
+ # String
376
+ #
377
+ # == Description
378
+ #
379
+ # Public setter for the +password+ component
380
+ # (with validation).
381
+ #
382
+ # See also URI::Generic.check_password.
383
+ #
384
+ # == Usage
385
+ #
386
+ # require 'uri'
387
+ #
388
+ # uri = URI.parse("http://john:S3nsit1ve@my.example.com")
389
+ # uri.password = "V3ry_S3nsit1ve"
390
+ # uri.to_s #=> "http://john:V3ry_S3nsit1ve@my.example.com"
391
+ #
392
+ def password=: (String password) -> String
393
+
394
+ # Protected setter for the +user+ component, and +password+ if available
395
+ # (with validation).
396
+ #
397
+ # See also URI::Generic.userinfo=.
398
+ #
399
+ def set_userinfo: (String user, ?String? password) -> Array[String | nil]
400
+
401
+ # Protected setter for the user component +v+.
402
+ #
403
+ # See also URI::Generic.user=.
404
+ #
405
+ def set_user: (String v) -> String
406
+
407
+ # Protected setter for the password component +v+.
408
+ #
409
+ # See also URI::Generic.password=.
410
+ #
411
+ def set_password: (String v) -> String
412
+
413
+ # Returns the userinfo +ui+ as <code>[user, password]</code>
414
+ # if properly formatted as 'user:password'.
415
+ def split_userinfo: (String ui) -> Array[String | nil]
416
+
417
+ # Escapes 'user:password' +v+ based on RFC 1738 section 3.1.
418
+ def escape_userpass: (String v) -> String
419
+
420
+ # Returns the userinfo, either as 'user' or 'user:password'.
421
+ def userinfo: () -> String?
422
+
423
+ # Returns the user component.
424
+ def user: () -> String
425
+
426
+ # Returns the password component.
427
+ def password: () -> String
428
+
429
+ #
430
+ # Checks the host +v+ component for RFC2396 compliance
431
+ # and against the URI::Parser Regexp for :HOST.
432
+ #
433
+ # Can not have a registry or opaque component defined,
434
+ # with a host component defined.
435
+ #
436
+ def check_host: (String v) -> (String | true)
437
+
438
+ # Protected setter for the host component +v+.
439
+ #
440
+ # See also URI::Generic.host=.
441
+ #
442
+ def set_host: (String v) -> String
443
+
444
+ #
445
+ # == Args
446
+ #
447
+ # +v+::
448
+ # String
449
+ #
450
+ # == Description
451
+ #
452
+ # Public setter for the host component +v+
453
+ # (with validation).
454
+ #
455
+ # See also URI::Generic.check_host.
456
+ #
457
+ # == Usage
458
+ #
459
+ # require 'uri'
460
+ #
461
+ # uri = URI.parse("http://my.example.com")
462
+ # uri.host = "foo.com"
463
+ # uri.to_s #=> "http://foo.com"
464
+ #
465
+ def host=: (String v) -> String
466
+
467
+ # Extract the host part of the URI and unwrap brackets for IPv6 addresses.
468
+ #
469
+ # This method is the same as URI::Generic#host except
470
+ # brackets for IPv6 (and future IP) addresses are removed.
471
+ #
472
+ # uri = URI("http://[::1]/bar")
473
+ # uri.hostname #=> "::1"
474
+ # uri.host #=> "[::1]"
475
+ #
476
+ def hostname: () -> String
477
+
478
+ # Sets the host part of the URI as the argument with brackets for IPv6 addresses.
479
+ #
480
+ # This method is the same as URI::Generic#host= except
481
+ # the argument can be a bare IPv6 address.
482
+ #
483
+ # uri = URI("http://foo/bar")
484
+ # uri.hostname = "::1"
485
+ # uri.to_s #=> "http://[::1]/bar"
486
+ #
487
+ # If the argument seems to be an IPv6 address,
488
+ # it is wrapped with brackets.
489
+ #
490
+ def hostname=: (String v) -> String
491
+
492
+ #
493
+ # Checks the port +v+ component for RFC2396 compliance
494
+ # and against the URI::Parser Regexp for :PORT.
495
+ #
496
+ # Can not have a registry or opaque component defined,
497
+ # with a port component defined.
498
+ #
499
+ def check_port: (Integer v) -> (Integer | true)
500
+
501
+ # Protected setter for the port component +v+.
502
+ #
503
+ # See also URI::Generic.port=.
504
+ #
505
+ def set_port: (Integer v) -> Integer
506
+
507
+ #
508
+ # == Args
509
+ #
510
+ # +v+::
511
+ # String
512
+ #
513
+ # == Description
514
+ #
515
+ # Public setter for the port component +v+
516
+ # (with validation).
517
+ #
518
+ # See also URI::Generic.check_port.
519
+ #
520
+ # == Usage
521
+ #
522
+ # require 'uri'
523
+ #
524
+ # uri = URI.parse("http://my.example.com")
525
+ # uri.port = 8080
526
+ # uri.to_s #=> "http://my.example.com:8080"
527
+ #
528
+ def port=: (Integer v) -> Integer
529
+
530
+ def check_registry: (String v) -> nil
531
+
532
+ def set_registry: (String v) -> nil
533
+
534
+ def registry=: (String v) -> nil
535
+
536
+ #
537
+ # Checks the path +v+ component for RFC2396 compliance
538
+ # and against the URI::Parser Regexp
539
+ # for :ABS_PATH and :REL_PATH.
540
+ #
541
+ # Can not have a opaque component defined,
542
+ # with a path component defined.
543
+ #
544
+ def check_path: (String v) -> true
545
+
546
+ # Protected setter for the path component +v+.
547
+ #
548
+ # See also URI::Generic.path=.
549
+ #
550
+ def set_path: (String v) -> String
551
+
552
+ #
553
+ # == Args
554
+ #
555
+ # +v+::
556
+ # String
557
+ #
558
+ # == Description
559
+ #
560
+ # Public setter for the path component +v+
561
+ # (with validation).
562
+ #
563
+ # See also URI::Generic.check_path.
564
+ #
565
+ # == Usage
566
+ #
567
+ # require 'uri'
568
+ #
569
+ # uri = URI.parse("http://my.example.com/pub/files")
570
+ # uri.path = "/faq/"
571
+ # uri.to_s #=> "http://my.example.com/faq/"
572
+ #
573
+ def path=: (String v) -> String
574
+
575
+ #
576
+ # == Args
577
+ #
578
+ # +v+::
579
+ # String
580
+ #
581
+ # == Description
582
+ #
583
+ # Public setter for the query component +v+.
584
+ #
585
+ # == Usage
586
+ #
587
+ # require 'uri'
588
+ #
589
+ # uri = URI.parse("http://my.example.com/?id=25")
590
+ # uri.query = "id=1"
591
+ # uri.to_s #=> "http://my.example.com/?id=1"
592
+ #
593
+ def query=: (String v) -> String
594
+
595
+ #
596
+ # Checks the opaque +v+ component for RFC2396 compliance and
597
+ # against the URI::Parser Regexp for :OPAQUE.
598
+ #
599
+ # Can not have a host, port, user, or path component defined,
600
+ # with an opaque component defined.
601
+ #
602
+ def check_opaque: (String v) -> (String | true)
603
+
604
+ # Protected setter for the opaque component +v+.
605
+ #
606
+ # See also URI::Generic.opaque=.
607
+ #
608
+ def set_opaque: (String v) -> String
609
+
610
+ #
611
+ # == Args
612
+ #
613
+ # +v+::
614
+ # String
615
+ #
616
+ # == Description
617
+ #
618
+ # Public setter for the opaque component +v+
619
+ # (with validation).
620
+ #
621
+ # See also URI::Generic.check_opaque.
622
+ #
623
+ def opaque=: (String v) -> String
624
+
625
+ #
626
+ # Checks the fragment +v+ component against the URI::Parser Regexp for :FRAGMENT.
627
+ #
628
+ #
629
+ # == Args
630
+ #
631
+ # +v+::
632
+ # String
633
+ #
634
+ # == Description
635
+ #
636
+ # Public setter for the fragment component +v+
637
+ # (with validation).
638
+ #
639
+ # == Usage
640
+ #
641
+ # require 'uri'
642
+ #
643
+ # uri = URI.parse("http://my.example.com/?id=25#time=1305212049")
644
+ # uri.fragment = "time=1305212086"
645
+ # uri.to_s #=> "http://my.example.com/?id=25#time=1305212086"
646
+ #
647
+ def fragment=: (String v) -> String
648
+
649
+ #
650
+ # Returns true if URI is hierarchical.
651
+ #
652
+ # == Description
653
+ #
654
+ # URI has components listed in order of decreasing significance from left to right,
655
+ # see RFC3986 https://tools.ietf.org/html/rfc3986 1.2.3.
656
+ #
657
+ # == Usage
658
+ #
659
+ # require 'uri'
660
+ #
661
+ # uri = URI.parse("http://my.example.com/")
662
+ # uri.hierarchical?
663
+ # #=> true
664
+ # uri = URI.parse("mailto:joe@example.com")
665
+ # uri.hierarchical?
666
+ # #=> false
667
+ #
668
+ def hierarchical?: () -> bool
669
+
670
+ #
671
+ # Returns true if URI has a scheme (e.g. http:// or https://) specified.
672
+ #
673
+ def absolute?: () -> bool
674
+
675
+ #
676
+ # Returns true if URI does not have a scheme (e.g. http:// or https://) specified.
677
+ #
678
+ def relative?: () -> bool
679
+
680
+ #
681
+ # Returns an Array of the path split on '/'.
682
+ #
683
+ def split_path: (String path) -> Array[String]
684
+
685
+ #
686
+ # Merges a base path +base+, with relative path +rel+,
687
+ # returns a modified base path.
688
+ #
689
+ def merge_path: (String base, String rel) -> String
690
+
691
+ #
692
+ # == Args
693
+ #
694
+ # +oth+::
695
+ # URI or String
696
+ #
697
+ # == Description
698
+ #
699
+ # Destructive form of #merge.
700
+ #
701
+ # == Usage
702
+ #
703
+ # require 'uri'
704
+ #
705
+ # uri = URI.parse("http://my.example.com")
706
+ # uri.merge!("/main.rbx?page=1")
707
+ # uri.to_s # => "http://my.example.com/main.rbx?page=1"
708
+ #
709
+ def merge!: (String oth) -> String
710
+
711
+ #
712
+ # == Args
713
+ #
714
+ # +oth+::
715
+ # URI or String
716
+ #
717
+ # == Description
718
+ #
719
+ # Merges two URIs.
720
+ #
721
+ # == Usage
722
+ #
723
+ # require 'uri'
724
+ #
725
+ # uri = URI.parse("http://my.example.com")
726
+ # uri.merge("/main.rbx?page=1")
727
+ # # => "http://my.example.com/main.rbx?page=1"
728
+ #
729
+ def merge: (String oth) -> URI::Generic
730
+
731
+ # :stopdoc:
732
+ def route_from_path: (String src, String dst) -> String
733
+
734
+ # :stopdoc:
735
+ def route_from0: (String oth) -> Array[URI::Generic]
736
+
737
+ #
738
+ # == Args
739
+ #
740
+ # +oth+::
741
+ # URI or String
742
+ #
743
+ # == Description
744
+ #
745
+ # Calculates relative path from oth to self.
746
+ #
747
+ # == Usage
748
+ #
749
+ # require 'uri'
750
+ #
751
+ # uri = URI.parse('http://my.example.com/main.rbx?page=1')
752
+ # uri.route_from('http://my.example.com')
753
+ # #=> #<URI::Generic /main.rbx?page=1>
754
+ #
755
+ def route_from: (String oth) -> URI::Generic
756
+
757
+ #
758
+ # == Args
759
+ #
760
+ # +oth+::
761
+ # URI or String
762
+ #
763
+ # == Description
764
+ #
765
+ # Calculates relative path to oth from self.
766
+ #
767
+ # == Usage
768
+ #
769
+ # require 'uri'
770
+ #
771
+ # uri = URI.parse('http://my.example.com')
772
+ # uri.route_to('http://my.example.com/main.rbx?page=1')
773
+ # #=> #<URI::Generic /main.rbx?page=1>
774
+ #
775
+ def route_to: (String oth) -> URI::Generic
776
+
777
+ #
778
+ # Returns normalized URI.
779
+ #
780
+ # require 'uri'
781
+ #
782
+ # URI("HTTP://my.EXAMPLE.com").normalize
783
+ # #=> #<URI::HTTP http://my.example.com/>
784
+ #
785
+ # Normalization here means:
786
+ #
787
+ # * scheme and host are converted to lowercase,
788
+ # * an empty path component is set to "/".
789
+ #
790
+ def normalize: () -> untyped
791
+
792
+ #
793
+ # Destructive version of #normalize.
794
+ #
795
+ def normalize!: () -> untyped
796
+
797
+ #
798
+ # Constructs String from URI.
799
+ #
800
+ def to_s: () -> String
801
+
802
+ #
803
+ # Compares two URIs.
804
+ #
805
+ def ==: (URI::Generic oth) -> bool
806
+
807
+ def hash: () -> Integer
808
+
809
+ def eql?: (URI::Generic oth) -> bool
810
+
811
+ # Returns an Array of the components defined from the COMPONENT Array.
812
+ def component_ary: () -> Array[nil | String | Integer]
813
+
814
+ # == Args
815
+ #
816
+ # +components+::
817
+ # Multiple Symbol arguments defined in URI::HTTP.
818
+ #
819
+ # == Description
820
+ #
821
+ # Selects specified components from URI.
822
+ #
823
+ # == Usage
824
+ #
825
+ # require 'uri'
826
+ #
827
+ # uri = URI.parse('http://myuser:mypass@my.example.com/test.rbx')
828
+ # uri.select(:userinfo, :host, :path)
829
+ # # => ["myuser:mypass", "my.example.com", "/test.rbx"]
830
+ #
831
+ def select: (*Symbol components) -> Array[nil | String | Integer]
832
+
833
+ def inspect: () -> String
834
+
835
+ #
836
+ # == Args
837
+ #
838
+ # +v+::
839
+ # URI or String
840
+ #
841
+ # == Description
842
+ #
843
+ # Attempts to parse other URI +oth+,
844
+ # returns [parsed_oth, self].
845
+ #
846
+ # == Usage
847
+ #
848
+ # require 'uri'
849
+ #
850
+ # uri = URI.parse("http://my.example.com")
851
+ # uri.coerce("http://foo.com")
852
+ # #=> [#<URI::HTTP http://foo.com>, #<URI::HTTP http://my.example.com>]
853
+ #
854
+ def coerce: ((URI::Generic | String) oth) -> Array[URI::Generic]
855
+
856
+ # Returns a proxy URI.
857
+ # The proxy URI is obtained from environment variables such as http_proxy,
858
+ # ftp_proxy, no_proxy, etc.
859
+ # If there is no proper proxy, nil is returned.
860
+ #
861
+ # If the optional parameter +env+ is specified, it is used instead of ENV.
862
+ #
863
+ # Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.)
864
+ # are examined, too.
865
+ #
866
+ # But http_proxy and HTTP_PROXY is treated specially under CGI environment.
867
+ # It's because HTTP_PROXY may be set by Proxy: header.
868
+ # So HTTP_PROXY is not used.
869
+ # http_proxy is not used too if the variable is case insensitive.
870
+ # CGI_HTTP_PROXY can be used instead.
871
+ def find_proxy: (?String env) -> (nil | URI::Generic)
872
+
873
+ def self.use_proxy?: (String hostname, String addr, Integer port, String no_proxy) -> bool
874
+ end
875
+ end