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
@@ -2,24 +2,6 @@ interface _ToJson
2
2
  def to_json: (?JSON::State state) -> String
3
3
  end
4
4
 
5
- interface _JsonToWritableIO
6
- def to_io: () -> _JsonWrite
7
- end
8
-
9
- interface _JsonWrite
10
- def write: (String json) -> void
11
- end
12
-
13
- interface _JsonReadableIO
14
- def to_io: () -> _JsonRead
15
- end
16
-
17
- interface _JsonRead
18
- def read: () -> string
19
- end
20
-
21
- type json_options = Hash[Symbol, untyped]
22
-
23
5
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
24
6
  # The base exception for JSON errors.
25
7
  #
@@ -94,10 +76,6 @@ end
94
76
  class JSON::Pure::Parser
95
77
  end
96
78
 
97
- type json_generator = singleton(::JSON::Ext::Generator) | singleton(::JSON::Pure::Generator)
98
- type json_parser = singleton(::JSON::Ext::Parser) | singleton(::JSON::Pure::Parser)
99
- type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure::Generator::State)
100
-
101
79
  # <!-- rdoc-file=ext/json/lib/json.rb -->
102
80
  # # JavaScript Object Notation (JSON)
103
81
  #
@@ -115,7 +93,6 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
115
93
  # name is double-quoted text; the values may be any JSON values:
116
94
  # {"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null}
117
95
  #
118
- #
119
96
  # A JSON array or object may contain nested arrays, objects, and scalars to any
120
97
  # depth:
121
98
  # {"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]}
@@ -134,13 +111,11 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
134
111
  # * `JSON.parse(source, opts)`
135
112
  # * `JSON.parse!(source, opts)`
136
113
  #
137
- #
138
114
  # where
139
115
  # * `source` is a Ruby object.
140
116
  # * `opts` is a Hash object containing options that control both input allowed
141
117
  # and output formatting.
142
118
  #
143
- #
144
119
  # The difference between the two methods is that JSON.parse! omits some checks
145
120
  # and may not be safe for some `source` data; use it only for data from trusted
146
121
  # sources. Use the safer method JSON.parse for less trusted sources.
@@ -298,7 +273,6 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
298
273
  # * `opts` is a Hash object containing options that control both input allowed
299
274
  # and output formatting.
300
275
  #
301
- #
302
276
  # #### Generating JSON from Arrays
303
277
  #
304
278
  # When the source is a Ruby Array, JSON.generate returns a String containing a
@@ -417,7 +391,6 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
417
391
  # inserted before the colon in each JSON object's pair; defaults to the
418
392
  # empty String, `''`.
419
393
  #
420
- #
421
394
  # In this example, `obj` is used first to generate the shortest JSON data (no
422
395
  # whitespace), then again with all formatting options specified:
423
396
  #
@@ -465,7 +438,6 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
465
438
  # * JSON.parse, called with option `create_additions`, uses that information
466
439
  # to create a proper Ruby object.
467
440
  #
468
- #
469
441
  # This example shows a Range being generated into JSON and parsed back into
470
442
  # Ruby, both without and with the addition for Range:
471
443
  # ruby = Range.new(0, 2)
@@ -477,13 +449,13 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
477
449
  # json1 = JSON.generate(ruby)
478
450
  # ruby1 = JSON.parse(json1, create_additions: true)
479
451
  # # Make a nice display.
480
- # display = <<EOT
481
- # Generated JSON:
482
- # Without addition: #{json0} (#{json0.class})
483
- # With addition: #{json1} (#{json1.class})
484
- # Parsed JSON:
485
- # Without addition: #{ruby0.inspect} (#{ruby0.class})
486
- # With addition: #{ruby1.inspect} (#{ruby1.class})
452
+ # display = <<~EOT
453
+ # Generated JSON:
454
+ # Without addition: #{json0} (#{json0.class})
455
+ # With addition: #{json1} (#{json1.class})
456
+ # Parsed JSON:
457
+ # Without addition: #{ruby0.inspect} (#{ruby0.class})
458
+ # With addition: #{ruby1.inspect} (#{ruby1.class})
487
459
  # EOT
488
460
  # puts display
489
461
  #
@@ -517,7 +489,6 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
517
489
  # * Symbol: `require 'json/add/symbol'`
518
490
  # * Time: `require 'json/add/time'`
