rbs 3.2.0 → 3.3.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/comments.yml +1 -1
- data/.github/workflows/ruby.yml +7 -2
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +134 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +21 -15
- data/README.md +11 -2
- data/Rakefile +10 -7
- data/Steepfile +7 -7
- data/core/basic_object.rbs +7 -7
- data/core/binding.rbs +3 -3
- data/core/builtin.rbs +171 -5
- data/core/constants.rbs +17 -17
- data/core/dir.rbs +3 -3
- data/core/encoding.rbs +434 -628
- data/core/enumerator.rbs +37 -0
- data/core/exception.rbs +11 -11
- data/core/false_class.rbs +5 -11
- data/core/fiber.rbs +5 -5
- data/core/file_test.rbs +28 -26
- data/core/kernel.rbs +900 -21
- data/core/marshal.rbs +24 -14
- data/core/match_data.rbs +8 -8
- data/core/math.rbs +57 -53
- data/core/method.rbs +3 -1
- data/core/module.rbs +38 -36
- data/core/nil_class.rbs +7 -13
- data/core/object.rbs +3 -966
- data/core/process.rbs +3 -3
- data/core/ractor.rbs +2 -2
- data/core/rb_config.rbs +64 -43
- data/core/regexp.rbs +3 -3
- data/core/set.rbs +3 -2
- data/core/signal.rbs +10 -4
- data/core/struct.rbs +1 -1
- data/core/thread.rbs +7 -7
- data/core/thread_group.rbs +9 -9
- data/core/true_class.rbs +5 -11
- data/core/unbound_method.rbs +56 -7
- data/core/warning.rbs +33 -0
- data/docs/collection.md +56 -6
- data/docs/data_and_struct.md +57 -0
- data/docs/stdlib.md +61 -2
- data/docs/syntax.md +123 -2
- data/ext/rbs_extension/constants.c +73 -72
- data/ext/rbs_extension/lexer.c +624 -569
- data/ext/rbs_extension/lexer.h +1 -0
- data/ext/rbs_extension/lexer.re +1 -0
- data/ext/rbs_extension/lexstate.c +1 -0
- data/ext/rbs_extension/parser.c +6 -0
- data/goodcheck.yml +2 -2
- data/lib/rbs/annotate/formatter.rb +13 -3
- data/lib/rbs/annotate/rdoc_source.rb +10 -1
- data/lib/rbs/cli/colored_io.rb +48 -0
- data/lib/rbs/cli/diff.rb +80 -0
- data/lib/rbs/cli.rb +169 -17
- data/lib/rbs/collection/config/lockfile.rb +0 -25
- data/lib/rbs/collection/config/lockfile_generator.rb +0 -6
- data/lib/rbs/collection/installer.rb +1 -1
- data/lib/rbs/collection/sources/git.rb +6 -4
- data/lib/rbs/collection/sources/local.rb +7 -5
- data/lib/rbs/diff.rb +121 -0
- data/lib/rbs/environment.rb +7 -4
- data/lib/rbs/method_type.rb +23 -0
- data/lib/rbs/prototype/rb.rb +2 -9
- data/lib/rbs/prototype/rbi.rb +1 -1
- data/lib/rbs/prototype/runtime/helpers.rb +59 -0
- data/lib/rbs/prototype/runtime/reflection.rb +19 -0
- data/lib/rbs/prototype/runtime/value_object_generator.rb +275 -0
- data/lib/rbs/prototype/runtime.rb +233 -153
- data/lib/rbs/resolver/constant_resolver.rb +1 -1
- data/lib/rbs/sorter.rb +144 -117
- data/lib/rbs/test/guaranteed.rb +31 -0
- data/lib/rbs/test/type_check.rb +4 -4
- data/lib/rbs/test.rb +3 -0
- data/lib/rbs/types.rb +184 -3
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +4 -4
- data/lib/rbs.rb +1 -0
- data/rbs.gemspec +1 -0
- data/sig/annotate/formatter.rbs +2 -2
- data/sig/annotate/rdoc_annotater.rbs +1 -1
- data/sig/cli/colored_io.rbs +15 -0
- data/sig/cli/diff.rbs +21 -0
- data/sig/cli.rbs +2 -0
- data/sig/collection/config/lockfile.rbs +0 -6
- data/sig/diff.rbs +23 -0
- data/sig/errors.rbs +1 -5
- data/sig/method_types.rbs +6 -0
- data/sig/prototype/runtime.rbs +166 -0
- data/sig/rdoc/rbs.rbs +4 -0
- data/sig/shims/bundler.rbs +5 -0
- data/sig/sorter.rbs +23 -5
- data/sig/types.rbs +29 -0
- data/stdlib/benchmark/0/benchmark.rbs +1 -1
- data/stdlib/cgi/0/core.rbs +2 -2
- data/stdlib/did_you_mean/0/did_you_mean.rbs +2 -2
- data/stdlib/digest/0/digest.rbs +1 -1
- data/stdlib/fileutils/0/fileutils.rbs +1 -1
- data/stdlib/forwardable/0/forwardable.rbs +4 -4
- data/stdlib/io-console/0/io-console.rbs +1 -1
- data/stdlib/json/0/json.rbs +37 -0
- data/stdlib/logger/0/logger.rbs +2 -2
- data/stdlib/net-http/0/manifest.yaml +1 -1
- data/stdlib/net-http/0/net-http.rbs +16 -63
- data/stdlib/net-protocol/0/manifest.yaml +2 -0
- data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
- data/stdlib/net-smtp/0/manifest.yaml +2 -0
- data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
- data/stdlib/open-uri/0/manifest.yaml +3 -0
- data/stdlib/open-uri/0/open-uri.rbs +341 -0
- data/stdlib/openssl/0/openssl.rbs +1 -1
- data/stdlib/pp/0/manifest.yaml +2 -0
- data/stdlib/pp/0/pp.rbs +301 -0
- data/stdlib/{yaml → psych}/0/dbm.rbs +3 -3
- data/stdlib/psych/0/manifest.yaml +3 -0
- data/stdlib/psych/0/psych.rbs +391 -0
- data/stdlib/{yaml → psych}/0/store.rbs +2 -2
- data/stdlib/rdoc/0/code_object.rbs +55 -0
- data/stdlib/rdoc/0/comment.rbs +60 -0
- data/stdlib/rdoc/0/context.rbs +153 -0
- data/stdlib/rdoc/0/markup.rbs +119 -0
- data/stdlib/rdoc/0/parser.rbs +56 -0
- data/stdlib/rdoc/0/rdoc.rbs +0 -372
- data/stdlib/rdoc/0/ri.rbs +17 -0
- data/stdlib/rdoc/0/store.rbs +48 -0
- data/stdlib/rdoc/0/top_level.rbs +97 -0
- data/stdlib/socket/0/basic_socket.rbs +1 -1
- data/stdlib/socket/0/socket.rbs +1 -1
- data/stdlib/uri/0/common.rbs +1 -1
- data/stdlib/yaml/0/manifest.yaml +1 -2
- data/stdlib/yaml/0/yaml.rbs +1 -199
- metadata +49 -7
- data/sig/shims/pp.rbs +0 -3
- data/sig/shims.rbs +0 -47
@@ -1,59 +1,10 @@
|
|
1
1
|
module Net
|
2
|
-
class Protocol
|
3
|
-
VERSION: String
|
4
|
-
end
|
5
|
-
|
6
|
-
class ProtocolError < StandardError
|
7
|
-
end
|
8
|
-
|
9
|
-
class ProtoSyntaxError < ProtocolError
|
10
|
-
end
|
11
|
-
|
12
|
-
class ProtoFatalError < ProtocolError
|
13
|
-
end
|
14
|
-
|
15
|
-
class ProtoUnknownError < ProtocolError
|
16
|
-
end
|
17
|
-
|
18
|
-
class ProtoServerError < ProtocolError
|
19
|
-
end
|
20
|
-
|
21
|
-
class ProtoAuthError < ProtocolError
|
22
|
-
end
|
23
|
-
|
24
|
-
class ProtoCommandError < ProtocolError
|
25
|
-
end
|
26
|
-
|
27
|
-
class ProtoRetriableError < ProtocolError
|
28
|
-
end
|
29
|
-
|
30
2
|
class HTTPBadResponse < StandardError
|
31
3
|
end
|
32
4
|
|
33
5
|
class HTTPHeaderSyntaxError < StandardError
|
34
6
|
end
|
35
7
|
|
36
|
-
# <!-- rdoc-file=lib/net/protocol.rb -->
|
37
|
-
# OpenTimeout, a subclass of Timeout::Error, is raised if a connection cannot be
|
38
|
-
# created within the open_timeout.
|
39
|
-
#
|
40
|
-
class OpenTimeout < Timeout::Error
|
41
|
-
end
|
42
|
-
|
43
|
-
# <!-- rdoc-file=lib/net/protocol.rb -->
|
44
|
-
# ReadTimeout, a subclass of Timeout::Error, is raised if a chunk of the
|
45
|
-
# response cannot be read within the read_timeout.
|
46
|
-
#
|
47
|
-
class ReadTimeout < Timeout::Error
|
48
|
-
end
|
49
|
-
|
50
|
-
# <!-- rdoc-file=lib/net/protocol.rb -->
|
51
|
-
# WriteTimeout, a subclass of Timeout::Error, is raised if a chunk of the
|
52
|
-
# response cannot be written within the write_timeout. Not raised on Windows.
|
53
|
-
#
|
54
|
-
class WriteTimeout < Timeout::Error
|
55
|
-
end
|
56
|
-
|
57
8
|
# <!-- rdoc-file=lib/net/http.rb -->
|
58
9
|
# Class Net::HTTP provides a rich library that implements the client in a
|
59
10
|
# client-server model that uses the HTTP request-response protocol. For
|
@@ -1128,7 +1079,7 @@ module Net
|
|
1128
1079
|
# This class is obsolete. You may pass these same parameters directly to
|
1129
1080
|
# Net::HTTP.new. See Net::HTTP.new for details of the arguments.
|
1130
1081
|
#
|
1131
|
-
def self.Proxy: (?
|
1082
|
+
def self.Proxy: (?interned p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass) -> untyped
|
1132
1083
|
|
1133
1084
|
# <!--
|
1134
1085
|
# rdoc-file=lib/net/http.rb
|
@@ -1836,7 +1787,9 @@ module Net
|
|
1836
1787
|
|
1837
1788
|
alias length size
|
1838
1789
|
|
1839
|
-
|
1790
|
+
# A previous incarnation of `interned` for backward-compatibility (see #1499)
|
1791
|
+
%a{steep:deprecated}
|
1792
|
+
type key = interned
|
1840
1793
|
|
1841
1794
|
# <!--
|
1842
1795
|
# rdoc-file=lib/net/http/header.rb
|
@@ -1852,7 +1805,7 @@ module Net
|
|
1852
1805
|
# Note that some field values may be retrieved via convenience methods; see
|
1853
1806
|
# [Getters](rdoc-ref:Net::HTTPHeader@Getters).
|
1854
1807
|
#
|
1855
|
-
def []: (
|
1808
|
+
def []: (interned key) -> (nil | String)
|
1856
1809
|
|
1857
1810
|
# <!--
|
1858
1811
|
# rdoc-file=lib/net/http/header.rb
|
@@ -1870,7 +1823,7 @@ module Net
|
|
1870
1823
|
# Note that some field values may be set via convenience methods; see
|
1871
1824
|
# [Setters](rdoc-ref:Net::HTTPHeader@Setters).
|
1872
1825
|
#
|
1873
|
-
def []=: (
|
1826
|
+
def []=: (interned key, untyped val) -> void
|
1874
1827
|
|
1875
1828
|
# <!--
|
1876
1829
|
# rdoc-file=lib/net/http/header.rb
|
@@ -1889,7 +1842,7 @@ module Net
|
|
1889
1842
|
# req['Foo'] # => "bar, baz, baz, bam"
|
1890
1843
|
# req.get_fields('Foo') # => ["bar", "baz", "baz", "bam"]
|
1891
1844
|
#
|
1892
|
-
def add_field: (
|
1845
|
+
def add_field: (interned key, untyped val) -> void
|
1893
1846
|
|
1894
1847
|
private
|
1895
1848
|
|
@@ -1898,7 +1851,7 @@ module Net
|
|
1898
1851
|
# - set_field(key, val)
|
1899
1852
|
# -->
|
1900
1853
|
#
|
1901
|
-
def set_field: (
|
1854
|
+
def set_field: (interned key, untyped val) -> void
|
1902
1855
|
|
1903
1856
|
# <!--
|
1904
1857
|
# rdoc-file=lib/net/http/header.rb
|
@@ -1920,7 +1873,7 @@ module Net
|
|
1920
1873
|
# res.get_fields('Connection') # => ["keep-alive"]
|
1921
1874
|
# res.get_fields('Nosuch') # => nil
|
1922
1875
|
#
|
1923
|
-
def get_fields: (
|
1876
|
+
def get_fields: (interned key) -> (nil | Array[String])
|
1924
1877
|
|
1925
1878
|
# <!--
|
1926
1879
|
# rdoc-file=lib/net/http/header.rb
|
@@ -1950,9 +1903,9 @@ module Net
|
|
1950
1903
|
# res.fetch('Nosuch', 'Foo') # => "Foo"
|
1951
1904
|
# res.fetch('Nosuch') # Raises KeyError.
|
1952
1905
|
#
|
1953
|
-
def fetch: (
|
1954
|
-
| (
|
1955
|
-
| (
|
1906
|
+
def fetch: (interned key) -> String
|
1907
|
+
| (interned key, untyped) -> untyped
|
1908
|
+
| (interned key) { (String) -> untyped } -> untyped
|
1956
1909
|
|
1957
1910
|
# <!--
|
1958
1911
|
# rdoc-file=lib/net/http/header.rb
|
@@ -2081,7 +2034,7 @@ module Net
|
|
2081
2034
|
# req.delete('Accept') # => ["*/*"]
|
2082
2035
|
# req.delete('Nosuch') # => nil
|
2083
2036
|
#
|
2084
|
-
def delete: (
|
2037
|
+
def delete: (interned key) -> (Array[String] | nil)
|
2085
2038
|
|
2086
2039
|
# <!--
|
2087
2040
|
# rdoc-file=lib/net/http/header.rb
|
@@ -2094,7 +2047,7 @@ module Net
|
|
2094
2047
|
# req.key?('Accept') # => true
|
2095
2048
|
# req.key?('Nosuch') # => false
|
2096
2049
|
#
|
2097
|
-
def key?: (
|
2050
|
+
def key?: (interned key) -> bool
|
2098
2051
|
|
2099
2052
|
# <!--
|
2100
2053
|
# rdoc-file=lib/net/http/header.rb
|
@@ -2138,7 +2091,7 @@ module Net
|
|
2138
2091
|
# - capitalize(name)
|
2139
2092
|
# -->
|
2140
2093
|
#
|
2141
|
-
def capitalize: (
|
2094
|
+
def capitalize: (interned name) -> String
|
2142
2095
|
|
2143
2096
|
public
|
2144
2097
|
|
@@ -2361,7 +2314,7 @@ module Net
|
|
2361
2314
|
# Net::HTTPHeader#content_type= is an alias for
|
2362
2315
|
# Net::HTTPHeader#set_content_type.
|
2363
2316
|
#
|
2364
|
-
def set_content_type: (
|
2317
|
+
def set_content_type: (interned `type`, ?Hash[untyped, untyped] params) -> void
|
2365
2318
|
|
2366
2319
|
# <!--
|
2367
2320
|
# rdoc-file=lib/net/http/header.rb
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Net
|
2
|
+
class Protocol
|
3
|
+
VERSION: String
|
4
|
+
end
|
5
|
+
|
6
|
+
class ProtocolError < StandardError
|
7
|
+
end
|
8
|
+
|
9
|
+
class ProtoSyntaxError < ProtocolError
|
10
|
+
end
|
11
|
+
|
12
|
+
class ProtoFatalError < ProtocolError
|
13
|
+
end
|
14
|
+
|
15
|
+
class ProtoUnknownError < ProtocolError
|
16
|
+
end
|
17
|
+
|
18
|
+
class ProtoServerError < ProtocolError
|
19
|
+
end
|
20
|
+
|
21
|
+
class ProtoAuthError < ProtocolError
|
22
|
+
end
|
23
|
+
|
24
|
+
class ProtoCommandError < ProtocolError
|
25
|
+
end
|
26
|
+
|
27
|
+
class ProtoRetriableError < ProtocolError
|
28
|
+
end
|
29
|
+
|
30
|
+
class HTTPBadResponse < StandardError
|
31
|
+
end
|
32
|
+
|
33
|
+
class HTTPHeaderSyntaxError < StandardError
|
34
|
+
end
|
35
|
+
|
36
|
+
# <!-- rdoc-file=lib/net/protocol.rb -->
|
37
|
+
# OpenTimeout, a subclass of Timeout::Error, is raised if a connection cannot be
|
38
|
+
# created within the open_timeout.
|
39
|
+
#
|
40
|
+
class OpenTimeout < Timeout::Error
|
41
|
+
end
|
42
|
+
|
43
|
+
# <!-- rdoc-file=lib/net/protocol.rb -->
|
44
|
+
# ReadTimeout, a subclass of Timeout::Error, is raised if a chunk of the
|
45
|
+
# response cannot be read within the read_timeout.
|
46
|
+
#
|
47
|
+
class ReadTimeout < Timeout::Error
|
48
|
+
end
|
49
|
+
|
50
|
+
# <!-- rdoc-file=lib/net/protocol.rb -->
|
51
|
+
# WriteTimeout, a subclass of Timeout::Error, is raised if a chunk of the
|
52
|
+
# response cannot be written within the write_timeout. Not raised on Windows.
|
53
|
+
#
|
54
|
+
class WriteTimeout < Timeout::Error
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Net
|
2
|
+
# Module mixed in to all SMTP error classes
|
3
|
+
module SMTPError
|
4
|
+
attr_reader response: Response
|
5
|
+
|
6
|
+
def initialize: (Response response, ?message: String) -> void
|
7
|
+
|
8
|
+
def message: () -> String?
|
9
|
+
end
|
10
|
+
|
11
|
+
# Represents an SMTP authentication error.
|
12
|
+
class SMTPAuthenticationError < ProtoAuthError
|
13
|
+
include SMTPError
|
14
|
+
end
|
15
|
+
|
16
|
+
# Represents SMTP error code 4xx, a temporary error.
|
17
|
+
class SMTPServerBusy < ProtoServerError
|
18
|
+
include SMTPError
|
19
|
+
end
|
20
|
+
|
21
|
+
# Represents an SMTP command syntax error (error code 500)
|
22
|
+
class SMTPSyntaxError < ProtoSyntaxError
|
23
|
+
include SMTPError
|
24
|
+
end
|
25
|
+
|
26
|
+
# Represents a fatal SMTP error (error code 5xx, except for 500)
|
27
|
+
class SMTPFatalError < ProtoFatalError
|
28
|
+
include SMTPError
|
29
|
+
end
|
30
|
+
|
31
|
+
# Unexpected reply code returned from server.
|
32
|
+
class SMTPUnknownError < ProtoUnknownError
|
33
|
+
include SMTPError
|
34
|
+
end
|
35
|
+
|
36
|
+
# Command is not supported on server.
|
37
|
+
class SMTPUnsupportedCommand < ProtocolError
|
38
|
+
include SMTPError
|
39
|
+
end
|
40
|
+
|
41
|
+
class SMTP < Protocol
|
42
|
+
def self.start: (String address, ?Integer port, ?tls_verify: bool, ?tls_hostname: String?, ?helo: String, ?user: String?, ?password: String?, ?auth_type: Symbol) -> instance
|
43
|
+
| [T] (String address, ?Integer port, ?tls_verify: bool, ?tls_hostname: String?, ?helo: String, ?user: String?, ?password: String?, ?auth_type: Symbol) { (instance) -> T } -> T
|
44
|
+
| (String address, ?Integer port, ?String helo, ?String? user, ?String? password, ?Symbol auth_type) -> instance
|
45
|
+
| [T] (String address, ?Integer port, ?String helo, ?String? user, ?String? password, ?Symbol auth_type) { (instance) -> T } -> T
|
46
|
+
|
47
|
+
def initialize: (String address, ?Integer port) -> void
|
48
|
+
def send_message: (_Each[String] mail_src, String from_addr, *String to_addrs) -> void
|
49
|
+
end
|
50
|
+
|
51
|
+
class Response
|
52
|
+
end
|
53
|
+
|
54
|
+
class SMTPSession = SMTP
|
55
|
+
end
|
@@ -0,0 +1,341 @@
|
|
1
|
+
%a{annotate:rdoc:skip}
|
2
|
+
module URI
|
3
|
+
# <!--
|
4
|
+
# rdoc-file=lib/open-uri.rb
|
5
|
+
# - open(name, *rest, &block)
|
6
|
+
# -->
|
7
|
+
# Allows the opening of various resources including URIs.
|
8
|
+
#
|
9
|
+
# If the first argument responds to the 'open' method, 'open' is called on it
|
10
|
+
# with the rest of the arguments.
|
11
|
+
#
|
12
|
+
# If the first argument is a string that begins with `(protocol)://`, it is
|
13
|
+
# parsed by URI.parse. If the parsed object responds to the 'open' method,
|
14
|
+
# 'open' is called on it with the rest of the arguments.
|
15
|
+
#
|
16
|
+
# Otherwise, Kernel#open is called.
|
17
|
+
#
|
18
|
+
# OpenURI::OpenRead#open provides URI::HTTP#open, URI::HTTPS#open and
|
19
|
+
# URI::FTP#open, Kernel#open.
|
20
|
+
#
|
21
|
+
# We can accept URIs and strings that begin with http://, https:// and ftp://.
|
22
|
+
# In these cases, the opened file object is extended by OpenURI::Meta.
|
23
|
+
#
|
24
|
+
def self.open: (String name, ?String mode, ?Integer perm, ?untyped options) -> (StringIO & OpenURI::Meta | Tempfile & OpenURI::Meta)
|
25
|
+
| [T] (String name, ?String mode, ?Integer perm, ?untyped options) { (StringIO | Tempfile) -> T } -> T
|
26
|
+
end
|
27
|
+
|
28
|
+
# <!-- rdoc-file=lib/open-uri.rb -->
|
29
|
+
# OpenURI is an easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP.
|
30
|
+
#
|
31
|
+
# ## Example
|
32
|
+
#
|
33
|
+
# It is possible to open an http, https or ftp URL as though it were a file:
|
34
|
+
#
|
35
|
+
# URI.open("http://www.ruby-lang.org/") {|f|
|
36
|
+
# f.each_line {|line| p line}
|
37
|
+
# }
|
38
|
+
#
|
39
|
+
# The opened file has several getter methods for its meta-information, as
|
40
|
+
# follows, since it is extended by OpenURI::Meta.
|
41
|
+
#
|
42
|
+
# URI.open("http://www.ruby-lang.org/en") {|f|
|
43
|
+
# f.each_line {|line| p line}
|
44
|
+
# p f.base_uri # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/>
|
45
|
+
# p f.content_type # "text/html"
|
46
|
+
# p f.charset # "iso-8859-1"
|
47
|
+
# p f.content_encoding # []
|
48
|
+
# p f.last_modified # Thu Dec 05 02:45:02 UTC 2002
|
49
|
+
# }
|
50
|
+
#
|
51
|
+
# Additional header fields can be specified by an optional hash argument.
|
52
|
+
#
|
53
|
+
# URI.open("http://www.ruby-lang.org/en/",
|
54
|
+
# "User-Agent" => "Ruby/#{RUBY_VERSION}",
|
55
|
+
# "From" => "foo@bar.invalid",
|
56
|
+
# "Referer" => "http://www.ruby-lang.org/") {|f|
|
57
|
+
# # ...
|
58
|
+
# }
|
59
|
+
#
|
60
|
+
# The environment variables such as http_proxy, https_proxy and ftp_proxy are in
|
61
|
+
# effect by default. Here we disable proxy:
|
62
|
+
#
|
63
|
+
# URI.open("http://www.ruby-lang.org/en/", :proxy => nil) {|f|
|
64
|
+
# # ...
|
65
|
+
# }
|
66
|
+
#
|
67
|
+
# See OpenURI::OpenRead.open and URI.open for more on available options.
|
68
|
+
#
|
69
|
+
# URI objects can be opened in a similar way.
|
70
|
+
#
|
71
|
+
# uri = URI.parse("http://www.ruby-lang.org/en/")
|
72
|
+
# uri.open {|f|
|
73
|
+
# # ...
|
74
|
+
# }
|
75
|
+
#
|
76
|
+
# URI objects can be read directly. The returned string is also extended by
|
77
|
+
# OpenURI::Meta.
|
78
|
+
#
|
79
|
+
# str = uri.read
|
80
|
+
# p str.base_uri
|
81
|
+
#
|
82
|
+
# Author
|
83
|
+
# : Tanaka Akira <akr@m17n.org>
|
84
|
+
#
|
85
|
+
module OpenURI
|
86
|
+
# <!-- rdoc-file=lib/open-uri.rb -->
|
87
|
+
# Mixin for holding meta-information.
|
88
|
+
#
|
89
|
+
module Meta
|
90
|
+
# <!-- rdoc-file=lib/open-uri.rb -->
|
91
|
+
# returns an Array that consists of status code and message.
|
92
|
+
#
|
93
|
+
attr_accessor status: [ String, String ]
|
94
|
+
|
95
|
+
# <!-- rdoc-file=lib/open-uri.rb -->
|
96
|
+
# returns a URI that is the base of relative URIs in the data. It may differ
|
97
|
+
# from the URI supplied by a user due to redirection.
|
98
|
+
#
|
99
|
+
attr_accessor base_uri: URI::Generic
|
100
|
+
|
101
|
+
# <!-- rdoc-file=lib/open-uri.rb -->
|
102
|
+
# returns a Hash that represents header fields. The Hash keys are downcased for
|
103
|
+
# canonicalization. The Hash values are a field body. If there are multiple
|
104
|
+
# field with same field name, the field values are concatenated with a comma.
|
105
|
+
#
|
106
|
+
attr_reader meta: Hash[String, String]
|
107
|
+
|
108
|
+
# <!--
|
109
|
+
# rdoc-file=lib/open-uri.rb
|
110
|
+
# - last_modified()
|
111
|
+
# -->
|
112
|
+
# returns a Time that represents the Last-Modified field.
|
113
|
+
#
|
114
|
+
def last_modified: () -> Time?
|
115
|
+
|
116
|
+
# <!--
|
117
|
+
# rdoc-file=lib/open-uri.rb
|
118
|
+
# - content_type()
|
119
|
+
# -->
|
120
|
+
# returns "type/subtype" which is MIME Content-Type. It is downcased for
|
121
|
+
# canonicalization. Content-Type parameters are stripped.
|
122
|
+
#
|
123
|
+
def content_type: () -> String
|
124
|
+
|
125
|
+
def charet: () -> String?
|
126
|
+
|
127
|
+
# <!--
|
128
|
+
# rdoc-file=lib/open-uri.rb
|
129
|
+
# - content_encoding()
|
130
|
+
# -->
|
131
|
+
# Returns a list of encodings in Content-Encoding field as an array of strings.
|
132
|
+
#
|
133
|
+
# The encodings are downcased for canonicalization.
|
134
|
+
#
|
135
|
+
def content_encoding: () -> Array[String]
|
136
|
+
end
|
137
|
+
|
138
|
+
# <!-- rdoc-file=lib/open-uri.rb -->
|
139
|
+
# Mixin for HTTP and FTP URIs.
|
140
|
+
#
|
141
|
+
module OpenRead
|
142
|
+
# <!--
|
143
|
+
# rdoc-file=lib/open-uri.rb
|
144
|
+
# - open(*rest, &block)
|
145
|
+
# -->
|
146
|
+
# OpenURI::OpenRead#open provides `open' for URI::HTTP and URI::FTP.
|
147
|
+
#
|
148
|
+
# OpenURI::OpenRead#open takes optional 3 arguments as:
|
149
|
+
#
|
150
|
+
# OpenURI::OpenRead#open([mode [, perm]] [, options]) [{|io| ... }]
|
151
|
+
#
|
152
|
+
# OpenURI::OpenRead#open returns an IO-like object if block is not given.
|
153
|
+
# Otherwise it yields the IO object and return the value of the block. The IO
|
154
|
+
# object is extended with OpenURI::Meta.
|
155
|
+
#
|
156
|
+
# `mode` and `perm` are the same as Kernel#open.
|
157
|
+
#
|
158
|
+
# However, `mode` must be read mode because OpenURI::OpenRead#open doesn't
|
159
|
+
# support write mode (yet). Also `perm` is ignored because it is meaningful only
|
160
|
+
# for file creation.
|
161
|
+
#
|
162
|
+
# `options` must be a hash.
|
163
|
+
#
|
164
|
+
# Each option with a string key specifies an extra header field for HTTP. I.e.,
|
165
|
+
# it is ignored for FTP without HTTP proxy.
|
166
|
+
#
|
167
|
+
# The hash may include other options, where keys are symbols:
|
168
|
+
#
|
169
|
+
# :proxy
|
170
|
+
# : Synopsis:
|
171
|
+
# :proxy => "http://proxy.foo.com:8000/"
|
172
|
+
# :proxy => URI.parse("http://proxy.foo.com:8000/")
|
173
|
+
# :proxy => true
|
174
|
+
# :proxy => false
|
175
|
+
# :proxy => nil
|
176
|
+
#
|
177
|
+
# If :proxy option is specified, the value should be String, URI, boolean or
|
178
|
+
# nil.
|
179
|
+
#
|
180
|
+
# When String or URI is given, it is treated as proxy URI.
|
181
|
+
#
|
182
|
+
# When true is given or the option itself is not specified, environment
|
183
|
+
# variable `scheme_proxy' is examined. `scheme' is replaced by `http',
|
184
|
+
# `https' or `ftp'.
|
185
|
+
#
|
186
|
+
# When false or nil is given, the environment variables are ignored and
|
187
|
+
# connection will be made to a server directly.
|
188
|
+
#
|
189
|
+
# :proxy_http_basic_authentication
|
190
|
+
# : Synopsis:
|
191
|
+
# :proxy_http_basic_authentication =>
|
192
|
+
# ["http://proxy.foo.com:8000/", "proxy-user", "proxy-password"]
|
193
|
+
# :proxy_http_basic_authentication =>
|
194
|
+
# [URI.parse("http://proxy.foo.com:8000/"),
|
195
|
+
# "proxy-user", "proxy-password"]
|
196
|
+
#
|
197
|
+
# If :proxy option is specified, the value should be an Array with 3
|
198
|
+
# elements. It should contain a proxy URI, a proxy user name and a proxy
|
199
|
+
# password. The proxy URI should be a String, an URI or nil. The proxy
|
200
|
+
# user name and password should be a String.
|
201
|
+
#
|
202
|
+
# If nil is given for the proxy URI, this option is just ignored.
|
203
|
+
#
|
204
|
+
# If :proxy and :proxy_http_basic_authentication is specified, ArgumentError
|
205
|
+
# is raised.
|
206
|
+
#
|
207
|
+
# :http_basic_authentication
|
208
|
+
# : Synopsis:
|
209
|
+
# :http_basic_authentication=>[user, password]
|
210
|
+
#
|
211
|
+
# If :http_basic_authentication is specified, the value should be an array
|
212
|
+
# which contains 2 strings: username and password. It is used for HTTP Basic
|
213
|
+
# authentication defined by RFC 2617.
|
214
|
+
#
|
215
|
+
# :content_length_proc
|
216
|
+
# : Synopsis:
|
217
|
+
# :content_length_proc => lambda {|content_length| ... }
|
218
|
+
#
|
219
|
+
# If :content_length_proc option is specified, the option value procedure is
|
220
|
+
# called before actual transfer is started. It takes one argument, which is
|
221
|
+
# expected content length in bytes.
|
222
|
+
#
|
223
|
+
# If two or more transfers are performed by HTTP redirection, the procedure
|
224
|
+
# is called only once for the last transfer.
|
225
|
+
#
|
226
|
+
# When expected content length is unknown, the procedure is called with nil.
|
227
|
+
# This happens when the HTTP response has no Content-Length header.
|
228
|
+
#
|
229
|
+
# :progress_proc
|
230
|
+
# : Synopsis:
|
231
|
+
# :progress_proc => lambda {|size| ...}
|
232
|
+
#
|
233
|
+
# If :progress_proc option is specified, the proc is called with one
|
234
|
+
# argument each time when `open' gets content fragment from network. The
|
235
|
+
# argument `size` is the accumulated transferred size in bytes.
|
236
|
+
#
|
237
|
+
# If two or more transfer is done by HTTP redirection, the procedure is
|
238
|
+
# called only one for a last transfer.
|
239
|
+
#
|
240
|
+
# :progress_proc and :content_length_proc are intended to be used for
|
241
|
+
# progress bar. For example, it can be implemented as follows using
|
242
|
+
# Ruby/ProgressBar.
|
243
|
+
#
|
244
|
+
# pbar = nil
|
245
|
+
# open("http://...",
|
246
|
+
# :content_length_proc => lambda {|t|
|
247
|
+
# if t && 0 < t
|
248
|
+
# pbar = ProgressBar.new("...", t)
|
249
|
+
# pbar.file_transfer_mode
|
250
|
+
# end
|
251
|
+
# },
|
252
|
+
# :progress_proc => lambda {|s|
|
253
|
+
# pbar.set s if pbar
|
254
|
+
# }) {|f| ... }
|
255
|
+
#
|
256
|
+
# :read_timeout
|
257
|
+
# : Synopsis:
|
258
|
+
# :read_timeout=>nil (no timeout)
|
259
|
+
# :read_timeout=>10 (10 second)
|
260
|
+
#
|
261
|
+
# :read_timeout option specifies a timeout of read for http connections.
|
262
|
+
#
|
263
|
+
# :open_timeout
|
264
|
+
# : Synopsis:
|
265
|
+
# :open_timeout=>nil (no timeout)
|
266
|
+
# :open_timeout=>10 (10 second)
|
267
|
+
#
|
268
|
+
# :open_timeout option specifies a timeout of open for http connections.
|
269
|
+
#
|
270
|
+
# :ssl_ca_cert
|
271
|
+
# : Synopsis:
|
272
|
+
# :ssl_ca_cert=>filename or an Array of filenames
|
273
|
+
#
|
274
|
+
# :ssl_ca_cert is used to specify CA certificate for SSL. If it is given,
|
275
|
+
# default certificates are not used.
|
276
|
+
#
|
277
|
+
# :ssl_verify_mode
|
278
|
+
# : Synopsis:
|
279
|
+
# :ssl_verify_mode=>mode
|
280
|
+
#
|
281
|
+
# :ssl_verify_mode is used to specify openssl verify mode.
|
282
|
+
#
|
283
|
+
# :ssl_min_version
|
284
|
+
# : Synopsis:
|
285
|
+
# :ssl_min_version=>:TLS1_2
|
286
|
+
#
|
287
|
+
# :ssl_min_version option specifies the minimum allowed SSL/TLS protocol
|
288
|
+
# version. See also OpenSSL::SSL::SSLContext#min_version=.
|
289
|
+
#
|
290
|
+
# :ssl_max_version
|
291
|
+
# : Synopsis:
|
292
|
+
# :ssl_max_version=>:TLS1_2
|
293
|
+
#
|
294
|
+
# :ssl_max_version option specifies the maximum allowed SSL/TLS protocol
|
295
|
+
# version. See also OpenSSL::SSL::SSLContext#max_version=.
|
296
|
+
#
|
297
|
+
# :ftp_active_mode
|
298
|
+
# : Synopsis:
|
299
|
+
# :ftp_active_mode=>bool
|
300
|
+
#
|
301
|
+
# `:ftp_active_mode => true` is used to make ftp active mode. Ruby 1.9 uses
|
302
|
+
# passive mode by default. Note that the active mode is default in Ruby 1.8
|
303
|
+
# or prior.
|
304
|
+
#
|
305
|
+
# :redirect
|
306
|
+
# : Synopsis:
|
307
|
+
# :redirect=>bool
|
308
|
+
#
|
309
|
+
# `:redirect` is true by default. `:redirect => false` is used to disable
|
310
|
+
# all HTTP redirects.
|
311
|
+
#
|
312
|
+
# OpenURI::HTTPRedirect exception raised on redirection. Using `true` also
|
313
|
+
# means that redirections between http and ftp are permitted.
|
314
|
+
#
|
315
|
+
def open: (*untyped) -> IO
|
316
|
+
| [T] (*untyped) { (IO) -> T } -> T
|
317
|
+
|
318
|
+
# <!--
|
319
|
+
# rdoc-file=lib/open-uri.rb
|
320
|
+
# - read(options={})
|
321
|
+
# -->
|
322
|
+
# OpenURI::OpenRead#read([ options ]) reads a content referenced by self and
|
323
|
+
# returns the content as string. The string is extended with OpenURI::Meta. The
|
324
|
+
# argument `options` is same as OpenURI::OpenRead#open.
|
325
|
+
#
|
326
|
+
def read: (untyped options) -> String
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
%a{annotate:rdoc:skip}
|
331
|
+
module URI
|
332
|
+
%a{annotate:rdoc:skip}
|
333
|
+
class HTTP
|
334
|
+
include OpenURI::OpenRead
|
335
|
+
end
|
336
|
+
|
337
|
+
%a{annotate:rdoc:skip}
|
338
|
+
class FTP
|
339
|
+
include OpenURI::OpenRead
|
340
|
+
end
|
341
|
+
end
|
@@ -8418,7 +8418,7 @@ module OpenSSL
|
|
8418
8418
|
# -->
|
8419
8419
|
# See BasicSocket#shutdown for details.
|
8420
8420
|
#
|
8421
|
-
def shutdown: (
|
8421
|
+
def shutdown: (interned | Integer how) -> void
|
8422
8422
|
|
8423
8423
|
# <!-- rdoc-file=ext/openssl/lib/openssl/ssl.rb -->
|
8424
8424
|
# When true then #accept works exactly the same as TCPServer#accept
|