rbs 3.7.0 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +3 -3
  3. data/.github/workflows/ruby.yml +7 -7
  4. data/CHANGELOG.md +68 -0
  5. data/core/array.rbs +1756 -1591
  6. data/core/basic_object.rbs +38 -35
  7. data/core/comparable.rbs +1 -1
  8. data/core/complex.rbs +166 -94
  9. data/core/data.rbs +1 -1
  10. data/core/dir.rbs +1 -17
  11. data/core/encoding.rbs +12 -32
  12. data/core/enumerable.rbs +270 -266
  13. data/core/enumerator.rbs +0 -2
  14. data/core/env.rbs +1 -1
  15. data/core/errno.rbs +33 -16
  16. data/core/errors.rbs +6 -2
  17. data/core/exception.rbs +235 -169
  18. data/core/fiber.rbs +3 -2
  19. data/core/file.rbs +26 -75
  20. data/core/float.rbs +125 -72
  21. data/core/gc.rbs +156 -40
  22. data/core/hash.rbs +122 -143
  23. data/core/integer.rbs +79 -50
  24. data/core/io/buffer.rbs +49 -43
  25. data/core/io.rbs +99 -146
  26. data/core/kernel.rbs +292 -202
  27. data/core/match_data.rbs +76 -2
  28. data/core/math.rbs +0 -36
  29. data/core/module.rbs +28 -23
  30. data/core/nil_class.rbs +2 -2
  31. data/core/numeric.rbs +101 -104
  32. data/core/object.rbs +0 -4
  33. data/core/object_space/weak_key_map.rbs +3 -4
  34. data/core/object_space.rbs +3 -3
  35. data/core/proc.rbs +80 -12
  36. data/core/process.rbs +109 -57
  37. data/core/ractor.rbs +54 -4
  38. data/core/range.rbs +114 -87
  39. data/core/rational.rbs +0 -2
  40. data/core/rbs/unnamed/argf.rbs +234 -33
  41. data/core/rbs/unnamed/env_class.rbs +35 -53
  42. data/core/rbs/unnamed/random.rbs +1 -2
  43. data/core/regexp.rbs +6 -54
  44. data/core/ruby_vm.rbs +88 -9
  45. data/core/rubygems/config_file.rbs +3 -0
  46. data/core/rubygems/errors.rbs +3 -6
  47. data/core/rubygems/platform.rbs +0 -9
  48. data/core/rubygems/rubygems.rbs +3 -6
  49. data/core/rubygems/version.rbs +6 -6
  50. data/core/set.rbs +3 -15
  51. data/core/string.rbs +256 -260
  52. data/core/struct.rbs +6 -18
  53. data/core/symbol.rbs +14 -21
  54. data/core/thread.rbs +32 -35
  55. data/core/time.rbs +131 -50
  56. data/core/trace_point.rbs +124 -113
  57. data/core/true_class.rbs +0 -1
  58. data/core/warning.rbs +9 -2
  59. data/docs/architecture.md +1 -1
  60. data/docs/syntax.md +1 -1
  61. data/ext/rbs_extension/location.c +29 -19
  62. data/ext/rbs_extension/parser.c +268 -293
  63. data/ext/rbs_extension/parserstate.c +56 -22
  64. data/lib/rbs/annotate/annotations.rb +3 -3
  65. data/lib/rbs/annotate/rdoc_source.rb +2 -2
  66. data/lib/rbs/cli/diff.rb +3 -3
  67. data/lib/rbs/cli/validate.rb +1 -1
  68. data/lib/rbs/cli.rb +13 -13
  69. data/lib/rbs/collection/config.rb +3 -1
  70. data/lib/rbs/definition_builder/ancestor_builder.rb +3 -3
  71. data/lib/rbs/environment_loader.rb +1 -1
  72. data/lib/rbs/namespace.rb +1 -0
  73. data/lib/rbs/parser_aux.rb +2 -2
  74. data/lib/rbs/prototype/rb.rb +11 -8
  75. data/lib/rbs/prototype/rbi.rb +9 -5
  76. data/lib/rbs/prototype/runtime/value_object_generator.rb +7 -5
  77. data/lib/rbs/prototype/runtime.rb +4 -5
  78. data/lib/rbs/type_name.rb +14 -9
  79. data/lib/rbs/types.rb +2 -1
  80. data/lib/rbs/unit_test/type_assertions.rb +2 -2
  81. data/lib/rbs/validator.rb +3 -1
  82. data/lib/rbs/version.rb +1 -1
  83. data/lib/rdoc_plugin/parser.rb +2 -2
  84. data/rbs.gemspec +4 -0
  85. data/sig/ancestor_graph.rbs +4 -4
  86. data/sig/namespace.rbs +2 -3
  87. data/sig/resolver/constant_resolver.rbs +2 -2
  88. data/sig/resolver/context.rbs +1 -1
  89. data/sig/type_alias_regularity.rbs +5 -5
  90. data/sig/typename.rbs +8 -5
  91. data/sig/use_map.rbs +1 -1
  92. data/sig/validator.rbs +2 -2
  93. data/stdlib/base64/0/base64.rbs +0 -9
  94. data/stdlib/benchmark/0/benchmark.rbs +11 -2
  95. data/stdlib/bigdecimal/0/big_decimal.rbs +26 -182
  96. data/stdlib/cgi/0/core.rbs +47 -0
  97. data/stdlib/coverage/0/coverage.rbs +0 -3
  98. data/stdlib/csv/0/csv.rbs +18 -58
  99. data/stdlib/date/0/date.rbs +27 -42
  100. data/stdlib/did_you_mean/0/did_you_mean.rbs +0 -5
  101. data/stdlib/digest/0/digest.rbs +25 -2
  102. data/stdlib/erb/0/erb.rbs +0 -1
  103. data/stdlib/etc/0/etc.rbs +51 -34
  104. data/stdlib/fileutils/0/fileutils.rbs +3 -44
  105. data/stdlib/io-console/0/io-console.rbs +69 -15
  106. data/stdlib/ipaddr/0/ipaddr.rbs +8 -4
  107. data/stdlib/json/0/json.rbs +56 -71
  108. data/stdlib/logger/0/log_device.rbs +1 -1
  109. data/stdlib/logger/0/logger.rbs +3 -18
  110. data/stdlib/net-http/0/net-http.rbs +39 -106
  111. data/stdlib/nkf/0/nkf.rbs +30 -0
  112. data/stdlib/objspace/0/objspace.rbs +1 -2
  113. data/stdlib/observable/0/observable.rbs +1 -1
  114. data/stdlib/open-uri/0/open-uri.rbs +52 -0
  115. data/stdlib/open3/0/open3.rbs +0 -8
  116. data/stdlib/openssl/0/openssl.rbs +136 -69
  117. data/stdlib/optparse/0/optparse.rbs +58 -18
  118. data/stdlib/pathname/0/pathname.rbs +2 -8
  119. data/stdlib/pp/0/pp.rbs +3 -1
  120. data/stdlib/prettyprint/0/prettyprint.rbs +0 -4
  121. data/stdlib/pstore/0/pstore.rbs +0 -6
  122. data/stdlib/psych/0/psych.rbs +15 -4
  123. data/stdlib/pty/0/pty.rbs +46 -4
  124. data/stdlib/rdoc/0/code_object.rbs +0 -4
  125. data/stdlib/rdoc/0/markup.rbs +10 -12
  126. data/stdlib/rdoc/0/rdoc.rbs +13 -8
  127. data/stdlib/resolv/0/resolv.rbs +13 -4
  128. data/stdlib/ripper/0/ripper.rbs +0 -2
  129. data/stdlib/securerandom/0/securerandom.rbs +7 -2
  130. data/stdlib/shellwords/0/shellwords.rbs +11 -12
  131. data/stdlib/singleton/0/singleton.rbs +0 -1
  132. data/stdlib/socket/0/addrinfo.rbs +0 -1
  133. data/stdlib/socket/0/basic_socket.rbs +0 -5
  134. data/stdlib/socket/0/socket.rbs +32 -27
  135. data/stdlib/socket/0/tcp_server.rbs +0 -3
  136. data/stdlib/socket/0/tcp_socket.rbs +36 -3
  137. data/stdlib/socket/0/udp_socket.rbs +0 -1
  138. data/stdlib/socket/0/unix_server.rbs +0 -3
  139. data/stdlib/strscan/0/string_scanner.rbs +1265 -422
  140. data/stdlib/tempfile/0/tempfile.rbs +135 -28
  141. data/stdlib/time/0/time.rbs +48 -35
  142. data/stdlib/timeout/0/timeout.rbs +11 -8
  143. data/stdlib/tmpdir/0/tmpdir.rbs +10 -3
  144. data/stdlib/tsort/0/tsort.rbs +0 -4
  145. data/stdlib/uri/0/common.rbs +11 -30
  146. data/stdlib/uri/0/ftp.rbs +1 -1
  147. data/stdlib/uri/0/generic.rbs +22 -18
  148. data/stdlib/uri/0/http.rbs +2 -2
  149. data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
  150. data/stdlib/zlib/0/buf_error.rbs +1 -70
  151. data/stdlib/zlib/0/data_error.rbs +1 -70
  152. data/stdlib/zlib/0/deflate.rbs +8 -72
  153. data/stdlib/zlib/0/error.rbs +1 -70
  154. data/stdlib/zlib/0/gzip_file/crc_error.rbs +2 -105
  155. data/stdlib/zlib/0/gzip_file/error.rbs +2 -105
  156. data/stdlib/zlib/0/gzip_file/length_error.rbs +2 -105
  157. data/stdlib/zlib/0/gzip_file/no_footer.rbs +2 -105
  158. data/stdlib/zlib/0/gzip_file.rbs +1 -71
  159. data/stdlib/zlib/0/gzip_reader.rbs +3 -74
  160. data/stdlib/zlib/0/gzip_writer.rbs +1 -70
  161. data/stdlib/zlib/0/inflate.rbs +4 -71
  162. data/stdlib/zlib/0/mem_error.rbs +1 -70
  163. data/stdlib/zlib/0/need_dict.rbs +1 -70
  164. data/stdlib/zlib/0/stream_end.rbs +1 -70
  165. data/stdlib/zlib/0/stream_error.rbs +1 -70
  166. data/stdlib/zlib/0/version_error.rbs +1 -70
  167. data/stdlib/zlib/0/zlib.rbs +0 -2
  168. data/stdlib/zlib/0/zstream.rbs +4 -72
  169. metadata +3 -6
