rbs 3.6.1 → 3.9.5

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.
Files changed (268) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +2 -2
  3. data/.github/workflows/dependabot.yml +1 -1
  4. data/.github/workflows/ruby.yml +34 -10
  5. data/.github/workflows/windows.yml +20 -3
  6. data/.gitignore +1 -0
  7. data/.rubocop.yml +26 -1
  8. data/CHANGELOG.md +241 -0
  9. data/Rakefile +54 -4
  10. data/config.yml +317 -0
  11. data/core/array.rbs +1756 -1591
  12. data/core/basic_object.rbs +38 -35
  13. data/core/comparable.rbs +1 -1
  14. data/core/complex.rbs +166 -94
  15. data/core/data.rbs +2 -2
  16. data/core/dir.rbs +2 -18
  17. data/core/encoding.rbs +12 -32
  18. data/core/enumerable.rbs +270 -266
  19. data/core/enumerator.rbs +14 -4
  20. data/core/env.rbs +1 -1
  21. data/core/errno.rbs +33 -16
  22. data/core/errors.rbs +6 -2
  23. data/core/exception.rbs +342 -167
  24. data/core/fiber.rbs +3 -2
  25. data/core/file.rbs +26 -75
  26. data/core/float.rbs +125 -72
  27. data/core/gc.rbs +158 -42
  28. data/core/hash.rbs +122 -143
  29. data/core/integer.rbs +79 -50
  30. data/core/io/buffer.rbs +49 -43
  31. data/core/io.rbs +108 -151
  32. data/core/kernel.rbs +341 -209
  33. data/core/match_data.rbs +76 -2
  34. data/core/math.rbs +0 -36
  35. data/core/method.rbs +2 -2
  36. data/core/module.rbs +32 -27
  37. data/core/nil_class.rbs +2 -2
  38. data/core/numeric.rbs +101 -104
  39. data/core/object.rbs +1 -5
  40. data/core/object_space/weak_key_map.rbs +3 -4
  41. data/core/object_space.rbs +3 -3
  42. data/core/proc.rbs +82 -14
  43. data/core/process.rbs +110 -58
  44. data/core/ractor.rbs +57 -4
  45. data/core/range.rbs +114 -87
  46. data/core/rational.rbs +0 -2
  47. data/core/rbs/unnamed/argf.rbs +237 -36
  48. data/core/rbs/unnamed/env_class.rbs +35 -53
  49. data/core/rbs/unnamed/random.rbs +1 -2
  50. data/core/regexp.rbs +10 -56
  51. data/core/ruby_vm.rbs +88 -9
  52. data/core/rubygems/config_file.rbs +3 -0
  53. data/core/rubygems/errors.rbs +3 -6
  54. data/core/rubygems/platform.rbs +0 -9
  55. data/core/rubygems/rubygems.rbs +3 -6
  56. data/core/rubygems/version.rbs +8 -8
  57. data/core/set.rbs +4 -16
  58. data/core/string.rbs +271 -264
  59. data/core/struct.rbs +6 -18
  60. data/core/symbol.rbs +14 -21
  61. data/core/thread.rbs +32 -35
  62. data/core/time.rbs +131 -50
  63. data/core/trace_point.rbs +124 -113
  64. data/core/true_class.rbs +0 -1
  65. data/core/unbound_method.rbs +1 -1
  66. data/core/warning.rbs +9 -2
  67. data/docs/architecture.md +1 -1
  68. data/docs/syntax.md +17 -10
  69. data/ext/rbs_extension/extconf.rb +11 -0
  70. data/ext/rbs_extension/location.c +61 -29
  71. data/ext/rbs_extension/location.h +4 -3
  72. data/ext/rbs_extension/main.c +23 -1
  73. data/ext/rbs_extension/parser.c +506 -517
  74. data/ext/rbs_extension/parserstate.c +109 -30
  75. data/ext/rbs_extension/parserstate.h +6 -4
  76. data/ext/rbs_extension/rbs_extension.h +1 -10
  77. data/{ext/rbs_extension → include/rbs}/constants.h +21 -19
  78. data/include/rbs/ruby_objs.h +72 -0
  79. data/include/rbs/util/rbs_constant_pool.h +219 -0
  80. data/include/rbs.h +7 -0
  81. data/lib/rbs/annotate/annotations.rb +3 -3
  82. data/lib/rbs/annotate/rdoc_source.rb +2 -2
  83. data/lib/rbs/ast/declarations.rb +9 -4
  84. data/lib/rbs/ast/directives.rb +10 -0
  85. data/lib/rbs/ast/members.rb +2 -0
  86. data/lib/rbs/ast/type_param.rb +2 -12
  87. data/lib/rbs/cli/diff.rb +3 -3
  88. data/lib/rbs/cli/validate.rb +2 -1
  89. data/lib/rbs/cli.rb +16 -16
  90. data/lib/rbs/collection/config/lockfile_generator.rb +58 -8
  91. data/lib/rbs/collection/config.rb +5 -3
  92. data/lib/rbs/collection/sources/rubygems.rb +1 -1
  93. data/lib/rbs/collection.rb +1 -0
  94. data/lib/rbs/definition.rb +51 -34
  95. data/lib/rbs/definition_builder/ancestor_builder.rb +5 -3
  96. data/lib/rbs/definition_builder.rb +83 -24
  97. data/lib/rbs/environment.rb +33 -18
  98. data/lib/rbs/environment_loader.rb +6 -1
  99. data/lib/rbs/errors.rb +24 -0
  100. data/lib/rbs/locator.rb +2 -0
  101. data/lib/rbs/method_type.rb +2 -0
  102. data/lib/rbs/namespace.rb +1 -0
  103. data/lib/rbs/parser_aux.rb +40 -3
  104. data/lib/rbs/prototype/rb.rb +20 -12
  105. data/lib/rbs/prototype/rbi.rb +11 -6
  106. data/lib/rbs/prototype/runtime/value_object_generator.rb +7 -5
  107. data/lib/rbs/prototype/runtime.rb +7 -5
  108. data/lib/rbs/subtractor.rb +3 -3
  109. data/lib/rbs/test/hook.rb +47 -42
  110. data/lib/rbs/test/type_check.rb +7 -5
  111. data/lib/rbs/type_name.rb +14 -9
  112. data/lib/rbs/types.rb +63 -14
  113. data/lib/rbs/unit_test/spy.rb +4 -2
  114. data/lib/rbs/unit_test/type_assertions.rb +19 -13
  115. data/lib/rbs/unit_test/with_aliases.rb +3 -1
  116. data/lib/rbs/validator.rb +7 -1
  117. data/lib/rbs/version.rb +1 -1
  118. data/lib/rbs/writer.rb +10 -5
  119. data/lib/rbs.rb +1 -0
  120. data/lib/rdoc_plugin/parser.rb +2 -2
  121. data/rbs.gemspec +6 -2
  122. data/sig/ancestor_graph.rbs +5 -5
  123. data/sig/annotate/rdoc_source.rbs +2 -0
  124. data/sig/cli.rbs +2 -0
  125. data/sig/collection/config/lockfile_generator.rbs +9 -1
  126. data/sig/declarations.rbs +10 -3
  127. data/sig/definition.rbs +80 -12
  128. data/sig/definition_builder.rbs +18 -4
  129. data/sig/directives.rbs +17 -1
  130. data/sig/environment.rbs +3 -1
  131. data/sig/errors.rbs +19 -0
  132. data/sig/namespace.rbs +2 -3
  133. data/sig/parser.rbs +5 -1
  134. data/sig/prototype/rb.rbs +1 -1
  135. data/sig/resolver/constant_resolver.rbs +2 -2
  136. data/sig/resolver/context.rbs +1 -1
  137. data/sig/subtractor.rbs +1 -1
  138. data/sig/test/type_check.rbs +2 -2
  139. data/sig/type_alias_dependency.rbs +2 -2
  140. data/sig/type_alias_regularity.rbs +6 -6
  141. data/sig/type_param.rbs +4 -4
  142. data/sig/typename.rbs +8 -5
  143. data/sig/types.rbs +1 -1
  144. data/sig/unit_test/spy.rbs +2 -0
  145. data/sig/unit_test/type_assertions.rbs +2 -0
  146. data/sig/use_map.rbs +1 -1
  147. data/sig/validator.rbs +6 -2
  148. data/sig/vendorer.rbs +1 -1
  149. data/sig/writer.rbs +1 -1
  150. data/{ext/rbs_extension → src}/constants.c +35 -36
  151. data/src/ruby_objs.c +799 -0
  152. data/src/util/rbs_constant_pool.c +342 -0
  153. data/stdlib/base64/0/base64.rbs +0 -9
  154. data/stdlib/benchmark/0/benchmark.rbs +11 -2
  155. data/stdlib/bigdecimal/0/big_decimal.rbs +26 -182
  156. data/stdlib/cgi/0/core.rbs +60 -3
  157. data/stdlib/cgi/0/manifest.yaml +1 -0
  158. data/stdlib/coverage/0/coverage.rbs +0 -3
  159. data/stdlib/csv/0/csv.rbs +18 -58
  160. data/stdlib/csv/0/manifest.yaml +1 -0
  161. data/stdlib/date/0/date.rbs +27 -42
  162. data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -6
  163. data/stdlib/digest/0/digest.rbs +25 -2
  164. data/stdlib/erb/0/erb.rbs +0 -1
  165. data/stdlib/etc/0/etc.rbs +51 -34
  166. data/stdlib/fileutils/0/fileutils.rbs +3 -44
  167. data/stdlib/io-console/0/io-console.rbs +69 -15
  168. data/stdlib/ipaddr/0/ipaddr.rbs +16 -4
  169. data/stdlib/json/0/json.rbs +107 -120
  170. data/stdlib/logger/0/log_device.rbs +1 -1
  171. data/stdlib/logger/0/logger.rbs +3 -18
  172. data/stdlib/minitest/0/kernel.rbs +2 -2
  173. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +4 -1
  174. data/stdlib/minitest/0/minitest/assertion.rbs +1 -0
  175. data/stdlib/minitest/0/minitest/assertions.rbs +58 -13
  176. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +7 -0
  177. data/stdlib/minitest/0/minitest/bench_spec.rbs +8 -8
  178. data/stdlib/minitest/0/minitest/benchmark.rbs +17 -16
  179. data/stdlib/minitest/0/minitest/compress.rbs +13 -0
  180. data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
  181. data/stdlib/minitest/0/minitest/mock.rbs +9 -5
  182. data/stdlib/minitest/0/minitest/parallel/executor.rbs +4 -0
  183. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +0 -1
  184. data/stdlib/minitest/0/minitest/pride_io.rbs +8 -0
  185. data/stdlib/minitest/0/minitest/pride_lol.rbs +2 -0
  186. data/stdlib/minitest/0/minitest/progress_reporter.rbs +1 -1
  187. data/stdlib/minitest/0/minitest/reportable.rbs +2 -0
  188. data/stdlib/minitest/0/minitest/runnable.rbs +33 -1
  189. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +1 -1
  190. data/stdlib/minitest/0/minitest/spec/dsl.rbs +10 -6
  191. data/stdlib/minitest/0/minitest/spec.rbs +1 -1
  192. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +5 -0
  193. data/stdlib/minitest/0/minitest/summary_reporter.rbs +0 -7
  194. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +1 -1
  195. data/stdlib/minitest/0/minitest/test.rbs +7 -14
  196. data/stdlib/minitest/0/minitest/unexpected_error.rbs +2 -0
  197. data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
  198. data/stdlib/minitest/0/minitest/unit.rbs +1 -2
  199. data/stdlib/minitest/0/minitest.rbs +41 -892
  200. data/stdlib/monitor/0/monitor.rbs +13 -4
  201. data/stdlib/net-http/0/net-http.rbs +42 -109
  202. data/stdlib/nkf/0/nkf.rbs +30 -0
  203. data/stdlib/objspace/0/objspace.rbs +1 -2
  204. data/stdlib/observable/0/observable.rbs +1 -1
  205. data/stdlib/open-uri/0/manifest.yaml +1 -0
  206. data/stdlib/open-uri/0/open-uri.rbs +52 -0
  207. data/stdlib/open3/0/open3.rbs +0 -8
  208. data/stdlib/openssl/0/manifest.yaml +1 -0
  209. data/stdlib/openssl/0/openssl.rbs +235 -143
  210. data/stdlib/optparse/0/optparse.rbs +58 -18
  211. data/stdlib/pathname/0/pathname.rbs +2 -8
  212. data/stdlib/pp/0/pp.rbs +3 -1
  213. data/stdlib/prettyprint/0/prettyprint.rbs +0 -4
  214. data/stdlib/pstore/0/pstore.rbs +0 -6
  215. data/stdlib/psych/0/core_ext.rbs +12 -0
  216. data/stdlib/psych/0/psych.rbs +15 -4
  217. data/stdlib/pty/0/pty.rbs +46 -4
  218. data/stdlib/rdoc/0/code_object.rbs +0 -4
  219. data/stdlib/rdoc/0/markup.rbs +10 -12
  220. data/stdlib/rdoc/0/rdoc.rbs +13 -8
  221. data/stdlib/resolv/0/resolv.rbs +21 -12
  222. data/stdlib/ripper/0/ripper.rbs +0 -2
  223. data/stdlib/securerandom/0/securerandom.rbs +7 -2
  224. data/stdlib/shellwords/0/shellwords.rbs +11 -12
  225. data/stdlib/singleton/0/singleton.rbs +0 -1
  226. data/stdlib/socket/0/addrinfo.rbs +1 -2
  227. data/stdlib/socket/0/basic_socket.rbs +0 -5
  228. data/stdlib/socket/0/socket.rbs +32 -27
  229. data/stdlib/socket/0/tcp_server.rbs +0 -3
  230. data/stdlib/socket/0/tcp_socket.rbs +36 -3
  231. data/stdlib/socket/0/udp_socket.rbs +0 -1
  232. data/stdlib/socket/0/unix_server.rbs +0 -3
  233. data/stdlib/socket/0/unix_socket.rbs +4 -2
  234. data/{core/string_io.rbs → stdlib/stringio/0/stringio.rbs} +1 -1
  235. data/stdlib/strscan/0/string_scanner.rbs +1265 -422
  236. data/stdlib/tempfile/0/tempfile.rbs +135 -28
  237. data/stdlib/time/0/time.rbs +48 -35
  238. data/stdlib/timeout/0/timeout.rbs +11 -8
  239. data/stdlib/tmpdir/0/tmpdir.rbs +10 -3
  240. data/stdlib/tsort/0/tsort.rbs +0 -4
  241. data/stdlib/uri/0/common.rbs +28 -30
  242. data/stdlib/uri/0/ftp.rbs +1 -1
  243. data/stdlib/uri/0/generic.rbs +22 -18
  244. data/stdlib/uri/0/http.rbs +2 -2
  245. data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
  246. data/stdlib/zlib/0/buf_error.rbs +1 -70
  247. data/stdlib/zlib/0/data_error.rbs +1 -70
  248. data/stdlib/zlib/0/deflate.rbs +8 -72
  249. data/stdlib/zlib/0/error.rbs +1 -70
  250. data/stdlib/zlib/0/gzip_file/crc_error.rbs +2 -105
  251. data/stdlib/zlib/0/gzip_file/error.rbs +2 -105
  252. data/stdlib/zlib/0/gzip_file/length_error.rbs +2 -105
  253. data/stdlib/zlib/0/gzip_file/no_footer.rbs +2 -105
  254. data/stdlib/zlib/0/gzip_file.rbs +1 -71
  255. data/stdlib/zlib/0/gzip_reader.rbs +3 -74
  256. data/stdlib/zlib/0/gzip_writer.rbs +1 -70
  257. data/stdlib/zlib/0/inflate.rbs +4 -71
  258. data/stdlib/zlib/0/mem_error.rbs +1 -70
  259. data/stdlib/zlib/0/need_dict.rbs +1 -70
  260. data/stdlib/zlib/0/stream_end.rbs +1 -70
  261. data/stdlib/zlib/0/stream_error.rbs +1 -70
  262. data/stdlib/zlib/0/version_error.rbs +1 -70
  263. data/stdlib/zlib/0/zlib.rbs +0 -2
  264. data/stdlib/zlib/0/zstream.rbs +4 -72
  265. metadata +17 -13
  266. data/ext/rbs_extension/ruby_objs.c +0 -602
  267. data/ext/rbs_extension/ruby_objs.h +0 -51
  268. data/stdlib/minitest/0/manifest.yaml +0 -2
