rbs 4.0.0.dev.5 → 4.0.1.dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.clang-format +1 -0
- data/.github/workflows/c-check.yml +8 -4
- data/.github/workflows/comments.yml +3 -1
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +10 -0
- data/.github/workflows/rust.yml +95 -0
- data/CHANGELOG.md +323 -0
- data/Rakefile +12 -29
- data/Steepfile +1 -0
- data/config.yml +393 -37
- data/core/array.rbs +218 -188
- data/core/basic_object.rbs +9 -8
- data/core/class.rbs +6 -5
- data/core/comparable.rbs +45 -31
- data/core/complex.rbs +52 -40
- data/core/dir.rbs +57 -45
- data/core/encoding.rbs +5 -5
- data/core/enumerable.rbs +96 -91
- data/core/enumerator.rbs +4 -3
- data/core/errno.rbs +3 -2
- data/core/errors.rbs +31 -29
- data/core/exception.rbs +12 -12
- data/core/fiber.rbs +36 -36
- data/core/file.rbs +186 -113
- data/core/file_test.rbs +2 -2
- data/core/float.rbs +41 -32
- data/core/gc.rbs +78 -70
- data/core/hash.rbs +70 -60
- data/core/integer.rbs +32 -28
- data/core/io/buffer.rbs +36 -36
- data/core/io/wait.rbs +7 -7
- data/core/io.rbs +120 -135
- data/core/kernel.rbs +189 -139
- data/core/marshal.rbs +3 -3
- data/core/match_data.rbs +14 -12
- data/core/math.rbs +69 -67
- data/core/method.rbs +6 -6
- data/core/module.rbs +146 -85
- data/core/nil_class.rbs +4 -3
- data/core/numeric.rbs +35 -32
- data/core/object.rbs +6 -8
- data/core/object_space.rbs +11 -10
- data/core/pathname.rbs +131 -81
- data/core/proc.rbs +65 -33
- data/core/process.rbs +219 -201
- data/core/ractor.rbs +15 -11
- data/core/random.rbs +4 -3
- data/core/range.rbs +52 -47
- data/core/rational.rbs +5 -5
- data/core/rbs/unnamed/argf.rbs +58 -51
- data/core/rbs/unnamed/env_class.rbs +18 -13
- data/core/rbs/unnamed/main_class.rbs +123 -0
- data/core/rbs/unnamed/random.rbs +7 -5
- data/core/regexp.rbs +236 -197
- data/core/ruby.rbs +1 -1
- data/core/ruby_vm.rbs +32 -30
- data/core/rubygems/config_file.rbs +5 -5
- data/core/rubygems/errors.rbs +1 -1
- data/core/rubygems/requirement.rbs +5 -5
- data/core/rubygems/rubygems.rbs +5 -3
- data/core/set.rbs +17 -16
- data/core/signal.rbs +2 -2
- data/core/string.rbs +311 -292
- data/core/struct.rbs +26 -25
- data/core/symbol.rbs +25 -24
- data/core/thread.rbs +40 -34
- data/core/time.rbs +47 -42
- data/core/trace_point.rbs +34 -31
- data/core/true_class.rbs +2 -2
- data/core/unbound_method.rbs +10 -10
- data/core/warning.rbs +7 -7
- data/docs/collection.md +1 -1
- data/docs/config.md +171 -0
- data/docs/inline.md +110 -4
- data/docs/syntax.md +13 -12
- data/ext/rbs_extension/ast_translation.c +489 -135
- data/ext/rbs_extension/class_constants.c +8 -0
- data/ext/rbs_extension/class_constants.h +4 -0
- data/ext/rbs_extension/legacy_location.c +28 -51
- data/ext/rbs_extension/legacy_location.h +37 -0
- data/ext/rbs_extension/main.c +12 -20
- data/include/rbs/ast.h +423 -195
- data/include/rbs/lexer.h +2 -2
- data/include/rbs/location.h +25 -44
- data/include/rbs/parser.h +2 -2
- data/include/rbs/util/rbs_constant_pool.h +0 -3
- data/include/rbs.h +8 -0
- data/lib/rbs/ast/ruby/annotations.rb +157 -4
- data/lib/rbs/ast/ruby/members.rb +374 -22
- data/lib/rbs/cli/validate.rb +5 -60
- data/lib/rbs/collection/config/lockfile_generator.rb +6 -2
- data/lib/rbs/definition_builder.rb +60 -27
- data/lib/rbs/errors.rb +0 -11
- data/lib/rbs/inline_parser.rb +1 -1
- data/lib/rbs/parser_aux.rb +20 -7
- data/lib/rbs/prototype/helpers.rb +57 -0
- data/lib/rbs/prototype/rb.rb +1 -26
- data/lib/rbs/prototype/rbi.rb +1 -20
- data/lib/rbs/test/type_check.rb +3 -0
- data/lib/rbs/types.rb +62 -52
- data/lib/rbs/unit_test/type_assertions.rb +35 -8
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +0 -1
- data/rbs.gemspec +1 -1
- data/rust/.gitignore +1 -0
- data/rust/Cargo.lock +378 -0
- data/rust/Cargo.toml +7 -0
- data/rust/ruby-rbs/Cargo.toml +22 -0
- data/rust/ruby-rbs/build.rs +764 -0
- data/rust/ruby-rbs/examples/locations.rs +60 -0
- data/rust/ruby-rbs/src/lib.rs +1 -0
- data/rust/ruby-rbs/src/node/mod.rs +742 -0
- data/rust/ruby-rbs/tests/sanity.rs +47 -0
- data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
- data/rust/ruby-rbs-sys/Cargo.toml +23 -0
- data/rust/ruby-rbs-sys/build.rs +204 -0
- data/rust/ruby-rbs-sys/src/lib.rs +50 -0
- data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
- data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
- data/rust/ruby-rbs-sys/wrapper.h +1 -0
- data/sig/ast/ruby/annotations.rbs +191 -4
- data/sig/ast/ruby/members.rbs +21 -1
- data/sig/cli/validate.rbs +1 -6
- data/sig/definition_builder.rbs +2 -0
- data/sig/errors.rbs +0 -8
- data/sig/method_types.rbs +1 -1
- data/sig/parser.rbs +17 -13
- data/sig/prototype/helpers.rbs +2 -0
- data/sig/types.rbs +10 -11
- data/sig/unit_test/spy.rbs +0 -8
- data/sig/unit_test/type_assertions.rbs +11 -0
- data/src/ast.c +339 -161
- data/src/lexstate.c +1 -1
- data/src/location.c +7 -47
- data/src/parser.c +674 -480
- data/src/util/rbs_constant_pool.c +0 -4
- data/stdlib/bigdecimal/0/big_decimal.rbs +16 -16
- data/stdlib/cgi-escape/0/escape.rbs +4 -4
- data/stdlib/coverage/0/coverage.rbs +4 -3
- data/stdlib/date/0/date.rbs +33 -28
- data/stdlib/date/0/date_time.rbs +24 -23
- data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
- data/stdlib/erb/0/erb.rbs +64 -53
- data/stdlib/etc/0/etc.rbs +55 -50
- data/stdlib/fileutils/0/fileutils.rbs +138 -125
- data/stdlib/forwardable/0/forwardable.rbs +10 -10
- data/stdlib/io-console/0/io-console.rbs +2 -2
- data/stdlib/json/0/json.rbs +135 -108
- data/stdlib/monitor/0/monitor.rbs +3 -3
- data/stdlib/net-http/0/net-http.rbs +159 -134
- data/stdlib/objspace/0/objspace.rbs +8 -7
- data/stdlib/open-uri/0/open-uri.rbs +8 -8
- data/stdlib/open3/0/open3.rbs +36 -35
- data/stdlib/openssl/0/openssl.rbs +144 -129
- data/stdlib/optparse/0/optparse.rbs +18 -14
- data/stdlib/pathname/0/pathname.rbs +2 -2
- data/stdlib/pp/0/pp.rbs +9 -8
- data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
- data/stdlib/pstore/0/pstore.rbs +35 -30
- data/stdlib/psych/0/psych.rbs +61 -8
- data/stdlib/psych/0/store.rbs +2 -4
- data/stdlib/pty/0/pty.rbs +9 -6
- data/stdlib/random-formatter/0/random-formatter.rbs +2 -2
- data/stdlib/ripper/0/ripper.rbs +20 -17
- data/stdlib/securerandom/0/securerandom.rbs +1 -1
- data/stdlib/shellwords/0/shellwords.rbs +2 -2
- data/stdlib/socket/0/addrinfo.rbs +7 -7
- data/stdlib/socket/0/basic_socket.rbs +3 -3
- data/stdlib/socket/0/ip_socket.rbs +10 -8
- data/stdlib/socket/0/socket.rbs +10 -9
- data/stdlib/socket/0/tcp_server.rbs +1 -1
- data/stdlib/socket/0/tcp_socket.rbs +1 -1
- data/stdlib/socket/0/udp_socket.rbs +1 -1
- data/stdlib/socket/0/unix_server.rbs +1 -1
- data/stdlib/stringio/0/stringio.rbs +55 -54
- data/stdlib/strscan/0/string_scanner.rbs +46 -44
- data/stdlib/tempfile/0/tempfile.rbs +24 -20
- data/stdlib/time/0/time.rbs +7 -5
- data/stdlib/tsort/0/tsort.rbs +7 -6
- data/stdlib/uri/0/common.rbs +26 -18
- data/stdlib/uri/0/file.rbs +2 -2
- data/stdlib/uri/0/generic.rbs +2 -2
- data/stdlib/uri/0/http.rbs +2 -2
- data/stdlib/uri/0/ldap.rbs +2 -2
- data/stdlib/uri/0/mailto.rbs +3 -3
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -5
- data/stdlib/zlib/0/deflate.rbs +4 -3
- data/stdlib/zlib/0/gzip_reader.rbs +4 -4
- data/stdlib/zlib/0/gzip_writer.rbs +14 -12
- data/stdlib/zlib/0/inflate.rbs +1 -1
- data/stdlib/zlib/0/need_dict.rbs +1 -1
- metadata +23 -5
- data/.github/workflows/valgrind.yml +0 -42
|
@@ -132,7 +132,7 @@ class IO
|
|
|
132
132
|
# rdoc-file=ext/io/console/console.c
|
|
133
133
|
# - io.cursor = [line, column] -> io
|
|
134
134
|
# -->
|
|
135
|
-
# Same as
|
|
135
|
+
# Same as <code>io.goto(line, column)</code>
|
|
136
136
|
#
|
|
137
137
|
# See IO#goto.
|
|
138
138
|
#
|
|
@@ -362,7 +362,7 @@ class IO
|
|
|
362
362
|
# -->
|
|
363
363
|
# Enables raw mode, and returns `io`.
|
|
364
364
|
#
|
|
365
|
-
# If the terminal mode needs to be back, use
|
|
365
|
+
# If the terminal mode needs to be back, use <code>io.raw { ... }</code>.
|
|
366
366
|
#
|
|
367
367
|
# See IO#raw for details on the parameters.
|
|
368
368
|
#
|
data/stdlib/json/0/json.rbs
CHANGED
|
@@ -79,8 +79,8 @@ end
|
|
|
79
79
|
# JSON is a lightweight data-interchange format.
|
|
80
80
|
#
|
|
81
81
|
# A JSON value is one of the following:
|
|
82
|
-
# * Double-quoted text:
|
|
83
|
-
# * Number: `1`,
|
|
82
|
+
# * Double-quoted text: <code>"foo"</code>.
|
|
83
|
+
# * Number: `1`, <code>1.0</code>, <code>2.0e2</code>.
|
|
84
84
|
# * Boolean: `true`, `false`.
|
|
85
85
|
# * Null: `null`.
|
|
86
86
|
# * Array: an ordered list of values, enclosed by square brackets:
|
|
@@ -105,8 +105,8 @@ end
|
|
|
105
105
|
# ### Parsing JSON
|
|
106
106
|
#
|
|
107
107
|
# You can parse a String containing JSON data using either of two methods:
|
|
108
|
-
# *
|
|
109
|
-
# *
|
|
108
|
+
# * <code>JSON.parse(source, opts)</code>
|
|
109
|
+
# * <code>JSON.parse!(source, opts)</code>
|
|
110
110
|
#
|
|
111
111
|
# where
|
|
112
112
|
# * `source` is a Ruby object.
|
|
@@ -292,12 +292,12 @@ end
|
|
|
292
292
|
# ---
|
|
293
293
|
#
|
|
294
294
|
# Option `create_additions` (boolean) specifies whether to use JSON additions in
|
|
295
|
-
# parsing. See [
|
|
295
|
+
# parsing. See [JSON Additions](#module-JSON-label-JSON+Additions).
|
|
296
296
|
#
|
|
297
297
|
# ### Generating JSON
|
|
298
298
|
#
|
|
299
299
|
# To generate a Ruby String containing JSON data, use method
|
|
300
|
-
#
|
|
300
|
+
# <code>JSON.generate(source, opts)</code>, where
|
|
301
301
|
# * `source` is a Ruby object.
|
|
302
302
|
# * `opts` is a Hash object containing options that control both input allowed
|
|
303
303
|
# and output formatting.
|
|
@@ -361,7 +361,7 @@ end
|
|
|
361
361
|
# ###### Input Options
|
|
362
362
|
#
|
|
363
363
|
# Option `allow_nan` (boolean) specifies whether `NaN`, `Infinity`, and
|
|
364
|
-
#
|
|
364
|
+
# <code>-Infinity</code> may be generated; defaults to `false`.
|
|
365
365
|
#
|
|
366
366
|
# With the default, `false`:
|
|
367
367
|
# # Raises JSON::GeneratorError (920: NaN not allowed in JSON):
|
|
@@ -409,9 +409,9 @@ end
|
|
|
409
409
|
#
|
|
410
410
|
# ###### Escaping Options
|
|
411
411
|
#
|
|
412
|
-
# Options `script_safe` (boolean) specifies wether
|
|
413
|
-
#
|
|
414
|
-
# script tags.
|
|
412
|
+
# Options `script_safe` (boolean) specifies wether <code>'\u2028'</code>,
|
|
413
|
+
# <code>'\u2029'</code> and <code>'/'</code> should be escaped as to make the
|
|
414
|
+
# JSON object safe to interpolate in script tags.
|
|
415
415
|
#
|
|
416
416
|
# Options `ascii_only` (boolean) specifies wether all characters outside the
|
|
417
417
|
# ASCII range should be escaped.
|
|
@@ -425,19 +425,21 @@ end
|
|
|
425
425
|
# format, using whitespace. See also JSON.pretty_generate.
|
|
426
426
|
#
|
|
427
427
|
# * Option `array_nl` (String) specifies a string (usually a newline) to be
|
|
428
|
-
# inserted after each JSON array; defaults to the empty String,
|
|
428
|
+
# inserted after each JSON array; defaults to the empty String,
|
|
429
|
+
# <code>''</code>.
|
|
429
430
|
# * Option `object_nl` (String) specifies a string (usually a newline) to be
|
|
430
|
-
# inserted after each JSON object; defaults to the empty String,
|
|
431
|
+
# inserted after each JSON object; defaults to the empty String,
|
|
432
|
+
# <code>''</code>.
|
|
431
433
|
# * Option `indent` (String) specifies the string (usually spaces) to be used
|
|
432
|
-
# for indentation; defaults to the empty String,
|
|
433
|
-
# String,
|
|
434
|
-
# specify newlines.
|
|
434
|
+
# for indentation; defaults to the empty String, <code>''</code>; defaults
|
|
435
|
+
# to the empty String, <code>''</code>; has no effect unless options
|
|
436
|
+
# `array_nl` or `object_nl` specify newlines.
|
|
435
437
|
# * Option `space` (String) specifies a string (usually a space) to be
|
|
436
438
|
# inserted after the colon in each JSON object's pair; defaults to the empty
|
|
437
|
-
# String,
|
|
439
|
+
# String, <code>''</code>.
|
|
438
440
|
# * Option `space_before` (String) specifies a string (usually a space) to be
|
|
439
441
|
# inserted before the colon in each JSON object's pair; defaults to the
|
|
440
|
-
# empty String,
|
|
442
|
+
# empty String, <code>''</code>.
|
|
441
443
|
#
|
|
442
444
|
# In this example, `obj` is used first to generate the shortest JSON data (no
|
|
443
445
|
# whitespace), then again with all formatting options specified:
|
|
@@ -519,26 +521,26 @@ end
|
|
|
519
521
|
# With addition: 0..2 (Range)
|
|
520
522
|
#
|
|
521
523
|
# The JSON module includes additions for certain classes. You can also craft
|
|
522
|
-
# custom additions. See [Custom
|
|
524
|
+
# custom additions. See [Custom JSON
|
|
523
525
|
# Additions](#module-JSON-label-Custom+JSON+Additions).
|
|
524
526
|
#
|
|
525
527
|
# ### Built-in Additions
|
|
526
528
|
#
|
|
527
529
|
# The JSON module includes additions for certain classes. To use an addition,
|
|
528
530
|
# `require` its source:
|
|
529
|
-
# * BigDecimal:
|
|
530
|
-
# * Complex:
|
|
531
|
-
# * Date:
|
|
532
|
-
# * DateTime:
|
|
533
|
-
# * Exception:
|
|
534
|
-
# * OpenStruct:
|
|
535
|
-
# * Range:
|
|
536
|
-
# * Rational:
|
|
537
|
-
# * Regexp:
|
|
538
|
-
# * Set:
|
|
539
|
-
# * Struct:
|
|
540
|
-
# * Symbol:
|
|
541
|
-
# * Time:
|
|
531
|
+
# * BigDecimal: <code>require 'json/add/bigdecimal'</code>
|
|
532
|
+
# * Complex: <code>require 'json/add/complex'</code>
|
|
533
|
+
# * Date: <code>require 'json/add/date'</code>
|
|
534
|
+
# * DateTime: <code>require 'json/add/date_time'</code>
|
|
535
|
+
# * Exception: <code>require 'json/add/exception'</code>
|
|
536
|
+
# * OpenStruct: <code>require 'json/add/ostruct'</code>
|
|
537
|
+
# * Range: <code>require 'json/add/range'</code>
|
|
538
|
+
# * Rational: <code>require 'json/add/rational'</code>
|
|
539
|
+
# * Regexp: <code>require 'json/add/regexp'</code>
|
|
540
|
+
# * Set: <code>require 'json/add/set'</code>
|
|
541
|
+
# * Struct: <code>require 'json/add/struct'</code>
|
|
542
|
+
# * Symbol: <code>require 'json/add/symbol'</code>
|
|
543
|
+
# * Time: <code>require 'json/add/time'</code>
|
|
542
544
|
#
|
|
543
545
|
# To reduce punctuation clutter, the examples below show the generated JSON via
|
|
544
546
|
# `puts`, rather than the usual `inspect`,
|
|
@@ -857,7 +859,7 @@ module JSON
|
|
|
857
859
|
# json = JSON.generate(obj)
|
|
858
860
|
# json # => '{"foo":0,"bar":"s","baz":"bat"}'
|
|
859
861
|
#
|
|
860
|
-
# For examples of generating from other Ruby objects, see [Generating
|
|
862
|
+
# For examples of generating from other Ruby objects, see [Generating JSON from
|
|
861
863
|
# Other Objects](#module-JSON-label-Generating+JSON+from+Other+Objects).
|
|
862
864
|
#
|
|
863
865
|
# ---
|
|
@@ -895,15 +897,17 @@ module JSON
|
|
|
895
897
|
# in JSON version 3.0, `load` will have `create_additions` disabled by default.
|
|
896
898
|
#
|
|
897
899
|
# * Argument `source` must be, or be convertible to, a String:
|
|
898
|
-
# * If `source` responds to instance method `to_str`,
|
|
899
|
-
# becomes the source.
|
|
900
|
-
# * If `source` responds to instance method `to_io`,
|
|
901
|
-
# becomes the source.
|
|
902
|
-
# * If `source` responds to instance method `read`,
|
|
903
|
-
# the source.
|
|
904
|
-
# * If both of the following are true, source becomes the String
|
|
900
|
+
# * If `source` responds to instance method `to_str`,
|
|
901
|
+
# <code>source.to_str</code> becomes the source.
|
|
902
|
+
# * If `source` responds to instance method `to_io`,
|
|
903
|
+
# <code>source.to_io.read</code> becomes the source.
|
|
904
|
+
# * If `source` responds to instance method `read`,
|
|
905
|
+
# <code>source.read</code> becomes the source.
|
|
906
|
+
# * If both of the following are true, source becomes the String
|
|
907
|
+
# <code>'null'</code>:
|
|
905
908
|
# * Option `allow_blank` specifies a truthy value.
|
|
906
|
-
# * The source, as defined above, is `nil` or the empty String
|
|
909
|
+
# * The source, as defined above, is `nil` or the empty String
|
|
910
|
+
# <code>''</code>.
|
|
907
911
|
# * Otherwise, `source` remains the source.
|
|
908
912
|
# * Argument `proc`, if given, must be a Proc that accepts one argument. It
|
|
909
913
|
# will be called recursively with each result (depth-first order). See
|
|
@@ -915,7 +919,7 @@ module JSON
|
|
|
915
919
|
# ---
|
|
916
920
|
#
|
|
917
921
|
# When no `proc` is given, modifies `source` as above and returns the result of
|
|
918
|
-
#
|
|
922
|
+
# <code>parse(source, opts)</code>; see #parse.
|
|
919
923
|
#
|
|
920
924
|
# Source for following examples:
|
|
921
925
|
# source = <<~JSON
|
|
@@ -950,8 +954,8 @@ module JSON
|
|
|
950
954
|
#
|
|
951
955
|
# When `proc` is given:
|
|
952
956
|
# * Modifies `source` as above.
|
|
953
|
-
# * Gets the `result` from calling
|
|
954
|
-
# * Recursively calls
|
|
957
|
+
# * Gets the `result` from calling <code>parse(source, opts)</code>.
|
|
958
|
+
# * Recursively calls <code>proc(result)</code>.
|
|
955
959
|
# * Returns the final result.
|
|
956
960
|
#
|
|
957
961
|
# Example:
|
|
@@ -1083,7 +1087,7 @@ module JSON
|
|
|
1083
1087
|
# ruby.class # => Hash
|
|
1084
1088
|
#
|
|
1085
1089
|
# For examples of parsing for all JSON data types, see [Parsing
|
|
1086
|
-
#
|
|
1090
|
+
# JSON](#module-JSON-label-Parsing+JSON).
|
|
1087
1091
|
#
|
|
1088
1092
|
# Parses nested JSON objects:
|
|
1089
1093
|
# source = <<~JSON
|
|
@@ -1326,19 +1330,20 @@ class BigDecimal
|
|
|
1326
1330
|
# rdoc-file=ext/json/lib/json/add/bigdecimal.rb
|
|
1327
1331
|
# - as_json(*)
|
|
1328
1332
|
# -->
|
|
1329
|
-
# Methods
|
|
1330
|
-
# serialize and deserialize a
|
|
1331
|
-
# [Marshal](rdoc-ref:Marshal).
|
|
1333
|
+
# Methods <code>BigDecimal#as_json</code> and
|
|
1334
|
+
# <code>BigDecimal.json_create</code> may be used to serialize and deserialize a
|
|
1335
|
+
# BigDecimal object; see [Marshal](rdoc-ref:Marshal).
|
|
1332
1336
|
#
|
|
1333
|
-
# Method
|
|
1334
|
-
# representing `self`:
|
|
1337
|
+
# Method <code>BigDecimal#as_json</code> serializes `self`, returning a
|
|
1338
|
+
# 2-element hash representing `self`:
|
|
1335
1339
|
#
|
|
1336
1340
|
# require 'json/add/bigdecimal'
|
|
1337
1341
|
# x = BigDecimal(2).as_json # => {"json_class"=>"BigDecimal", "b"=>"27:0.2e1"}
|
|
1338
1342
|
# y = BigDecimal(2.0, 4).as_json # => {"json_class"=>"BigDecimal", "b"=>"36:0.2e1"}
|
|
1339
1343
|
# z = BigDecimal(Complex(2, 0)).as_json # => {"json_class"=>"BigDecimal", "b"=>"27:0.2e1"}
|
|
1340
1344
|
#
|
|
1341
|
-
# Method
|
|
1345
|
+
# Method <code>JSON.create</code> deserializes such a hash, returning a
|
|
1346
|
+
# BigDecimal object:
|
|
1342
1347
|
#
|
|
1343
1348
|
# BigDecimal.json_create(x) # => 0.2e1
|
|
1344
1349
|
# BigDecimal.json_create(y) # => 0.2e1
|
|
@@ -1380,17 +1385,19 @@ class Complex
|
|
|
1380
1385
|
# rdoc-file=ext/json/lib/json/add/complex.rb
|
|
1381
1386
|
# - as_json(*)
|
|
1382
1387
|
# -->
|
|
1383
|
-
# Methods
|
|
1384
|
-
# and deserialize a Complex object; see
|
|
1388
|
+
# Methods <code>Complex#as_json</code> and <code>Complex.json_create</code> may
|
|
1389
|
+
# be used to serialize and deserialize a Complex object; see
|
|
1390
|
+
# [Marshal](rdoc-ref:Marshal).
|
|
1385
1391
|
#
|
|
1386
|
-
# Method
|
|
1387
|
-
# representing `self`:
|
|
1392
|
+
# Method <code>Complex#as_json</code> serializes `self`, returning a 2-element
|
|
1393
|
+
# hash representing `self`:
|
|
1388
1394
|
#
|
|
1389
1395
|
# require 'json/add/complex'
|
|
1390
1396
|
# x = Complex(2).as_json # => {"json_class"=>"Complex", "r"=>2, "i"=>0}
|
|
1391
1397
|
# y = Complex(2.0, 4).as_json # => {"json_class"=>"Complex", "r"=>2.0, "i"=>4}
|
|
1392
1398
|
#
|
|
1393
|
-
# Method
|
|
1399
|
+
# Method <code>JSON.create</code> deserializes such a hash, returning a Complex
|
|
1400
|
+
# object:
|
|
1394
1401
|
#
|
|
1395
1402
|
# Complex.json_create(x) # => (2+0i)
|
|
1396
1403
|
# Complex.json_create(y) # => (2.0+4i)
|
|
@@ -1429,17 +1436,19 @@ class Date
|
|
|
1429
1436
|
# rdoc-file=ext/json/lib/json/add/date.rb
|
|
1430
1437
|
# - as_json(*)
|
|
1431
1438
|
# -->
|
|
1432
|
-
# Methods
|
|
1433
|
-
# deserialize a Date object; see
|
|
1439
|
+
# Methods <code>Date#as_json</code> and <code>Date.json_create</code> may be
|
|
1440
|
+
# used to serialize and deserialize a Date object; see
|
|
1441
|
+
# [Marshal](rdoc-ref:Marshal).
|
|
1434
1442
|
#
|
|
1435
|
-
# Method
|
|
1443
|
+
# Method <code>Date#as_json</code> serializes `self`, returning a 2-element hash
|
|
1436
1444
|
# representing `self`:
|
|
1437
1445
|
#
|
|
1438
1446
|
# require 'json/add/date'
|
|
1439
1447
|
# x = Date.today.as_json
|
|
1440
1448
|
# # => {"json_class"=>"Date", "y"=>2023, "m"=>11, "d"=>21, "sg"=>2299161.0}
|
|
1441
1449
|
#
|
|
1442
|
-
# Method
|
|
1450
|
+
# Method <code>JSON.create</code> deserializes such a hash, returning a Date
|
|
1451
|
+
# object:
|
|
1443
1452
|
#
|
|
1444
1453
|
# Date.json_create(x)
|
|
1445
1454
|
# # => #<Date: 2023-11-21 ((2460270j,0s,0n),+0s,2299161j)>
|
|
@@ -1476,17 +1485,19 @@ class DateTime
|
|
|
1476
1485
|
# rdoc-file=ext/json/lib/json/add/date_time.rb
|
|
1477
1486
|
# - as_json(*)
|
|
1478
1487
|
# -->
|
|
1479
|
-
# Methods
|
|
1480
|
-
# and deserialize a DateTime object; see
|
|
1488
|
+
# Methods <code>DateTime#as_json</code> and <code>DateTime.json_create</code>
|
|
1489
|
+
# may be used to serialize and deserialize a DateTime object; see
|
|
1490
|
+
# [Marshal](rdoc-ref:Marshal).
|
|
1481
1491
|
#
|
|
1482
|
-
# Method
|
|
1483
|
-
# representing `self`:
|
|
1492
|
+
# Method <code>DateTime#as_json</code> serializes `self`, returning a 2-element
|
|
1493
|
+
# hash representing `self`:
|
|
1484
1494
|
#
|
|
1485
1495
|
# require 'json/add/datetime'
|
|
1486
1496
|
# x = DateTime.now.as_json
|
|
1487
1497
|
# # => {"json_class"=>"DateTime", "y"=>2023, "m"=>11, "d"=>21, "sg"=>2299161.0}
|
|
1488
1498
|
#
|
|
1489
|
-
# Method
|
|
1499
|
+
# Method <code>JSON.create</code> deserializes such a hash, returning a DateTime
|
|
1500
|
+
# object:
|
|
1490
1501
|
#
|
|
1491
1502
|
# DateTime.json_create(x) # BUG? Raises Date::Error "invalid date"
|
|
1492
1503
|
#
|
|
@@ -1522,16 +1533,18 @@ class Exception
|
|
|
1522
1533
|
# rdoc-file=ext/json/lib/json/add/exception.rb
|
|
1523
1534
|
# - as_json(*)
|
|
1524
1535
|
# -->
|
|
1525
|
-
# Methods
|
|
1526
|
-
# serialize and deserialize a Exception object; see
|
|
1536
|
+
# Methods <code>Exception#as_json</code> and <code>Exception.json_create</code>
|
|
1537
|
+
# may be used to serialize and deserialize a Exception object; see
|
|
1538
|
+
# [Marshal](rdoc-ref:Marshal).
|
|
1527
1539
|
#
|
|
1528
|
-
# Method
|
|
1529
|
-
# representing `self`:
|
|
1540
|
+
# Method <code>Exception#as_json</code> serializes `self`, returning a 2-element
|
|
1541
|
+
# hash representing `self`:
|
|
1530
1542
|
#
|
|
1531
1543
|
# require 'json/add/exception'
|
|
1532
1544
|
# x = Exception.new('Foo').as_json # => {"json_class"=>"Exception", "m"=>"Foo", "b"=>nil}
|
|
1533
1545
|
#
|
|
1534
|
-
# Method
|
|
1546
|
+
# Method <code>JSON.create</code> deserializes such a hash, returning a
|
|
1547
|
+
# Exception object:
|
|
1535
1548
|
#
|
|
1536
1549
|
# Exception.json_create(x) # => #<Exception: Foo>
|
|
1537
1550
|
#
|
|
@@ -1567,18 +1580,19 @@ class OpenStruct
|
|
|
1567
1580
|
# rdoc-file=ext/json/lib/json/add/ostruct.rb
|
|
1568
1581
|
# - as_json(*)
|
|
1569
1582
|
# -->
|
|
1570
|
-
# Methods
|
|
1571
|
-
# serialize and deserialize a
|
|
1572
|
-
# [Marshal](rdoc-ref:Marshal).
|
|
1583
|
+
# Methods <code>OpenStruct#as_json</code> and
|
|
1584
|
+
# <code>OpenStruct.json_create</code> may be used to serialize and deserialize a
|
|
1585
|
+
# OpenStruct object; see [Marshal](rdoc-ref:Marshal).
|
|
1573
1586
|
#
|
|
1574
|
-
# Method
|
|
1575
|
-
# representing `self`:
|
|
1587
|
+
# Method <code>OpenStruct#as_json</code> serializes `self`, returning a
|
|
1588
|
+
# 2-element hash representing `self`:
|
|
1576
1589
|
#
|
|
1577
1590
|
# require 'json/add/ostruct'
|
|
1578
1591
|
# x = OpenStruct.new('name' => 'Rowdy', :age => nil).as_json
|
|
1579
1592
|
# # => {"json_class"=>"OpenStruct", "t"=>{:name=>'Rowdy', :age=>nil}}
|
|
1580
1593
|
#
|
|
1581
|
-
# Method
|
|
1594
|
+
# Method <code>JSON.create</code> deserializes such a hash, returning a
|
|
1595
|
+
# OpenStruct object:
|
|
1582
1596
|
#
|
|
1583
1597
|
# OpenStruct.json_create(x)
|
|
1584
1598
|
# # => #<OpenStruct name='Rowdy', age=nil>
|
|
@@ -1615,18 +1629,20 @@ class Range[out Elem]
|
|
|
1615
1629
|
# rdoc-file=ext/json/lib/json/add/range.rb
|
|
1616
1630
|
# - as_json(*)
|
|
1617
1631
|
# -->
|
|
1618
|
-
# Methods
|
|
1619
|
-
# deserialize a Range object; see
|
|
1632
|
+
# Methods <code>Range#as_json</code> and <code>Range.json_create</code> may be
|
|
1633
|
+
# used to serialize and deserialize a Range object; see
|
|
1634
|
+
# [Marshal](rdoc-ref:Marshal).
|
|
1620
1635
|
#
|
|
1621
|
-
# Method
|
|
1622
|
-
# representing `self`:
|
|
1636
|
+
# Method <code>Range#as_json</code> serializes `self`, returning a 2-element
|
|
1637
|
+
# hash representing `self`:
|
|
1623
1638
|
#
|
|
1624
1639
|
# require 'json/add/range'
|
|
1625
1640
|
# x = (1..4).as_json # => {"json_class"=>"Range", "a"=>[1, 4, false]}
|
|
1626
1641
|
# y = (1...4).as_json # => {"json_class"=>"Range", "a"=>[1, 4, true]}
|
|
1627
1642
|
# z = ('a'..'d').as_json # => {"json_class"=>"Range", "a"=>["a", "d", false]}
|
|
1628
1643
|
#
|
|
1629
|
-
# Method
|
|
1644
|
+
# Method <code>JSON.create</code> deserializes such a hash, returning a Range
|
|
1645
|
+
# object:
|
|
1630
1646
|
#
|
|
1631
1647
|
# Range.json_create(x) # => 1..4
|
|
1632
1648
|
# Range.json_create(y) # => 1...4
|
|
@@ -1668,17 +1684,19 @@ class Rational
|
|
|
1668
1684
|
# rdoc-file=ext/json/lib/json/add/rational.rb
|
|
1669
1685
|
# - as_json(*)
|
|
1670
1686
|
# -->
|
|
1671
|
-
# Methods
|
|
1672
|
-
# and deserialize a Rational object; see
|
|
1687
|
+
# Methods <code>Rational#as_json</code> and <code>Rational.json_create</code>
|
|
1688
|
+
# may be used to serialize and deserialize a Rational object; see
|
|
1689
|
+
# [Marshal](rdoc-ref:Marshal).
|
|
1673
1690
|
#
|
|
1674
|
-
# Method
|
|
1675
|
-
# representing `self`:
|
|
1691
|
+
# Method <code>Rational#as_json</code> serializes `self`, returning a 2-element
|
|
1692
|
+
# hash representing `self`:
|
|
1676
1693
|
#
|
|
1677
1694
|
# require 'json/add/rational'
|
|
1678
1695
|
# x = Rational(2, 3).as_json
|
|
1679
1696
|
# # => {"json_class"=>"Rational", "n"=>2, "d"=>3}
|
|
1680
1697
|
#
|
|
1681
|
-
# Method
|
|
1698
|
+
# Method <code>JSON.create</code> deserializes such a hash, returning a Rational
|
|
1699
|
+
# object:
|
|
1682
1700
|
#
|
|
1683
1701
|
# Rational.json_create(x)
|
|
1684
1702
|
# # => (2/3)
|
|
@@ -1715,17 +1733,19 @@ class Regexp
|
|
|
1715
1733
|
# rdoc-file=ext/json/lib/json/add/regexp.rb
|
|
1716
1734
|
# - as_json(*)
|
|
1717
1735
|
# -->
|
|
1718
|
-
# Methods
|
|
1719
|
-
# deserialize a Regexp object; see
|
|
1736
|
+
# Methods <code>Regexp#as_json</code> and <code>Regexp.json_create</code> may be
|
|
1737
|
+
# used to serialize and deserialize a Regexp object; see
|
|
1738
|
+
# [Marshal](rdoc-ref:Marshal).
|
|
1720
1739
|
#
|
|
1721
|
-
# Method
|
|
1722
|
-
# representing `self`:
|
|
1740
|
+
# Method <code>Regexp#as_json</code> serializes `self`, returning a 2-element
|
|
1741
|
+
# hash representing `self`:
|
|
1723
1742
|
#
|
|
1724
1743
|
# require 'json/add/regexp'
|
|
1725
1744
|
# x = /foo/.as_json
|
|
1726
1745
|
# # => {"json_class"=>"Regexp", "o"=>0, "s"=>"foo"}
|
|
1727
1746
|
#
|
|
1728
|
-
# Method
|
|
1747
|
+
# Method <code>JSON.create</code> deserializes such a hash, returning a Regexp
|
|
1748
|
+
# object:
|
|
1729
1749
|
#
|
|
1730
1750
|
# Regexp.json_create(x) # => /foo/
|
|
1731
1751
|
#
|
|
@@ -1761,17 +1781,18 @@ class Set[unchecked out A]
|
|
|
1761
1781
|
# rdoc-file=ext/json/lib/json/add/set.rb
|
|
1762
1782
|
# - as_json(*)
|
|
1763
1783
|
# -->
|
|
1764
|
-
# Methods
|
|
1765
|
-
# deserialize a Set object; see [Marshal](rdoc-ref:Marshal).
|
|
1784
|
+
# Methods <code>Set#as_json</code> and <code>Set.json_create</code> may be used
|
|
1785
|
+
# to serialize and deserialize a Set object; see [Marshal](rdoc-ref:Marshal).
|
|
1766
1786
|
#
|
|
1767
|
-
# Method
|
|
1787
|
+
# Method <code>Set#as_json</code> serializes `self`, returning a 2-element hash
|
|
1768
1788
|
# representing `self`:
|
|
1769
1789
|
#
|
|
1770
1790
|
# require 'json/add/set'
|
|
1771
1791
|
# x = Set.new(%w/foo bar baz/).as_json
|
|
1772
1792
|
# # => {"json_class"=>"Set", "a"=>["foo", "bar", "baz"]}
|
|
1773
1793
|
#
|
|
1774
|
-
# Method
|
|
1794
|
+
# Method <code>JSON.create</code> deserializes such a hash, returning a Set
|
|
1795
|
+
# object:
|
|
1775
1796
|
#
|
|
1776
1797
|
# Set.json_create(x) # => #<Set: {"foo", "bar", "baz"}>
|
|
1777
1798
|
#
|
|
@@ -1807,18 +1828,20 @@ class Struct[Elem]
|
|
|
1807
1828
|
# rdoc-file=ext/json/lib/json/add/struct.rb
|
|
1808
1829
|
# - as_json(*)
|
|
1809
1830
|
# -->
|
|
1810
|
-
# Methods
|
|
1811
|
-
# deserialize a Struct object; see
|
|
1831
|
+
# Methods <code>Struct#as_json</code> and <code>Struct.json_create</code> may be
|
|
1832
|
+
# used to serialize and deserialize a Struct object; see
|
|
1833
|
+
# [Marshal](rdoc-ref:Marshal).
|
|
1812
1834
|
#
|
|
1813
|
-
# Method
|
|
1814
|
-
# representing `self`:
|
|
1835
|
+
# Method <code>Struct#as_json</code> serializes `self`, returning a 2-element
|
|
1836
|
+
# hash representing `self`:
|
|
1815
1837
|
#
|
|
1816
1838
|
# require 'json/add/struct'
|
|
1817
1839
|
# Customer = Struct.new('Customer', :name, :address, :zip)
|
|
1818
1840
|
# x = Struct::Customer.new.as_json
|
|
1819
1841
|
# # => {"json_class"=>"Struct::Customer", "v"=>[nil, nil, nil]}
|
|
1820
1842
|
#
|
|
1821
|
-
# Method
|
|
1843
|
+
# Method <code>JSON.create</code> deserializes such a hash, returning a Struct
|
|
1844
|
+
# object:
|
|
1822
1845
|
#
|
|
1823
1846
|
# Struct::Customer.json_create(x)
|
|
1824
1847
|
# # => #<struct Struct::Customer name=nil, address=nil, zip=nil>
|
|
@@ -1856,17 +1879,19 @@ class Symbol
|
|
|
1856
1879
|
# rdoc-file=ext/json/lib/json/add/symbol.rb
|
|
1857
1880
|
# - as_json(*)
|
|
1858
1881
|
# -->
|
|
1859
|
-
# Methods
|
|
1860
|
-
# deserialize a Symbol object; see
|
|
1882
|
+
# Methods <code>Symbol#as_json</code> and <code>Symbol.json_create</code> may be
|
|
1883
|
+
# used to serialize and deserialize a Symbol object; see
|
|
1884
|
+
# [Marshal](rdoc-ref:Marshal).
|
|
1861
1885
|
#
|
|
1862
|
-
# Method
|
|
1863
|
-
# representing `self`:
|
|
1886
|
+
# Method <code>Symbol#as_json</code> serializes `self`, returning a 2-element
|
|
1887
|
+
# hash representing `self`:
|
|
1864
1888
|
#
|
|
1865
1889
|
# require 'json/add/symbol'
|
|
1866
1890
|
# x = :foo.as_json
|
|
1867
1891
|
# # => {"json_class"=>"Symbol", "s"=>"foo"}
|
|
1868
1892
|
#
|
|
1869
|
-
# Method
|
|
1893
|
+
# Method <code>JSON.create</code> deserializes such a hash, returning a Symbol
|
|
1894
|
+
# object:
|
|
1870
1895
|
#
|
|
1871
1896
|
# Symbol.json_create(x) # => :foo
|
|
1872
1897
|
#
|
|
@@ -1902,17 +1927,19 @@ class Time
|
|
|
1902
1927
|
# rdoc-file=ext/json/lib/json/add/time.rb
|
|
1903
1928
|
# - as_json(*)
|
|
1904
1929
|
# -->
|
|
1905
|
-
# Methods
|
|
1906
|
-
# deserialize a Time object; see
|
|
1930
|
+
# Methods <code>Time#as_json</code> and <code>Time.json_create</code> may be
|
|
1931
|
+
# used to serialize and deserialize a Time object; see
|
|
1932
|
+
# [Marshal](rdoc-ref:Marshal).
|
|
1907
1933
|
#
|
|
1908
|
-
# Method
|
|
1934
|
+
# Method <code>Time#as_json</code> serializes `self`, returning a 2-element hash
|
|
1909
1935
|
# representing `self`:
|
|
1910
1936
|
#
|
|
1911
1937
|
# require 'json/add/time'
|
|
1912
1938
|
# x = Time.now.as_json
|
|
1913
1939
|
# # => {"json_class"=>"Time", "s"=>1700931656, "n"=>472846644}
|
|
1914
1940
|
#
|
|
1915
|
-
# Method
|
|
1941
|
+
# Method <code>JSON.create</code> deserializes such a hash, returning a Time
|
|
1942
|
+
# object:
|
|
1916
1943
|
#
|
|
1917
1944
|
# Time.json_create(x)
|
|
1918
1945
|
# # => 2023-11-25 11:00:56.472846644 -0600
|
|
@@ -154,9 +154,9 @@ end
|
|
|
154
154
|
# end
|
|
155
155
|
#
|
|
156
156
|
# The consumer thread waits for the producer thread to push a line to buf while
|
|
157
|
-
#
|
|
158
|
-
# pushes it into buf then calls
|
|
159
|
-
# thread of new data.
|
|
157
|
+
# <code>buf.empty?</code>. The producer thread (main thread) reads a line from
|
|
158
|
+
# ARGF and pushes it into buf then calls <code>empty_cond.signal</code> to
|
|
159
|
+
# notify the consumer thread of new data.
|
|
160
160
|
#
|
|
161
161
|
# ### Simple Class include
|
|
162
162
|
#
|