@@ -1,9 +1,3 @@
1
- # <!-- rdoc-file=lib/rdoc/rubygems_hook.rb -->
2
- # Gem::RDoc provides methods to generate RDoc and ri data for installed gems
3
- # upon gem installation.
4
- #
5
- # This file is automatically required by RubyGems 1.9 and newer.
6
- #
7
1
  # <!-- rdoc-file=lib/rdoc.rb -->
8
2
  # RDoc produces documentation for Ruby source files by parsing the source and
9
3
  # extracting the definition for classes, modules, methods, includes and
@@ -21,8 +15,7 @@
21
15
  # If you want to use RDoc to create documentation for your Ruby source files,
22
16
  # see RDoc::Markup and refer to `rdoc --help` for command line usage.
23
17
  #
24
- # If you want to set the default markup format see
25
- # RDoc::Markup@Supported+Formats
18
+ # If you want to set the default markup format see RDoc::Markup@Markup+Formats
26
19
  #
27
20
  # If you want to store rdoc configuration in your gem (such as the default
28
21
  # markup format) see RDoc::Options@Saved+Options
@@ -56,6 +49,18 @@
56
49
  # of Keiju ISHITSUKA of Nippon Rational Inc, who produced the Ruby parser
57
50
  # for irb and the rtags package.