@@ -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'],
@@ -463,7 +466,7 @@ end
463
466
  class Resolv::DNS::Message
464
467
  def self.decode: (String m) -> instance
465
468
 
466
- def ==: (instance other) -> bool
469
+ def ==: (self other) -> bool
467
470
 
468
471
  def aa: () -> Integer
469
472
 
@@ -555,7 +558,7 @@ class Resolv::DNS::Message::MessageDecoder
555
558
 
556
559
  private
557
560
 
558
- def initialize: (String data) { (instance) -> void } -> untyped
561
+ def initialize: (String data) { (self) -> void } -> untyped
559
562
  end
560
563
 
561
564
  class Resolv::DNS::Message::MessageEncoder
@@ -594,12 +597,13 @@ 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
  #
600
604
  def self.create: (Resolv::DNS::dns_name arg) -> untyped
601
605
 
602
- def ==: (instance other) -> bool
606
+ def ==: (self other) -> bool
603
607
 
604
608
  def []: (Integer i) -> Resolv::DNS::Label::Str?
605
609
 
@@ -635,7 +639,7 @@ class Resolv::DNS::Name
635
639
  # p Resolv::DNS::Name.create("x.y.z.").subdomain_of?(domain) #=> false
636
640
  # p Resolv::DNS::Name.create("w.z").subdomain_of?(domain) #=> false