519
491
  #
520
- #
521
492
  # To reduce punctuation clutter, the examples below show the generated JSON via
522
493
  # `puts`, rather than the usual `inspect`,
523
494
  #
@@ -660,13 +631,13 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
660
631
  # json1 = JSON.generate(foo1)
661
632
  # obj1 = JSON.parse(json1, create_additions: true)
662
633
  # # Make a nice display.
663
- # display = <<EOT
664
- # Generated JSON:
665
- # Without custom addition: #{json0} (#{json0.class})
666
- # With custom addition: #{json1} (#{json1.class})
667
- # Parsed JSON:
668
- # Without custom addition: #{obj0.inspect} (#{obj0.class})
669
- # With custom addition: #{obj1.inspect} (#{obj1.class})
634
+ # display = <<~EOT
635
+ # Generated JSON:
636
+ # Without custom addition: #{json0} (#{json0.class})
637
+ # With custom addition: #{json1} (#{json1.class})
638
+ # Parsed JSON:
639
+ # Without custom addition: #{obj0.inspect} (#{obj0.class})
640
+ # With custom addition: #{obj1.inspect} (#{obj1.class})
670
641
  # EOT
671
642
  # puts display
672
643
  #
@@ -680,6 +651,32 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
680
651
  # With custom addition: #<Foo:0x0000000006473bb8 @bar=0, @baz=1> (Foo)
681
652
  #
682
653
  module JSON
654
+ type options = Hash[Symbol, untyped]
655
+
656
+ type generator = singleton(::JSON::Ext::Generator) | singleton(::JSON::Pure::Generator)
657
+
658
+ type parser = singleton(::JSON::Ext::Parser) | singleton(::JSON::Pure::Parser)
659
+
660
+ type state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure::Generator::State)
661
+
662
+ interface _WritableIO
663
+ def to_io: () -> _Write
664
+ end
665
+
666
+ interface _Write
667
+ def write: (String json) -> void
668
+
669
+ def flush: () -> void
670
+ end
671
+
672
+ interface _ReadableIO
673
+ def to_io: () -> _Read
674
+ end
675
+
676
+ interface _Read
677
+ def read: () -> string
678
+ end
679
+
683
680
  # <!--
684
681
  # rdoc-file=ext/json/lib/json/common.rb
685
682
  # - JSON[object] -> new_array or new_string
@@ -694,7 +691,7 @@ module JSON
694
691
  # ruby = [0, 1, nil]
695
692
  # JSON[ruby] # => '[0,1,null]'
696
693
  #
697
- def self.[]: (untyped object, ?json_options opts) -> untyped
694
+ def self.[]: (untyped object, ?options opts) -> untyped
698
695
 
699
696
  # <!--
700
697
  # rdoc-file=ext/json/lib/json/common.rb
@@ -714,7 +711,7 @@ module JSON
714
711
  #
715
712
  def self.create_id=: (_ToS create_id) -> _ToS
716
713
 
717
- def self.deep_const_get: (_ToS path) -> untyped
714
+ def self.deep_const_get: (interned path) -> untyped
718
715
 
719
716
  # <!--
720
717
  # rdoc-file=ext/json/lib/json/common.rb
@@ -731,7 +728,6 @@ module JSON
731
728
  # * Argument `limit`, if given, is passed to JSON.generate as option
732
729
  # `max_nesting`.
733
730
  #
734
- #
735
731
  # ---
736
732
  #
737
733
  # When argument `io` is not given, returns the JSON String generated from `obj`:
@@ -750,22 +746,22 @@ module JSON
750
746
  # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
751
747
  #
752
748
  def self?.dump: (_ToJson obj, ?Integer limit) -> String
753
- | (_ToJson obj, _JsonToWritableIO anIO) -> _JsonWrite
754
- | (_ToJson obj, _JsonWrite anIO, ?Integer limit) -> _JsonWrite
749
+ | (_ToJson obj, _WritableIO anIO) -> _Write
750
+ | (_ToJson obj, _Write anIO, ?Integer limit) -> _Write
755
751
 
756
752
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
757
753
  # Sets or returns the default options for the JSON.dump method. Initially:
758
754
  # opts = JSON.dump_default_options
759
- # opts # => {:max_nesting=>false, :allow_nan=>true, :script_safe=>false}
755
+ # opts # => {:max_nesting=>false, :allow_nan=>true}
760
756
  #