58
51
  #
52
+ # <!-- rdoc-file=lib/rdoc/rubygems_hook.rb -->
53
+ # This class is referenced by RubyGems to create documents. All implementations
54
+ # are moved to the above RubyGemsHook.
55
+ #
56
+ # This class does nothing when this RDoc is installed as a normal gem or a
57
+ # bundled gem.
58
+ #
59
+ # This class does generate/remove documents for compatibility when this RDoc is
60
+ # installed as a default gem.
61
+ #
62
+ # We can remove this when all maintained RubyGems remove `rubygems/rdoc.rb`.
63
+ #
59
64
  module RDoc
60
65
  # <!-- rdoc-file=lib/rdoc/token_stream.rb -->
61
66
  # A TokenStream is a list of tokens, gathered during the parse of some entity
@@ -126,10 +126,14 @@ class Resolv
126
126
 
127
127
  # <!--
128
128
  # rdoc-file=lib/resolv.rb
129
- # - new(resolvers=nil, use_ipv6: nil)
129
+ # - new(resolvers=(arg_not_set = true; nil), use_ipv6: (keyword_not_set = true; nil))
130
130
  # -->
131
131
  # Creates a new Resolv using `resolvers`.
132
132
  #
133
+ # If `resolvers` is not given, a hash, or `nil`, uses a Hosts resolver and and a
134
+ # DNS resolver. If `resolvers` is a hash, uses the hash as configuration for
135
+ # the DNS resolver.
136
+ #
133
137
  def initialize: (?Resolv::Hosts | Resolv::DNS resolvers) -> untyped
134
138
  end
135
139
 
@@ -292,7 +296,6 @@ class Resolv::DNS
292
296
  # * Resolv::DNS::Resource::IN::TXT
293
297
  # * Resolv::DNS::Resource::IN::WKS
294
298
  #
295
- #
296
299
  # Returned resource is represented as a Resolv::DNS::Resource instance, i.e.
297
300
  # Resolv::DNS::Resource::IN::A.
298
301
  #
@@ -341,8 +344,10 @@ class Resolv::DNS
341
344
  #
342
345
  # nil
343
346
  # : Uses /etc/resolv.conf.
347
+ #
344
348
  # String
345
349
  # : Path to a file using /etc/resolv.conf's format.
350
+ #
346
351
  # Hash
347
352
  # : Must contain :nameserver, :search and :ndots keys.
348
353
  #
@@ -355,12 +360,10 @@ class Resolv::DNS
355
360
  # * :nameserver => '8.8.8.8'
356
361
  # * :nameserver => ['8.8.8.8', '8.8.4.4']
357
362
  #
358
- #
359
363
  # The value of :nameserver_port should be an array of pair of nameserver address
360
364
  # and port number.
361
365
  # * :nameserver_port => [['8.8.8.8', 53], ['8.8.4.4', 53]]
362
366
  #
363
- #
364
367
  # Example:
365
368
  #
366
369
  # Resolv::DNS.new(:nameserver => ['210.251.121.21'],
@@ -594,6 +597,7 @@ class Resolv::DNS::Name
594
597
  #
595
598
  # Name
596
599
  # : returns `arg`.
600
+ #
597
601
  # String
598
602
  # : Creates a new Name.
599
603
  #
@@ -1534,6 +1538,7 @@ class Resolv::IPv6
1534
1538
  #
1535
1539
  # IPv6
1536
1540
  # : returns `arg`.
1541
+ #
1537
1542
  # String
1538
1543
  # : `arg` must match one of the IPv6::Regex* constants
1539
1544
  #
@@ -1617,6 +1622,7 @@ class Resolv::LOC::Alt
1617
1622
  #
1618
1623
  # LOC::Alt
1619
1624
  # : returns `arg`.
1625
+ #
1620
1626
  # String
1621
1627
  # : `arg` must match the LOC::Alt::Regex constant