637
641
  #
638
- def subdomain_of?: (instance other) -> bool
642
+ def subdomain_of?: (self other) -> bool
639
643
 
640
644
  def to_a: () -> Array[Resolv::DNS::Label::Str]
641
645
 
@@ -1487,14 +1491,14 @@ class Resolv::IPv4
1487
1491
  #
1488
1492
  def self.create: (String | instance arg) -> instance
1489
1493
 
1490
- def ==: (instance other) -> bool
1494
+ def ==: (self other) -> bool
1491
1495
 
1492
1496
  # <!-- rdoc-file=lib/resolv.rb -->
1493
1497
  # The raw IPv4 address as a String.
1494
1498
  #
1495
1499
  def address: () -> String
1496
1500
 
1497
- def eql?: (instance other) -> bool
1501
+ def eql?: (self other) -> bool
1498
1502
 
1499
1503
  def hash: () -> Integer
1500
1504
 
@@ -1534,19 +1538,20 @@ 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
  #
1540
1545
  def self.create: (String | instance arg) -> instance
1541
1546
 
1542
- def ==: (instance other) -> bool
1547
+ def ==: (self other) -> bool
1543
1548
 
1544
1549
  # <!-- rdoc-file=lib/resolv.rb -->
1545
1550
  # The raw IPv6 address as a String.
1546
1551
  #
1547
1552
  def address: () -> String
1548
1553
 
1549
- def eql?: (instance other) -> bool
1554
+ def eql?: (self other) -> bool
1550
1555
 
1551
1556
  def hash: () -> Integer
1552
1557
 
@@ -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
@@ -541,7 +541,7 @@ class Addrinfo
541
541
 
542
542
  def marshal_dump: () -> String
543
543
 
544
- def marshal_load: (String) -> instance
544
+ def marshal_load: (String) -> self
545
545
 
546
546
  # <!--
547
547
  # rdoc-file=ext/socket/raddrinfo.c
@@ -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