rbs 0.12.0 → 0.14.0
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/.github/workflows/ruby.yml +10 -10
- data/.gitignore +0 -1
- data/CHANGELOG.md +24 -0
- data/Gemfile +3 -0
- data/README.md +8 -2
- data/Rakefile +9 -4
- data/Steepfile +1 -0
- data/bin/annotate-with-rdoc +1 -1
- data/bin/setup +0 -2
- data/bin/test_runner.rb +3 -6
- data/docs/CONTRIBUTING.md +1 -0
- data/goodcheck.yml +22 -5
- data/lib/rbs/ast/comment.rb +1 -1
- data/lib/rbs/cli.rb +12 -4
- data/lib/rbs/constant.rb +1 -1
- data/lib/rbs/constant_table.rb +9 -8
- data/lib/rbs/definition_builder.rb +4 -5
- data/lib/rbs/environment.rb +5 -1
- data/lib/rbs/environment_loader.rb +12 -12
- data/lib/rbs/namespace.rb +1 -1
- data/lib/rbs/parser.rb +3146 -0
- data/lib/rbs/parser.y +7 -2
- data/lib/rbs/test/setup_helper.rb +4 -4
- data/lib/rbs/test/type_check.rb +2 -2
- data/lib/rbs/type_name.rb +1 -1
- data/lib/rbs/variance_calculator.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +25 -15
- data/sig/constant.rbs +21 -0
- data/sig/constant_table.rbs +30 -0
- data/sig/declarations.rbs +1 -1
- data/sig/definition.rbs +1 -1
- data/sig/definition_builder.rbs +4 -5
- data/sig/environment_loader.rbs +54 -0
- data/sig/namespace.rbs +3 -3
- data/sig/parser.rbs +25 -0
- data/sig/substitution.rbs +3 -3
- data/sig/typename.rbs +1 -1
- data/sig/types.rbs +1 -1
- data/sig/version.rbs +3 -0
- data/sig/writer.rbs +40 -0
- data/stdlib/benchmark/benchmark.rbs +2 -2
- data/stdlib/builtin/basic_object.rbs +54 -54
- data/stdlib/builtin/binding.rbs +42 -42
- data/stdlib/builtin/class.rbs +33 -33
- data/stdlib/builtin/complex.rbs +90 -90
- data/stdlib/builtin/encoding.rbs +33 -33
- data/stdlib/builtin/enumerable.rbs +32 -32
- data/stdlib/builtin/enumerator.rbs +35 -35
- data/stdlib/builtin/errors.rbs +1 -1
- data/stdlib/builtin/exception.rbs +50 -50
- data/stdlib/builtin/false_class.rbs +6 -6
- data/stdlib/builtin/fiber.rbs +14 -14
- data/stdlib/builtin/fiber_error.rbs +1 -1
- data/stdlib/builtin/float.rbs +161 -161
- data/stdlib/builtin/gc.rbs +1 -1
- data/stdlib/builtin/io.rbs +83 -83
- data/stdlib/builtin/kernel.rbs +70 -68
- data/stdlib/builtin/match_data.rbs +1 -1
- data/stdlib/builtin/method.rbs +19 -19
- data/stdlib/builtin/nil_class.rbs +20 -20
- data/stdlib/builtin/numeric.rbs +101 -101
- data/stdlib/builtin/object.rbs +172 -172
- data/stdlib/builtin/proc.rbs +91 -91
- data/stdlib/builtin/range.rbs +2 -4
- data/stdlib/builtin/rational.rbs +83 -83
- data/stdlib/builtin/signal.rbs +7 -7
- data/stdlib/builtin/string.rbs +4 -4
- data/stdlib/builtin/string_io.rbs +1 -1
- data/stdlib/builtin/thread.rbs +185 -185
- data/stdlib/builtin/thread_group.rbs +2 -2
- data/stdlib/builtin/true_class.rbs +9 -9
- data/stdlib/builtin/warning.rbs +1 -1
- data/stdlib/date/date.rbs +2 -2
- data/stdlib/find/find.rbs +10 -10
- data/stdlib/pathname/pathname.rbs +2 -0
- data/stdlib/pty/pty.rbs +5 -29
- data/stdlib/tmpdir/tmpdir.rbs +12 -12
- data/stdlib/uri/generic.rbs +1 -1
- data/stdlib/uri/http.rbs +158 -0
- data/stdlib/uri/https.rbs +108 -0
- data/stdlib/uri/ldap.rbs +224 -0
- data/stdlib/uri/ldaps.rbs +108 -0
- data/steep/Gemfile.lock +13 -17
- metadata +12 -3
@@ -1,11 +1,11 @@
|
|
1
1
|
# [ThreadGroup](ThreadGroup) provides a means of
|
2
2
|
# keeping track of a number of threads as a group.
|
3
|
-
#
|
3
|
+
#
|
4
4
|
# A given [Thread](https://ruby-doc.org/core-2.6.3/Thread.html) object can
|
5
5
|
# only belong to one [ThreadGroup](ThreadGroup) at a
|
6
6
|
# time; adding a thread to a new group will remove it from any previous
|
7
7
|
# group.
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# Newly created threads belong to the same group as the thread from which
|
10
10
|
# they were created.
|
11
11
|
class ThreadGroup < Object
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# The global value `true` is the only instance of class TrueClass and represents
|
2
2
|
# a logically true value in boolean expressions. The class provides operators
|
3
3
|
# allowing `true` to be used in logical expressions.
|
4
|
-
#
|
4
|
+
#
|
5
5
|
class TrueClass
|
6
6
|
public
|
7
7
|
|
8
8
|
def !: () -> bool
|
9
9
|
|
10
10
|
# And---Returns `false` if *obj* is `nil` or `false`, `true` otherwise.
|
11
|
-
#
|
11
|
+
#
|
12
12
|
def &: (nil) -> false
|
13
13
|
| (false) -> false
|
14
14
|
| (untyped obj) -> bool
|
@@ -16,12 +16,12 @@ class TrueClass
|
|
16
16
|
# Case Equality -- For class Object, effectively the same as calling `#==`, but
|
17
17
|
# typically overridden by descendants to provide meaningful semantics in `case`
|
18
18
|
# statements.
|
19
|
-
#
|
19
|
+
#
|
20
20
|
def ===: (true) -> true
|
21
21
|
| (untyped obj) -> bool
|
22
22
|
|
23
23
|
# Exclusive Or---Returns `true` if *obj* is `nil` or `false`, `false` otherwise.
|
24
|
-
#
|
24
|
+
#
|
25
25
|
def ^: (nil) -> true
|
26
26
|
| (false) -> true
|
27
27
|
| (untyped obj) -> bool
|
@@ -29,18 +29,18 @@ class TrueClass
|
|
29
29
|
alias inspect to_s
|
30
30
|
|
31
31
|
# The string representation of `true` is "true".
|
32
|
-
#
|
32
|
+
#
|
33
33
|
def to_s: () -> "true"
|
34
34
|
|
35
35
|
# Or---Returns `true`. As *obj* is an argument to a method call, it is always
|
36
36
|
# evaluated; there is no short-circuit evaluation in this case.
|
37
|
-
#
|
37
|
+
#
|
38
38
|
# true | puts("or")
|
39
39
|
# true || puts("logical or")
|
40
|
-
#
|
40
|
+
#
|
41
41
|
# *produces:*
|
42
|
-
#
|
42
|
+
#
|
43
43
|
# or
|
44
|
-
#
|
44
|
+
#
|
45
45
|
def |: (bool obj) -> bool
|
46
46
|
end
|
data/stdlib/builtin/warning.rbs
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# module extends itself, making `Warning.warn` available.
|
4
4
|
# [\#warn](Warning#method-i-warn) is called for all
|
5
5
|
# warnings issued by Ruby. By default, warnings are printed to $stderr.
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# By overriding [\#warn](Warning#method-i-warn), you
|
8
8
|
# can change how warnings are handled by Ruby, either filtering some
|
9
9
|
# warnings, and/or outputting warnings somewhere other than $stderr. When
|
data/stdlib/date/date.rbs
CHANGED
@@ -318,7 +318,7 @@ class Date
|
|
318
318
|
#
|
319
319
|
def self.ordinal: (?Integer year, ?Integer yday, ?Integer start) -> Date
|
320
320
|
|
321
|
-
# Parses the given representation of date and time, and creates a date object.
|
321
|
+
# Parses the given representation of date and time, and creates a date object.
|
322
322
|
# This method does not function as a validator.
|
323
323
|
#
|
324
324
|
# If the optional second argument is true and the detected year is in the range
|
@@ -448,7 +448,7 @@ class Date
|
|
448
448
|
#
|
449
449
|
def +: (Integer | Rational other) -> Date
|
450
450
|
|
451
|
-
# Returns the difference between the two dates if the other is a date object.
|
451
|
+
# Returns the difference between the two dates if the other is a date object.
|
452
452
|
# If the other is a numeric value, returns a date object pointing `other` days
|
453
453
|
# before self. If the other is a fractional number, assumes its precision is at
|
454
454
|
# most nanosecond.
|
data/stdlib/find/find.rbs
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# The `Find` module supports the top-down traversal of a set of file paths.
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# For example, to total the size of all files under your home directory,
|
4
4
|
# ignoring anything in a "dot" directory (e.g. $HOME/.ssh):
|
5
|
-
#
|
5
|
+
#
|
6
6
|
# require 'find'
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# total_size = 0
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Find.find(ENV["HOME"]) do |path|
|
11
11
|
# if FileTest.directory?(path)
|
12
12
|
# if File.basename(path).start_with?('.')
|
@@ -18,23 +18,23 @@
|
|
18
18
|
# total_size += FileTest.size(path)
|
19
19
|
# end
|
20
20
|
# end
|
21
|
-
#
|
21
|
+
#
|
22
22
|
module Find
|
23
23
|
# Calls the associated block with the name of every file and directory listed as
|
24
24
|
# arguments, then recursively on their subdirectories, and so on.
|
25
|
-
#
|
25
|
+
#
|
26
26
|
# Returns an enumerator if no block is given.
|
27
|
-
#
|
27
|
+
#
|
28
28
|
# See the `Find` module documentation for an example.
|
29
|
-
#
|
29
|
+
#
|
30
30
|
def self?.find: (*String | _ToPath paths, ?ignore_error: bool) -> Enumerator[String, nil]
|
31
31
|
| (*String | _ToPath paths, ?ignore_error: bool) { (String arg0) -> void } -> nil
|
32
32
|
|
33
33
|
# Skips the current file or directory, restarting the loop with the next entry.
|
34
34
|
# If the current file is a directory, that directory will not be recursively
|
35
35
|
# entered. Meaningful only within the block associated with Find::find.
|
36
|
-
#
|
36
|
+
#
|
37
37
|
# See the `Find` module documentation for an example.
|
38
|
-
#
|
38
|
+
#
|
39
39
|
def self?.prune: () -> void
|
40
40
|
end
|
data/stdlib/pty/pty.rbs
CHANGED
@@ -65,34 +65,10 @@ module PTY
|
|
65
65
|
# `raise`
|
66
66
|
# : If `true` and the process identified by `pid` is no longer alive a
|
67
67
|
# PTY::ChildExited is raised.
|
68
|
-
def self.check: (Integer pid) -> (Process::Status | nil)
|
69
|
-
| (Integer pid, FalseClass raise) -> (Process::Status | nil)
|
70
|
-
| (Integer pid, TrueClass raise) -> nil
|
71
|
-
|
72
|
-
# Spawns the specified command on a newly allocated pty. You can also use the
|
73
|
-
# alias ::getpty.
|
74
|
-
#
|
75
|
-
# The command's controlling tty is set to the slave device of the pty and its
|
76
|
-
# standard input/output/error is redirected to the slave device.
|
77
68
|
#
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
# ### Return values
|
82
|
-
#
|
83
|
-
# In the non-block form this returns an array of size three, `[r, w, pid]`.
|
84
|
-
#
|
85
|
-
# In the block form these same values will be yielded to the block:
|
86
|
-
#
|
87
|
-
# `r`
|
88
|
-
# : A readable IO that contains the command's standard output and standard
|
89
|
-
# error
|
90
|
-
# `w`
|
91
|
-
# : A writable IO that is the command's standard input
|
92
|
-
# `pid`
|
93
|
-
# : The process identifier for the command.
|
94
|
-
def self.getpty: (*String command) -> [ IO, IO, Integer ]
|
95
|
-
| (*String command) { ([ IO ,IO , Integer ]) -> untyped } -> untyped
|
69
|
+
def self.check: (Integer pid, ?bool raise) -> Process::Status?
|
70
|
+
|
71
|
+
alias self.getpty self.spawn
|
96
72
|
|
97
73
|
# Allocates a pty (pseudo-terminal).
|
98
74
|
#
|
@@ -130,7 +106,7 @@ module PTY
|
|
130
106
|
# ...
|
131
107
|
# }
|
132
108
|
def self.open: () -> [ IO, File ]
|
133
|
-
| () { ([ IO , File ]) ->
|
109
|
+
| [A] () { ([ IO , File ]) -> A } -> A
|
134
110
|
|
135
111
|
# Spawns the specified command on a newly allocated pty. You can also use the
|
136
112
|
# alias ::getpty.
|
@@ -155,5 +131,5 @@ module PTY
|
|
155
131
|
# `pid`
|
156
132
|
# : The process identifier for the command.
|
157
133
|
def self.spawn: (*String command) -> [ IO, IO, Integer ]
|
158
|
-
| (*String command) {([ IO , IO , Integer ]) ->
|
134
|
+
| (*String command) {([ IO , IO , Integer ]) -> void } -> void
|
159
135
|
end
|
data/stdlib/tmpdir/tmpdir.rbs
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
class Dir
|
2
2
|
# Returns the operating system's temporary file path.
|
3
|
-
#
|
3
|
+
#
|
4
4
|
def self.tmpdir: () -> String
|
5
5
|
|
6
6
|
# Dir.mktmpdir creates a temporary directory.
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# The directory is created with 0700 permission. Application should not change
|
9
9
|
# the permission to make the temporary directory accessible from other users.
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The prefix and suffix of the name of the directory is specified by the
|
12
12
|
# optional first argument, *prefix_suffix*.
|
13
13
|
# * If it is not specified or nil, "d" is used as the prefix and no suffix is
|
@@ -15,30 +15,30 @@ class Dir
|
|
15
15
|
# * If it is a string, it is used as the prefix and no suffix is used.
|
16
16
|
# * If it is an array, first element is used as the prefix and second element
|
17
17
|
# is used as a suffix.
|
18
|
-
#
|
19
|
-
#
|
18
|
+
#
|
19
|
+
#
|
20
20
|
# Dir.mktmpdir {|dir| dir is ".../d..." }
|
21
21
|
# Dir.mktmpdir("foo") {|dir| dir is ".../foo..." }
|
22
22
|
# Dir.mktmpdir(["foo", "bar"]) {|dir| dir is ".../foo...bar" }
|
23
|
-
#
|
23
|
+
#
|
24
24
|
# The directory is created under Dir.tmpdir or the optional second argument
|
25
25
|
# *tmpdir* if non-nil value is given.
|
26
|
-
#
|
26
|
+
#
|
27
27
|
# Dir.mktmpdir {|dir| dir is "#{Dir.tmpdir}/d..." }
|
28
28
|
# Dir.mktmpdir(nil, "/var/tmp") {|dir| dir is "/var/tmp/d..." }
|
29
|
-
#
|
29
|
+
#
|
30
30
|
# If a block is given, it is yielded with the path of the directory. The
|
31
31
|
# directory and its contents are removed using FileUtils.remove_entry before
|
32
32
|
# Dir.mktmpdir returns. The value of the block is returned.
|
33
|
-
#
|
33
|
+
#
|
34
34
|
# Dir.mktmpdir {|dir|
|
35
35
|
# # use the directory...
|
36
36
|
# open("#{dir}/foo", "w") { ... }
|
37
37
|
# }
|
38
|
-
#
|
38
|
+
#
|
39
39
|
# If a block is not given, The path of the directory is returned. In this case,
|
40
40
|
# Dir.mktmpdir doesn't remove the directory.
|
41
|
-
#
|
41
|
+
#
|
42
42
|
# dir = Dir.mktmpdir
|
43
43
|
# begin
|
44
44
|
# # use the directory...
|
@@ -47,7 +47,7 @@ class Dir
|
|
47
47
|
# # remove the directory.
|
48
48
|
# FileUtils.remove_entry dir
|
49
49
|
# end
|
50
|
-
#
|
50
|
+
#
|
51
51
|
def self.mktmpdir: (?(String | [ String, String ] | nil), ?String?, ?max_try: Integer?) -> String
|
52
52
|
| [X] (?(String | [ String, String ] | nil), ?String?, ?max_try: Integer?) { (String) -> X } -> X
|
53
53
|
end
|
data/stdlib/uri/generic.rbs
CHANGED
@@ -851,7 +851,7 @@ module URI
|
|
851
851
|
# uri.coerce("http://foo.com")
|
852
852
|
# #=> [#<URI::HTTP http://foo.com>, #<URI::HTTP http://my.example.com>]
|
853
853
|
#
|
854
|
-
def coerce: (
|
854
|
+
def coerce: (URI::Generic | String oth) -> Array[URI::Generic]
|
855
855
|
|
856
856
|
# Returns a proxy URI.
|
857
857
|
# The proxy URI is obtained from environment variables such as http_proxy,
|
data/stdlib/uri/http.rbs
ADDED
@@ -0,0 +1,158 @@
|
|
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 syntax of HTTP URIs is defined in RFC1738 section 3.3.
|
103
|
+
#
|
104
|
+
# Note that the Ruby URI library allows HTTP URLs containing usernames and
|
105
|
+
# passwords. This is not legal as per the RFC, but used to be
|
106
|
+
# supported in Internet Explorer 5 and 6, before the MS04-004 security
|
107
|
+
# update. See <URL:http://support.microsoft.com/kb/834489>.
|
108
|
+
#
|
109
|
+
class HTTP < Generic
|
110
|
+
# A Default port of 80 for URI::HTTP.
|
111
|
+
DEFAULT_PORT: Integer
|
112
|
+
|
113
|
+
# An Array of the available components for URI::HTTP.
|
114
|
+
COMPONENT: Array[Symbol]
|
115
|
+
|
116
|
+
#
|
117
|
+
# == Description
|
118
|
+
#
|
119
|
+
# Creates a new URI::HTTP object from components, with syntax checking.
|
120
|
+
#
|
121
|
+
# The components accepted are userinfo, host, port, path, query, and
|
122
|
+
# fragment.
|
123
|
+
#
|
124
|
+
# The components should be provided either as an Array, or as a Hash
|
125
|
+
# with keys formed by preceding the component names with a colon.
|
126
|
+
#
|
127
|
+
# If an Array is used, the components must be passed in the
|
128
|
+
# order <code>[userinfo, host, port, path, query, fragment]</code>.
|
129
|
+
#
|
130
|
+
# Example:
|
131
|
+
#
|
132
|
+
# uri = URI::HTTP.build(host: 'www.example.com', path: '/foo/bar')
|
133
|
+
#
|
134
|
+
# uri = URI::HTTP.build([nil, "www.example.com", nil, "/path",
|
135
|
+
# "query", 'fragment'])
|
136
|
+
#
|
137
|
+
# Currently, if passed userinfo components this method generates
|
138
|
+
# invalid HTTP URIs as per RFC 1738.
|
139
|
+
#
|
140
|
+
def self.build: (Array[String | Integer] args) -> URI::HTTP
|
141
|
+
| ({ userinfo: String, host: String, port: Integer, path: String, query: String, fragment: String }) -> URI::HTTP
|
142
|
+
|
143
|
+
#
|
144
|
+
# == Description
|
145
|
+
#
|
146
|
+
# Returns the full path for an HTTP request, as required by Net::HTTP::Get.
|
147
|
+
#
|
148
|
+
# If the URI contains a query, the full path is URI#path + '?' + URI#query.
|
149
|
+
# Otherwise, the path is simply URI#path.
|
150
|
+
#
|
151
|
+
# Example:
|
152
|
+
#
|
153
|
+
# uri = URI::HTTP.build(path: '/foo/bar', query: 'test=true')
|
154
|
+
# uri.request_uri # => "/foo/bar?test=true"
|
155
|
+
#
|
156
|
+
def request_uri: () -> String
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,108 @@
|
|
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
|
+
# The default port for HTTPS URIs is 443, and the scheme is 'https:' rather
|
102
|
+
# than 'http:'. Other than that, HTTPS URIs are identical to HTTP URIs;
|
103
|
+
# see URI::HTTP.
|
104
|
+
class HTTPS < HTTP
|
105
|
+
# A Default port of 443 for URI::HTTPS
|
106
|
+
DEFAULT_PORT: Integer
|
107
|
+
end
|
108
|
+
end
|