1622
1628
  #
@@ -1663,6 +1669,7 @@ class Resolv::LOC::Coord
1663
1669
  #
1664
1670
  # LOC::Coord
1665
1671
  # : returns `arg`.
1672
+ #
1666
1673
  # String
1667
1674
  # : `arg` must match the LOC::Coord::Regex constant
1668
1675
  #
@@ -1712,6 +1719,7 @@ class Resolv::LOC::Size
1712
1719
  #
1713
1720
  # LOC::Size
1714
1721
  # : returns `arg`.
1722
+ #
1715
1723
  # String
1716
1724
  # : `arg` must match the LOC::Size::Regex constant
1717
1725
  #
@@ -1782,6 +1790,7 @@ class Resolv::MDNS < Resolv::DNS
1782
1790
  # nil
1783
1791
  # : Uses the default mDNS addresses
1784
1792
  #
1793
+ #
1785
1794
  # Hash
1786
1795
  # : Must contain :nameserver or :nameserver_port like Resolv::DNS#initialize.
1787
1796
  #
@@ -55,13 +55,11 @@
55
55
  # Inside](http://www.rubyinside.com/using-ripper-to-see-how-ruby-is-parsing-
56
56
  # your-code-5270.html)
57
57
  #
58
- #
59
58
  # ## Requirements
60
59
  #
61
60
  # * ruby 1.9 (support CVS HEAD only)
62
61
  # * bison 1.28 or later (Other yaccs do not work)
63
62
  #
64
- #
65
63
  # ## License
66
64
  #
67
65
  # Ruby License.
@@ -14,7 +14,6 @@
14
14
  # * /dev/urandom
15
15
  # * Win32
16
16
  #
17
- #
18
17
  # SecureRandom is extended by the Random::Formatter module which defines the
19
18
  # following methods:
20
19
  #
@@ -29,7 +28,6 @@
29
28
  # * urlsafe_base64
30
29
  # * uuid
31
30
  #
32
- #
33
31
  # These methods are usable as class methods of SecureRandom such as
34
32
  # `SecureRandom.hex`.
35
33
  #
@@ -39,6 +37,13 @@
39
37
  module SecureRandom
40
38
  extend Random::Formatter
41
39
 
40
+ # <!--
41
+ # rdoc-file=lib/securerandom.rb
42
+ # - alphanumeric(n = nil, chars: ALPHANUMERIC)
43
+ # -->
44
+ # Compatibility methods for Ruby 3.2, we can remove this after dropping to
45
+ # support Ruby 3.2
46
+ #
42
47
  def self.alphanumeric: (?Integer?) -> String
43
48
 
44
49
  def self.base64: (?Integer?) -> String
@@ -4,9 +4,11 @@
4
4
  # This module manipulates strings according to the word parsing rules of the
5
5
  # UNIX Bourne shell.
6
6
  #
7
- # The shellwords() function was originally a port of shellwords.pl, but modified
8
- # to conform to the Shell & Utilities volume of the IEEE Std 1003.1-2008, 2016
9
- # Edition [1].
7
+ # The `shellwords()` function was originally a port of shellwords.pl, but
8
+ # modified to conform to [the Shell & Utilities volume of the IEEE Std
9
+ # 1003.1-2008, 2016
10
+ # Edition](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.ht
11
+ # ml)
10
12
  #
11
13
  # ### Usage
12
14
  #
@@ -58,17 +60,9 @@
58
60
  # * Wakou Aoyama
59
61
  # * Akinori MUSHA <knu@iDaemons.org>
60
62
  #
61
- #
62
63
  # ### Contact
63
64
  # * Akinori MUSHA <knu@iDaemons.org> (current maintainer)
64
65
  #
65
- #
66
- # ### Resources
67
- #
68
- # 1: [IEEE Std 1003.1-2008, 2016 Edition, the Shell & Utilities
69
- # volume](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.htm
70
- # l)
71
- #
72
66
  module Shellwords
73
67
  # <!--
74
68
  # rdoc-file=lib/shellwords.rb
@@ -77,6 +71,8 @@ module Shellwords
77
71
  # Escapes a string so that it can be safely used in a Bourne shell command line.
78
72
  # `str` can be a non-string object that responds to `to_s`.
79
73
  #
74
+ # `str` must not contain NUL characters because of nature of `exec` system call.
75
+ #
80
76
  # Note that a resulted string should be used unquoted and is not intended for
81
77
  # use in double quotes nor in single quotes.
82
78
  #
@@ -114,7 +110,7 @@ module Shellwords
114
110
  #
115
111
  # All elements are joined into a single string with fields separated by a space,
116
112
  # where each element is escaped for the Bourne shell and stringified using
117
- # `to_s`.
113
+ # `to_s`. See also Shellwords.shellescape.
118
114
  #
119
115
  # ary = ["There's", "a", "time", "and", "place", "for", "everything"]
120
116
  # argv = Shellwords.join(ary)
@@ -142,6 +138,9 @@ module Shellwords
142
138
  # argv = Shellwords.split('here are "two words"')
143
139
  # argv #=> ["here", "are", "two words"]
144
140
  #
141
+ # `line` must not contain NUL characters because of nature of `exec` system
142
+ # call.
143
+ #
145
144
  # Note, however, that this is not a command line parser. Shell metacharacters