761
- def self.dump_default_options: () -> json_options
757
+ def self.dump_default_options: () -> options
762
758
 
763
759
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
764
760
  # Sets or returns the default options for the JSON.dump method. Initially:
765
761
  # opts = JSON.dump_default_options
766
- # opts # => {:max_nesting=>false, :allow_nan=>true, :script_safe=>false}
762
+ # opts # => {:max_nesting=>false, :allow_nan=>true}
767
763
  #
768
- def self.dump_default_options=: (json_options) -> json_options
764
+ def self.dump_default_options=: (options) -> options
769
765
 
770
766
  # <!--
771
767
  # rdoc-file=ext/json/lib/json/common.rb
@@ -782,7 +778,7 @@ module JSON
782
778
  # # Raises SystemStackError (stack level too deep):
783
779
  # JSON.fast_generate(a)
784
780
  #
785
- def self?.fast_generate: (_ToJson obj, ?json_options opts) -> String
781
+ def self?.fast_generate: (_ToJson obj, ?options opts) -> String
786
782
 
787
783
  alias self.fast_unparse self.fast_generate
788
784
 
@@ -825,16 +821,14 @@ module JSON
825
821
  # # Raises JSON::NestingError (nesting of 100 is too deep):
826
822
  # JSON.generate(a)
827
823
  #
828
- def self?.generate: (_ToJson obj, ?json_options opts) -> String
824
+ def self?.generate: (_ToJson obj, ?options opts) -> String
829
825
 
830
826
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
831
- # Returns the JSON generator module that is used by JSON. This is either
832
- # JSON::Ext::Generator or JSON::Pure::Generator:
833
- # JSON.generator # => JSON::Ext::Generator
827
+ # Returns the JSON generator module that is used by JSON.
834
828
  #
835
- def self.generator: () -> json_generator
829
+ def self.generator: () -> generator
836
830
 
837
- def self.generator=: (json_generator generator) -> void
831
+ def self.generator=: (generator generator) -> void
838
832
 
839
833
  # <!--
840
834
  # rdoc-file=ext/json/lib/json/common.rb
@@ -850,6 +844,15 @@ module JSON
850
844
  # -->
851
845
  # Returns the Ruby objects created by parsing the given `source`.
852
846
  #
847
+ # BEWARE: This method is meant to serialise data from trusted user input, like
848
+ # from your own database server or clients under your control, it could be
849
+ # dangerous to allow untrusted users to pass JSON sources into it. If you must
850
+ # use it, use JSON.unsafe_load instead to make it clear.
851
+ #
852
+ # Since JSON version 2.8.0, `load` emits a deprecation warning when a non native
853
+ # type is deserialized, without `create_additions` being explicitly enabled, and
854
+ # in JSON version 3.0, `load` will have `create_additions` disabled by default.
855
+ #
853
856
  # * Argument `source` must be, or be convertible to, a String:
854
857
  # * If `source` responds to instance method `to_str`, `source.to_str`
855
858
  # becomes the source.
@@ -860,37 +863,31 @@ module JSON
860
863
  # * If both of the following are true, source becomes the String `'null'`:
861
864
  # * Option `allow_blank` specifies a truthy value.
862
865
  # * The source, as defined above, is `nil` or the empty String `''`.
863
- #
864
866
  # * Otherwise, `source` remains the source.
865
- #
866
867
  # * Argument `proc`, if given, must be a Proc that accepts one argument. It
867
868
  # will be called recursively with each result (depth-first order). See
868
- # details below. BEWARE: This method is meant to serialise data from trusted
869
- # user input, like from your own database server or clients under your
870
- # control, it could be dangerous to allow untrusted users to pass JSON
871
- # sources into it.
869
+ # details below.
872
870
  # * Argument `opts`, if given, contains a Hash of options for the parsing. See
873
871
  # [Parsing Options](#module-JSON-label-Parsing+Options). The default options
874
872
  # can be changed via method JSON.load_default_options=.
875
873
  #
876
- #
877
874
  # ---
878
875
  #
879
876
  # When no `proc` is given, modifies `source` as above and returns the result of
880
877
  # `parse(source, opts)`; see #parse.
881
878
  #
882
879
  # Source for following examples:
883
- # source = <<-EOT
884
- # {
885
- # "name": "Dave",
886
- # "age" :40,
887
- # "hats": [
888
- # "Cattleman's",
889
- # "Panama",
890
- # "Tophat"
891
- # ]
892
- # }
893
- # EOT
880
+ # source = <<~JSON
881
+ # {
882
+ # "name": "Dave",
883
+ # "age" :40,
884
+ # "hats": [
885
+ # "Cattleman's",
886
+ # "Panama",
887
+ # "Tophat"
888
+ # ]
889
+ # }
890
+ # JSON
894
891
  #
895
892
  # Load a String:
896
893
  # ruby = JSON.load(source)
@@ -916,7 +913,6 @@ module JSON
916
913
  # * Recursively calls `proc(result)`.
917
914
  # * Returns the final result.
918
915
  #
919
- #
920
916
  # Example:
921
917
  # require 'json'
922
918
  #
@@ -978,7 +974,7 @@ module JSON
978
974
  # #<Admin:0x00000000064c41f8
979
975
  # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
980
976
  #
981
- def self?.load: (string | _JsonReadableIO | _JsonRead source, ?Proc proc, ?json_options options) -> untyped
977
+ def self?.load: (string | _ReadableIO | _Read source, ?Proc proc, ?options options) -> untyped
982
978
 
983
979
  # <!--
984
980
  # rdoc-file=ext/json/lib/json/common.rb
@@ -989,7 +985,7 @@ module JSON
989
985
  #
990
986
  # See method #parse.
991
987
  #
992
- def self?.load_file: (string path, ?json_options opts) -> untyped
988
+ def self?.load_file: (string path, ?options opts) -> untyped
993
989
 
994
990
  # <!--
995
991
  # rdoc-file=ext/json/lib/json/common.rb
@@ -1000,21 +996,21 @@ module JSON
1000
996
  #
1001
997
  # See method #parse!
1002
998
  #
1003
- def self?.load_file!: (string path, ?json_options opts) -> untyped
999
+ def self?.load_file!: (string path, ?options opts) -> untyped
1004
1000
 
1005
1001
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
1006
1002
  # Sets or returns default options for the JSON.load method. Initially:
1007
1003
  # opts = JSON.load_default_options
1008
1004
  # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
1009
1005
  #
1010
- def self.load_default_options: () -> json_options
1006
+ def self.load_default_options: () -> options
1011
1007
 
1012
1008
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
1013
1009
  # Sets or returns default options for the JSON.load method. Initially:
1014
1010
  # opts = JSON.load_default_options
1015
1011
  # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
1016
1012
  #
1017
- def self.load_default_options=: (json_options) -> json_options
1013
+ def self.load_default_options=: (options) -> options
1018
1014
 
1019
1015
  # <!--
1020
1016
  # rdoc-file=ext/json/lib/json/common.rb
@@ -1045,17 +1041,17 @@ module JSON
1045
1041
  # \JSON](#module-JSON-label-Parsing+JSON).
1046
1042
  #
1047
1043
  # Parses nested JSON objects:
1048
- # source = <<-EOT
1049
- # {
1050
- # "name": "Dave",
1051
- # "age" :40,
1052
- # "hats": [
1053
- # "Cattleman's",
1054
- # "Panama",
1055
- # "Tophat"
1056
- # ]
1057
- # }
1058
- # EOT
1044
+ # source = <<~JSON
1045
+ # {
1046
+ # "name": "Dave",
1047
+ # "age" :40,
1048
+ # "hats": [
1049
+ # "Cattleman's",
1050
+ # "Panama",
1051
+ # "Tophat"
1052
+ # ]
1053
+ # }
1054
+ # JSON
1059
1055
  # ruby = JSON.parse(source)
1060
1056
  # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1061
1057
  #
@@ -1065,7 +1061,7 @@ module JSON
1065
1061
  # # Raises JSON::ParserError (783: unexpected token at ''):
1066
1062
  # JSON.parse('')
1067
1063
  #
1068
- def self?.parse: (string source, ?json_options opts) -> untyped
1064
+ def self?.parse: (string source, ?options opts) -> untyped
1069
1065
 
1070
1066
  # <!--
1071
1067
  # rdoc-file=ext/json/lib/json/common.rb
@@ -1081,16 +1077,14 @@ module JSON
1081
1077
  # checking for nesting depth.