146
145
  # except for the single and double quotes and backslash are not treated as such.
147
146
  #
@@ -53,7 +53,6 @@
53
53
  # * Overriding Klass#clone and Klass#dup to raise TypeErrors to prevent
54
54
  # cloning or duping.
55
55
  #
56
- #
57
56
  # ## Singleton and Marshal
58
57
  #
59
58
  # By default Singleton's #_dump(depth) returns the empty string. Marshalling by
@@ -642,7 +642,6 @@ class Addrinfo
642
642
  # * `Socket.sockaddr_in(80, "www.ruby-lang.org")`
643
643
  # * `Socket.sockaddr_un("/tmp/sock")`
644
644
  #
645
- #
646
645
  # In an AF_INET/AF_INET6 sockaddr array, the 4th element, numeric IP address, is
647
646
  # used to construct socket address in the Addrinfo instance. If the 3rd element,
648
647
  # textual host name, is non-nil, it is also recorded but used only for
@@ -82,7 +82,6 @@ class BasicSocket < IO
82
82
  # (127.0.0.1).
83
83
  # * IPv6 unspecified address (::) is replaced by IPv6 loopback address (::1).
84
84
  #
85
- #
86
85
  # If the local address is not suitable for connect, SocketError is raised. IPv4
87
86
  # and IPv6 address which port is 0 is not suitable for connect. Unix domain
88
87
  # socket which has no path is not suitable for connect.
@@ -202,7 +201,6 @@ class BasicSocket < IO
202
201
  # Socket::SO_REUSEADDR. A string or symbol of the name, possibly without
203
202
  # prefix, is also accepted.
204
203
  #
205
- #
206
204
  # ### Examples
207
205
  #
208
206
  # Some socket options are integers with boolean values, in this case #getsockopt
@@ -302,7 +300,6 @@ class BasicSocket < IO
302
300
  # * `buf` - destination String buffer
303
301
  # * `options` - keyword hash, supporting `exception: false`
304
302
  #
305
- #
306
303
  # ### Example
307
304
  # serv = TCPServer.new("127.0.0.1", 0)
308
305
  # af, port, host, addr = serv.addr
@@ -518,10 +515,8 @@ class BasicSocket < IO
518
515
  # int is passed as for an Integer. Note that `false` must be passed, not
519
516
  # `nil`.
520
517
  # * String: the string's data and length is passed to the socket.
521
- #
522
518
  # * `socketoption` is an instance of Socket::Option
523
519
  #
524
- #
525
520
  # ### Examples
526
521
  #
527
522
  # Some socket options are integers with boolean values, in this case #setsockopt
@@ -22,12 +22,10 @@
22
22
  # * Socket::PF_UNIX
23
23
  # * etc.
24
24
  #
25
- #
26
25
  # **type:** The type of communications between the two endpoints, typically
27
26
  # * Socket::SOCK_STREAM
28
27
  # * Socket::SOCK_DGRAM.
29
28
  #
30
- #
31
29
  # **protocol:** Typically *zero*. This may be used to identify a variant of a
32
30
  # protocol.
33
31
  #
@@ -37,7 +35,6 @@
37
35
  # * a zero-length string which specifies INADDR_ANY
38
36
  # * an integer (interpreted as binary address in host byte order).
39
37
  #
40
- #
41
38
  # ### Quick start
42
39
  #
43
40
  # Many of the classes, such as TCPSocket, UDPSocket or UNIXSocket, ease the use
@@ -94,10 +91,13 @@
94
91
  #
95
92
  # TCP client socket
96
93
  # : Socket.tcp, TCPSocket.open
94
+ #
97
95
  # TCP server socket
98
96
  # : Socket.tcp_server_loop, TCPServer.open
97
+ #
99
98
  # UNIX client socket
100
99
  # : Socket.unix, UNIXSocket.open
100
+ #
101
101
  # UNIX server socket
102
102
  # : Socket.unix_server_loop, UNIXServer.open
103
103
  #
@@ -108,7 +108,6 @@
108
108
  # * Sam Roberts
109
109
  # * *Programming Ruby* from The Pragmatic Bookshelf.
110
110
  #
111
- #
112
111
  # Much material in this documentation is taken with permission from *Programming
113
112
  # Ruby* from The Pragmatic Bookshelf.
114
113
  #
@@ -180,7 +179,6 @@ class Socket < BasicSocket
180
179
  # cannot be released since gethostbyname() is not thread safe.)
181
180
  # * This method uses gethostbyname() function already removed from POSIX.
182
181
  #
183
- #
184
182
  # This method obtains the host information for *address*.
185
183
  #
186
184
  # p Socket.gethostbyaddr([221,186,184,68].pack("CCCC"))
@@ -209,7 +207,6 @@ class Socket < BasicSocket
209
207
  # cannot be released since gethostbyname() is not thread safe.)
210
208
  # * This method uses gethostbyname() function already removed from POSIX.
211
209
  #
212
- #
213
210
  # This method obtains the host information for *hostname*.
214
211
  #
215
212
  # p Socket.gethostbyname("hal") #=> ["localhost", ["hal"], 2, "\x7F\x00\x00\x01"]
@@ -281,7 +278,6 @@ class Socket < BasicSocket
281
278
  # * 3-elements array such as ["AF_INET", 80, "127.0.0.1"]
282
279
  # * 4-elements array such as ["AF_INET", 80, ignored, "127.0.0.1"]
283
280
  #
284
- #
285
281
  # *flags* should be bitwise OR of Socket::NI_* constants.
286
282
  #
287
283
  # Note: The last form is compatible with IPSocket#addr and IPSocket#peeraddr.
@@ -462,13 +458,38 @@ class Socket < BasicSocket
462
458
  # -->
463
459
  # creates a new socket object connected to host:port using TCP/IP.
464
460
  #
461
+ # Starting from Ruby 3.4, this method operates according to the Happy Eyeballs
462
+ # Version 2 ([RFC 8305](https://datatracker.ietf.org/doc/html/rfc8305))
463
+ # algorithm by default.
464
+ #
465
+ # For details on Happy Eyeballs Version 2, see
466
+ # [Socket.tcp_fast_fallback=](rdoc-ref:Socket.tcp_fast_fallback=).
467
+ #
468
+ # To make it behave the same as in Ruby 3.3 and earlier, explicitly specify the
469
+ # option fast_fallback:false. Or, setting Socket.tcp_fast_fallback=false will
470
+ # disable Happy Eyeballs Version 2 not only for this method but for all Socket
471
+ # globally.
472
+ #
465
473
  # If local_host:local_port is given, the socket is bound to it.
466
474
  #
467
475
  # The optional last argument *opts* is options represented by a hash. *opts* may
468
476
  # have following options:
469
477
  #
478
+ # :resolv_timeout
479
+ # : Specifies the timeout in seconds from when the hostname resolution starts.
480
+ #
470
481
  # :connect_timeout
471
- # : specify the timeout in seconds.
482
+ # : This method sequentially attempts connecting to all candidate destination
483
+ # addresses.
484
+ # The `connect_timeout` specifies the timeout in seconds from the start of
485
+ # the connection attempt to the last candidate.
486
+ # By default, all connection attempts continue until the timeout occurs.
487
+ # When `fast_fallback:false` is explicitly specified,
488
+ # a timeout is set for each connection attempt and any connection attempt
489
+ # that exceeds its timeout will be canceled.
490
+ #
491
+ # :fast_fallback
492
+ # : Enables the Happy Eyeballs Version 2 algorithm (enabled by default).
472
493
  #
473
494
  #
474
495
  # If a block is given, the block is called with the socket. The value of the
@@ -832,7 +853,6 @@ class Socket < BasicSocket
832
853
  # * `local_sockaddr` - the `struct` sockaddr contained in a string or an
833
854
  # Addrinfo object
834
855
  #
835
- #
836
856
  # ### Example
837
857
  # require 'socket'
838
858
  #
@@ -873,7 +893,6 @@ class Socket < BasicSocket
873
893
  # * Errno::EOPNOTSUPP - the socket type of the `socket` does not support
874
894
  # binding to an address
875
895
  #
876
- #
877
896
  # On unix-based based systems if the address family of the calling `socket` is
878
897
  # Socket::AF_UNIX the follow exceptions may be raised if the call to *bind*
879
898
  # fails:
@@ -892,7 +911,6 @@ class Socket < BasicSocket
892
911
  # *sockaddr* is not a directory
893
912
  # * Errno::EROFS - the name would reside on a read only filesystem
894
913
  #
895
- #
896
914
  # ### Windows Exceptions
897
915
  # On Windows systems the following system exceptions may be raised if the call
898
916
  # to *bind* fails:
@@ -908,7 +926,6 @@ class Socket < BasicSocket
908
926
  # * Errno::ENOBUFS - no buffer space is available
909
927
  # * Errno::ENOTSOCK - the `socket` argument does not refer to a socket
910
928
  #
911
- #
912
929
  # ### See
913
930
  # * bind manual pages on unix-based systems
914
931
  # * bind function in Microsoft's Winsock functions reference
@@ -926,7 +943,6 @@ class Socket < BasicSocket
926
943
  # * `remote_sockaddr` - the `struct` sockaddr contained in a string or
927
944
  # Addrinfo object
928
945
  #
929
- #
930
946
  # ### Example:
931
947
  # # Pull down Google's web page
932
948
  # require 'socket'
@@ -981,7 +997,6 @@ class Socket < BasicSocket
981
997
  # * Errno::ETIMEDOUT - the attempt to connect timed out before a connection
982
998
  # was made.
983
999
  #
984
- #
985
1000
  # On unix-based systems if the address family of the calling `socket` is AF_UNIX
986
1001
  # the follow exceptions may be raised if the call to *connect* fails:
987
1002
  # * Errno::EIO - an i/o error occurred while reading from or writing to the
@@ -995,7 +1010,6 @@ class Socket < BasicSocket
995
1010
  # * Errno::ENOTDIR - a component of the path prefix of the pathname in
996
1011
  # *sockaddr* is not a directory
997
1012
  #
998
- #
999
1013
  # ### Windows Exceptions
1000
1014
  # On Windows systems the following system exceptions may be raised if the call
1001
1015
  # to *connect* fails:
@@ -1028,7 +1042,6 @@ class Socket < BasicSocket
1028
1042
  # * Errno::EACCES - the attempt to connect the datagram socket to the