1082
1078
  # * Option `allow_nan`, if not provided, defaults to `true`.
1083
1079
  #
1084
- def self?.parse!: (string source, ?json_options opts) -> untyped
1080
+ def self?.parse!: (string source, ?options opts) -> untyped
1085
1081
 
1086
1082
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
1087
- # Returns the JSON parser class that is used by JSON. This is either
1088
- # JSON::Ext::Parser or JSON::Pure::Parser:
1089
- # JSON.parser # => JSON::Ext::Parser
1083
+ # Returns the JSON parser class that is used by JSON.
1090
1084
  #
1091
- def self.parser: () -> json_parser
1085
+ def self.parser: () -> parser
1092
1086
 
1093
- def self.parser=: (json_parser parser) -> void
1087
+ def self.parser=: (parser parser) -> void
1094
1088
 
1095
1089
  # <!--
1096
1090
  # rdoc-file=ext/json/lib/json/common.rb
@@ -1124,7 +1118,7 @@ module JSON
1124
1118
  # }
1125
1119
  # }
1126
1120
  #
1127
- def self?.pretty_generate: (_ToJson obj, ?json_options opts) -> untyped
1121
+ def self?.pretty_generate: (_ToJson obj, ?options opts) -> untyped
1128
1122
 
1129
1123
  alias self.pretty_unparse self.pretty_generate
1130
1124
 
@@ -1137,38 +1131,34 @@ module JSON
1137
1131
 
1138
1132
  # <!--
1139
1133
  # rdoc-file=ext/json/lib/json/common.rb
1140
- # - restore(source, proc = nil, options = {})
1134
+ # - restore(source, proc = nil, options = nil)
1141
1135
  # -->
1142
1136
  #
1143
1137
  alias self.restore self.load
1144
1138
 
1145
1139
  # <!--
1146
1140
  # rdoc-file=ext/json/lib/json/common.rb
1147
- # - restore(source, proc = nil, options = {})
1141
+ # - restore(source, proc = nil, options = nil)
1148
1142
  # -->
1149
1143
  #
1150
1144
  alias restore load
1151
1145
 
1152
1146
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
1153
- # Sets or Returns the JSON generator state class that is used by JSON. This is
1154
- # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
1155
- # JSON.state # => JSON::Ext::Generator::State
1147
+ # Sets or Returns the JSON generator state class that is used by JSON.
1156
1148
  #
1157
- def self.state: () -> json_state
1149
+ def self.state: () -> state
1158
1150
 
1159
1151
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
1160
- # Sets or Returns the JSON generator state class that is used by JSON. This is
1161
- # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
1162
- # JSON.state # => JSON::Ext::Generator::State
1152
+ # Sets or Returns the JSON generator state class that is used by JSON.
1163
1153
  #
1164
- def self.state=: (json_state) -> json_state
1154
+ def self.state=: (state) -> state
1165
1155
 
1166
1156
  alias self.unparse self.generate
1167
1157
 
1168
1158
  alias unparse generate
1169
1159
  end
1170
1160
 
1171
- JSON::FAST_STATE_PROTOTYPE: json_state
1161
+ JSON::FAST_STATE_PROTOTYPE: JSON::state
1172
1162
 
1173
1163
  JSON::Infinity: Float
1174
1164
 
@@ -1178,13 +1168,10 @@ JSON::MinusInfinity: Float
1178
1168
 
1179
1169
  JSON::NaN: Float
1180
1170
 
1181
- JSON::PRETTY_STATE_PROTOTYPE: json_state
1171
+ JSON::PRETTY_STATE_PROTOTYPE: JSON::state
1182
1172
 
1183
- JSON::SAFE_STATE_PROTOTYPE: json_state
1173
+ JSON::SAFE_STATE_PROTOTYPE: JSON::state
1184
1174
 
1185
- # <!-- rdoc-file=ext/json/lib/json/version.rb -->
1186
- # JSON version
1187
- #
1188
1175
  JSON::VERSION: String
1189
1176
 
1190
1177
  JSON::VERSION_ARRAY: Array[Integer]
@@ -1228,8 +1215,8 @@ module Kernel
1228
1215
  # The *opts* argument is passed through to generate/parse respectively. See
1229
1216
  # generate and parse for their documentation.
1230
1217
  #