1029
1043
  # broadcast address failed
1030
1044
  #
1031
- #
1032
1045
  # ### See
1033
1046
  # * connect manual pages on unix-based systems
1034
1047
  # * connect function in Microsoft's Winsock functions reference
@@ -1044,7 +1057,8 @@ class Socket < BasicSocket
1044
1057
  # otherwise an exception is raised.
1045
1058
  #
1046
1059
  # ### Parameter
1047
- # # +remote_sockaddr+ - the +struct+ sockaddr contained in a string or Addrinfo object
1060
+ # * `remote_sockaddr` - the `struct` sockaddr contained in a string or
1061
+ # Addrinfo object
1048
1062
  #
1049
1063
  # ### Example:
1050
1064
  # # Pull down Google's web page
@@ -1079,7 +1093,7 @@ class Socket < BasicSocket
1079
1093
  # the symbol `:wait_writable` instead.
1080
1094
  #
1081
1095
  # ### See
1082
- # # Socket#connect
1096
+ # * Socket#connect
1083
1097
  #
1084
1098
  def connect_nonblock: (untyped addr, ?exception: untyped) -> (Integer | :wait_writable)
1085
1099
 
@@ -1102,7 +1116,6 @@ class Socket < BasicSocket
1102
1116
  # ### Parameter
1103
1117
  # * `backlog` - the maximum length of the queue for pending connections.
1104
1118
  #
1105
- #
1106
1119
  # ### Example 1
1107
1120
  # require 'socket'
1108
1121
  # include Socket::Constants
@@ -1139,7 +1152,6 @@ class Socket < BasicSocket
1139
1152
  # * Errno::ENOBUFS - insufficient resources are available in the system to
1140
1153
  # complete the call
1141
1154
  #
1142
- #
1143
1155
  # ### Windows Exceptions
1144
1156
  # On Windows systems the following system exceptions may be raised if the call
1145
1157
  # to *listen* fails:
@@ -1159,7 +1171,6 @@ class Socket < BasicSocket
1159
1171
  # * Errno::EOPNOTSUPP - the referenced `socket` is not a type that supports
1160
1172
  # the *listen* method
1161
1173
  #
1162
- #
1163
1174
  # ### See
1164
1175
  # * listen manual pages on unix-based systems
1165
1176
  # * listen function in Microsoft's Winsock functions reference
@@ -1180,7 +1191,6 @@ class Socket < BasicSocket
1180
1191
  # * `maxlen` - the maximum number of bytes to receive from the socket
1181
1192
  # * `flags` - zero or more of the `MSG_` options
1182
1193
  #
1183
- #
1184
1194
  # ### Example
1185
1195
  # # In one file, start this first
1186
1196
  # require 'socket'
@@ -1236,7 +1246,6 @@ class Socket < BasicSocket
1236
1246
  # * Errno::ETIMEDOUT - the connection timed out during connection
1237
1247
  # establishment or due to a transmission timeout on an active connection
1238
1248
  #
1239
- #
1240
1249
  # ### Windows Exceptions
1241
1250
  # On Windows systems the following system exceptions may be raised if the call
1242
1251
  # to *recvfrom* fails:
@@ -1298,7 +1307,6 @@ class Socket < BasicSocket
1298
1307
  # * `outbuf` - destination String buffer
1299
1308
  # * `opts` - keyword hash, supporting `exception: false`
1300
1309
  #
1301
- #
1302
1310
  # ### Example
1303
1311
  # # In one file, start this first
1304
1312
  # require 'socket'
@@ -4122,7 +4130,6 @@ class Socket::AncillaryData
4122
4130
  # * Socket::AF_UNIX, "AF_UNIX", "UNIX", :AF_UNIX, :UNIX
4123
4131
  # * etc.
4124
4132
  #
4125
- #
4126
4133
  # *cmsg_level* should be an integer, a string or a symbol.
4127
4134
  # * Socket::SOL_SOCKET, "SOL_SOCKET", "SOCKET", :SOL_SOCKET and :SOCKET
4128
4135
  # * Socket::IPPROTO_IP, "IP" and :IP
@@ -4130,7 +4137,6 @@ class Socket::AncillaryData
4130
4137
  # * Socket::IPPROTO_TCP, "TCP" and :TCP
4131
4138
  # * etc.
4132
4139
  #
4133
- #
4134
4140
  # *cmsg_type* should be an integer, a string or a symbol. If a string/symbol is
4135
4141
  # specified, it is interpreted depend on *cmsg_level*.
4136
4142
  # * Socket::SCM_RIGHTS, "SCM_RIGHTS", "RIGHTS", :SCM_RIGHTS, :RIGHTS for
@@ -4139,7 +4145,6 @@ class Socket::AncillaryData
4139
4145
  # * Socket::IPV6_PKTINFO, "PKTINFO" and :PKTINFO for IPPROTO_IPV6
4140
4146
  # * etc.
4141
4147
  #
4142
- #
4143
4148
  # *cmsg_data* should be a string.
4144
4149
  #
4145
4150
  # p Socket::AncillaryData.new(:INET, :TCP, :NODELAY, "")
@@ -91,7 +91,6 @@ class TCPServer < TCPSocket
91
91
  # ### Parameter
92
92
  # * `backlog` - the maximum length of the queue for pending connections.
93
93
  #
94
- #
95
94
  # ### Example 1
96
95
  # require 'socket'
97
96
  # include Socket::Constants
@@ -128,7 +127,6 @@ class TCPServer < TCPSocket
128
127
  # * Errno::ENOBUFS - insufficient resources are available in the system to
129
128
  # complete the call
130
129
  #
131
- #
132
130
  # ### Windows Exceptions
133
131
  # On Windows systems the following system exceptions may be raised if the call
134
132
  # to *listen* fails:
@@ -148,7 +146,6 @@ class TCPServer < TCPSocket
148
146
  # * Errno::EOPNOTSUPP - the referenced `socket` is not a type that supports
149
147
  # the *listen* method
150
148
  #
151
- #
152
149
  # ### See
153
150
  # * listen manual pages on unix-based systems
154
151
  # * listen function in Microsoft's Winsock functions reference
@@ -27,7 +27,6 @@ class TCPSocket < IPSocket
27
27
  # cannot be released since gethostbyname() is not thread safe.)
28
28
  # * This method uses gethostbyname() function already removed from POSIX.
29
29
  #
30
- #
31
30
  # This method lookups host information by *hostname*.
32
31
  #
33
32
  # TCPSocket.gethostbyname("localhost")
@@ -38,9 +37,43 @@ class TCPSocket < IPSocket
38
37
  private
39
38
 
40
39
  # <!--
41
- # rdoc-file=lib/resolv-replace.rb
42
- # - new(host, serv, *rest)
40
+ # rdoc-file=ext/socket/tcpsocket.c
41
+ # - TCPSocket.new(remote_host, remote_port, local_host=nil, local_port=nil, resolv_timeout: nil, connect_timeout: nil, fast_fallback: true)
43
42
  # -->
43
+ # Opens a TCP connection to `remote_host` on `remote_port`. If `local_host` and
44
+ # `local_port` are specified, then those parameters are used on the local end to
45
+ # establish the connection.
46
+ #
47
+ # Starting from Ruby 3.4, this method operates according to the Happy Eyeballs
48
+ # Version 2 ([RFC 8305](https://datatracker.ietf.org/doc/html/rfc8305))
49
+ # algorithm by default, except on Windows.
50
+ #
51
+ # For details on Happy Eyeballs Version 2, see
52
+ # [Socket.tcp_fast_fallback=](rdoc-ref:Socket.tcp_fast_fallback=).
53
+ #
54
+ # To make it behave the same as in Ruby 3.3 and earlier, explicitly specify the
55
+ # option fast_fallback:false. Or, setting Socket.tcp_fast_fallback=false will
56
+ # disable Happy Eyeballs Version 2 not only for this method but for all Socket
57
+ # globally.
58
+ #
59
+ # When using TCPSocket.new on Windows, Happy Eyeballs Version 2 is not provided,
60
+ # and it behaves the same as in Ruby 3.3 and earlier.
61
+ #
62
+ # :resolv_timeout
63
+ # : Specifies the timeout in seconds from when the hostname resolution starts.
64
+ #
65
+ # :connect_timeout
66
+ # : This method sequentially attempts connecting to all candidate destination
67
+ # addresses.
68
+ # The `connect_timeout` specifies the timeout in seconds from the start of
69
+ # the connection attempt to the last candidate.
70
+ # By default, all connection attempts continue until the timeout occurs.
71
+ # When `fast_fallback:false` is explicitly specified,
72
+ # a timeout is set for each connection attempt and any connection attempt
73
+ # that exceeds its timeout will be canceled.
74
+ #
75
+ # :fast_fallback
76
+ # : Enables the Happy Eyeballs Version 2 algorithm (enabled by default).
44
77
  #
45
78
  def initialize: (String remote_host, Integer remote_port, ?String local_host, ?Integer local_port) -> untyped
46
79
  end
@@ -53,7 +53,6 @@ class UDPSocket < IPSocket
53
53
  # * `outbuf` - destination String buffer
54
54
  # * `options` - keyword hash, supporting `exception: false`
55
55
  #
56
- #
57
56
  # ### Example
58
57
  # require 'socket'
59
58
  # s1 = UDPSocket.new
@@ -69,7 +69,6 @@ class UNIXServer < UNIXSocket
69
69
  # ### Parameter
70
70
  # * `backlog` - the maximum length of the queue for pending connections.
71
71
  #
72
- #
73
72
  # ### Example 1
74
73
  # require 'socket'
75
74
  # include Socket::Constants
@@ -106,7 +105,6 @@ class UNIXServer < UNIXSocket
106
105
  # * Errno::ENOBUFS - insufficient resources are available in the system to
107
106
  # complete the call
108
107
  #
109
- #
110
108
  # ### Windows Exceptions
111
109
  # On Windows systems the following system exceptions may be raised if the call
112
110
  # to *listen* fails:
@@ -126,7 +124,6 @@ class UNIXServer < UNIXSocket
126
124
  # * Errno::EOPNOTSUPP - the referenced `socket` is not a type that supports
127
125
  # the *listen* method
128
126
  #
129
- #
130
127
  # ### See
131
128
  # * listen manual pages on unix-based systems
132
129
  # * listen function in Microsoft's Winsock functions reference