1231
- def JSON: (string source, ?json_options opts) -> untyped
1232
- | (_ToJson obj, ?json_options opts) -> String
1218
+ def JSON: (string source, ?JSON::options opts) -> untyped
1219
+ | (_ToJson obj, ?JSON::options opts) -> String
1233
1220
  end
1234
1221
 
1235
1222
  %a{annotate:rdoc:skip}
@@ -57,7 +57,7 @@ class Logger
57
57
 
58
58
  # <!--
59
59
  # rdoc-file=lib/logger/log_device.rb
60
- # - new(log = nil, shift_age: nil, shift_size: nil, shift_period_suffix: nil, binmode: false)
60
+ # - new(log = nil, shift_age: nil, shift_size: nil, shift_period_suffix: nil, binmode: false, reraise_write_errors: [])
61
61
  # -->
62
62
  #
63
63
  def initialize: (?untyped logdev, ?binmode: boolish, ?shift_period_suffix: String, ?shift_size: Integer, ?shift_age: Numeric | String) -> void
@@ -66,13 +66,11 @@
66
66
  # * A severity (the required argument to #add).
67
67
  # * An automatically created timestamp.
68
68
  #
69
- #
70
69
  # And may also have:
71
70
  #
72
71
  # * A message.
73
72
  # * A program name.
74
73
  #
75
- #
76
74
  # Example:
77
75
  #
78
76
  # logger = Logger.new($stdout)
@@ -92,7 +90,6 @@
92
90
  # * Program name.
93
91
  # * Message.
94
92
  #
95
- #
96
93
  # You can use a different entry format by:
97
94
  #
98
95
  # * Setting a custom format proc (affects following entries); see
@@ -112,8 +109,6 @@
112
109
  #
113
110
  # logger.error("#{my_slow_message_generator}")
114
111
  #
115
- #
116
- #
117
112
  # ### Severity
118
113
  #
119
114
  # The severity of a log entry has two effects:
@@ -123,7 +118,6 @@
123
118
  # * Indicates to any log reader (whether a person or a program) the relative
124
119
  # importance of the entry.
125
120
  #
126
- #
127
121
  # ### Timestamp
128
122
  #
129
123
  # The timestamp for a log entry is generated automatically when the entry is
@@ -157,7 +151,6 @@
157
151
  # * An Exception: `message.message` is used.
158
152
  # * Anything else: `message.inspect` is used.
159
153
  #
160
- #
161
154
  # **Note**: Logger::Formatter does not escape or sanitize the message passed to
162
155
  # it. Developers should be aware that malicious data (user input) may be in the
163
156
  # message, and should explicitly escape untrusted data.
@@ -271,7 +264,6 @@
271
264
  # * Only the most recent log file is open and active; the others are closed
272
265
  # and inactive.
273
266
  #
274
- #
275
267
  # ### Size-Based Rotation
276
268
  #
277
269
  # For size-based log file rotation, call Logger.new with:
@@ -282,7 +274,6 @@
282
274
  # * Argument `shift_size` as a positive integer: the maximum size (in bytes)
283
275
  # of each log file; defaults to 1048576 (1 megabyte).
284
276
  #
285
- #
286
277
  # Examples:
287
278
  #
288
279
  # logger = Logger.new('t.log', 3) # Three 1-megabyte files.
@@ -300,14 +291,12 @@
300
291
  # * `t.log` is closed and renamed to `t.log.0`.
301
292
  # * A new file `t.log` is opened.
302
293
  #
303
- #
304
294
  # The second time `t.log` is full:
305
295
  #
306
296
  # * +t.log.0 is renamed as `t.log.1`.
307
297
  # * `t.log` is closed and renamed to `t.log.0`.
308
298
  # * A new file `t.log` is opened.
309
299
  #
310
- #
311
300
  # Each subsequent time that `t.log` is full, the log files are rotated:
312
301
  #
313
302
  # * `t.log.1` is removed.
@@ -315,7 +304,6 @@
315
304
  # * `t.log` is closed and renamed to `t.log.0`.
316
305
  # * A new file `t.log` is opened.
317
306
  #
318
- #
319
307
  # ### Periodic Rotation
320
308
  #
321
309
  # For periodic rotation, call Logger.new with:
@@ -323,7 +311,6 @@
323
311
  # * Argument `logdev` as a file path.
324
312
  # * Argument `shift_age` as a string period indicator.
325
313
  #
326
- #
327
314
  # Examples:
328
315
  #
329
316
  # logger = Logger.new('t.log', 'daily') # Rotate log files daily.
@@ -341,7 +328,6 @@
341
328
  # * A new log file `t.log` is opened.
342
329
  # * Nothing is removed.
343
330
  #
344
- #
345
331
  # The default format for the suffix is `'%Y%m%d'`, which produces a suffix
346
332
  # similar to the one above. You can set a different format using create-time
347
333
  # option `shift_period_suffix`; see details and suggestions at
@@ -534,7 +520,6 @@ class Logger
534
520
  # * `progname`: The program name for the entry.
535
521
  # * `msg`: The message for the entry (string or string-convertible object).
536
522
  #
537
- #
538
523
  # The proc should return a string containing the formatted entry.
539
524
  #
540
525
  # This custom formatter uses [String#dump](rdoc-ref:String#dump) to escape the
@@ -568,7 +553,6 @@ class Logger
568
553
  # * `progname`: The program name for the entry.
569
554
  # * `msg`: The message for the entry (string or string-convertible object).
570
555
  #
571
- #
572
556
  # The proc should return a string containing the formatted entry.
573
557
  #
574
558
  # This custom formatter uses [String#dump](rdoc-ref:String#dump) to escape the
@@ -670,7 +654,6 @@ class Logger
670
654
  # * If `logdev` is an IO stream (usually `$stdout`, `$stderr`, or an open File
671
655
  # object), opens the stream for append.
672
656
  #
673
- #
674
657
  # Example:
675
658
  #
676
659
  # logger = Logger.new('t.log')
@@ -770,7 +753,6 @@ class Logger
770
753
  # are to be written to the given stream.
771
754
  # * `nil` or `File::NULL`: no entries are to be written.
772
755
  #
773
- #
774
756
  # Examples:
775
757
  #
776
758
  # Logger.new('t.log')
@@ -797,6 +779,9 @@ class Logger
797
779
  # * `shift_period_suffix`: sets the format for the filename suffix for
798
780
  # periodic log file rotation; default is `'%Y%m%d'`. See [Periodic
799
781
  # Rotation](rdoc-ref:Logger@Periodic+Rotation).
782
+ # * `reraise_write_errors`: An array of exception classes, which will be
783
+ # reraised if there is an error when writing to the log device. The default
784
+ # is to swallow all exceptions raised.
800
785
  #
801
786
  def initialize: (logdev? logdev, ?Numeric | String shift_age, ?Integer shift_size, ?shift_period_suffix: String, ?binmode: boolish, ?datetime_format: String, ?formatter: _Formatter, ?progname: String, ?level: Integer | interned) -> void
802
787
  end
@@ -32,11 +32,11 @@ module Kernel : ::BasicObject
32
32
  #
33
33
  # For some suggestions on how to improve your specs, try:
34
34
  #
35
- # http://betterspecs.org
35
+ # https://betterspecs.org
36
36
  #
37
37
  # but do note that several items there are debatable or specific to rspec.
38
38
  #
39
39
  # For more information about expectations, see Minitest::Expectations.
40
40
  #
41
- private def describe: (untyped desc, *untyped additional_desc) ?{ () -> untyped } -> untyped
41
+ private def describe: (untyped desc, *untyped additional_desc) { (?) -> untyped } -> untyped
42
42
  end
@@ -3,6 +3,9 @@
3
3
  # Go nuts.
4
4
  #
5
5
  class Minitest::AbstractReporter
6
+ @mutex: untyped
7
+ def initialize: () -> void
8
+
6
9
  # <!--
7
10
  # rdoc-file=lib/minitest.rb
8
11
  # - start()
@@ -45,5 +48,5 @@ class Minitest::AbstractReporter
45
48
  # Did this run pass?
46
49
  #
47
50
  def passed?: () -> true
48
- include Mutex_m
51
+ def synchronize: () { (?) -> untyped } -> untyped
49
52
  end
@@ -13,4 +13,5 @@ class Minitest::Assertion < ::Exception
13
13
  def location: () -> untyped
14
14
  def result_code: () -> untyped
15
15
  def result_label: () -> "Failure"
16
+ RE: Regexp
16
17
  end