repeatable 1.2.0 → 1.2.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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +19 -23
  3. data/.ruby-version +1 -0
  4. data/.yardopts +1 -0
  5. data/CHANGELOG.md +16 -2
  6. data/Gemfile +1 -0
  7. data/Gemfile.lock +86 -73
  8. data/README.md +8 -5
  9. data/lib/repeatable/expression/date.rb +1 -0
  10. data/lib/repeatable/expression/range_in_year.rb +2 -0
  11. data/lib/repeatable/version.rb +1 -1
  12. data/rbi/repeatable.rbi +1 -1
  13. data/sorbet/rbi/gems/{ast@2.4.2.rbi → ast@2.4.3.rbi} +3 -3
  14. data/sorbet/rbi/gems/benchmark@0.4.1.rbi +619 -0
  15. data/sorbet/rbi/gems/{commander@4.6.0.rbi → commander@5.0.0.rbi} +1 -0
  16. data/sorbet/rbi/gems/{diff-lcs@1.4.4.rbi → diff-lcs@1.6.2.rbi} +135 -83
  17. data/sorbet/rbi/gems/{erubi@1.12.0.rbi → erubi@1.13.1.rbi} +25 -15
  18. data/sorbet/rbi/gems/{highline@2.0.3.rbi → highline@3.0.1.rbi} +1 -0
  19. data/sorbet/rbi/gems/{json@2.7.2.rbi → json@2.13.2.rbi} +759 -233
  20. data/sorbet/rbi/gems/{language_server-protocol@3.17.0.3.rbi → language_server-protocol@3.17.0.5.rbi} +11 -5
  21. data/sorbet/rbi/gems/logger@1.7.0.rbi +963 -0
  22. data/sorbet/rbi/gems/{method_source@1.0.0.rbi → method_source@1.1.0.rbi} +41 -9
  23. data/sorbet/rbi/gems/{parallel@1.24.0.rbi → parallel@1.27.0.rbi} +32 -21
  24. data/sorbet/rbi/gems/{parlour@8.1.0.rbi → parlour@9.1.2.rbi} +86 -68
  25. data/sorbet/rbi/gems/{parser@3.3.1.0.rbi → parser@3.3.9.0.rbi} +908 -891
  26. data/sorbet/rbi/gems/{prism@0.28.0.rbi → prism@1.4.0.rbi} +14078 -10249
  27. data/sorbet/rbi/gems/{pry@0.14.0.rbi → pry@0.15.2.rbi} +437 -244
  28. data/sorbet/rbi/gems/{racc@1.7.3.rbi → racc@1.8.1.rbi} +36 -33
  29. data/sorbet/rbi/gems/{rake@13.0.3.rbi → rake@13.3.0.rbi} +83 -76
  30. data/sorbet/rbi/gems/rbi@0.3.6.rbi +6893 -0
  31. data/sorbet/rbi/gems/rbs@3.9.5.rbi +6976 -0
  32. data/sorbet/rbi/gems/{regexp_parser@2.9.0.rbi → regexp_parser@2.11.2.rbi} +1089 -1015
  33. data/sorbet/rbi/gems/{rexml@3.2.6.rbi → rexml@3.4.3.rbi} +833 -329
  34. data/sorbet/rbi/gems/{rspec-core@3.10.1.rbi → rspec-core@3.13.5.rbi} +1014 -613
  35. data/sorbet/rbi/gems/{rspec-expectations@3.10.1.rbi → rspec-expectations@3.13.5.rbi} +897 -638
  36. data/sorbet/rbi/gems/{rspec-mocks@3.10.2.rbi → rspec-mocks@3.13.5.rbi} +547 -444
  37. data/sorbet/rbi/gems/{rspec-support@3.10.2.rbi → rspec-support@3.13.5.rbi} +337 -304
  38. data/sorbet/rbi/gems/rspec@3.13.1.rbi +83 -0
  39. data/sorbet/rbi/gems/{rubocop-ast@1.31.3.rbi → rubocop-ast@1.46.0.rbi} +1678 -958
  40. data/sorbet/rbi/gems/{rubocop-performance@1.20.2.rbi → rubocop-performance@1.25.0.rbi} +1 -0
  41. data/sorbet/rbi/gems/{rubocop@1.62.1.rbi → rubocop@1.80.2.rbi} +11243 -5431
  42. data/sorbet/rbi/gems/simplecov-html@0.13.2.rbi +225 -0
  43. data/sorbet/rbi/gems/{simplecov@0.21.2.rbi → simplecov@0.22.0.rbi} +39 -25
  44. data/sorbet/rbi/gems/simplecov_json_formatter@0.1.4.rbi +233 -2
  45. data/sorbet/rbi/gems/spoom@1.6.3.rbi +6985 -0
  46. data/sorbet/rbi/gems/{standard-performance@1.3.1.rbi → standard-performance@1.8.0.rbi} +1 -0
  47. data/sorbet/rbi/gems/{standard@1.35.1.rbi → standard@1.51.0.rbi} +181 -96
  48. data/sorbet/rbi/gems/{tapioca@0.13.3.rbi → tapioca@0.16.11.rbi} +489 -388
  49. data/sorbet/rbi/gems/{thor@1.3.1.rbi → thor@1.4.0.rbi} +94 -46
  50. data/sorbet/rbi/gems/unicode-display_width@3.2.0.rbi +132 -0
  51. data/sorbet/rbi/gems/unicode-emoji@4.1.0.rbi +251 -0
  52. data/sorbet/rbi/gems/{yard-sorbet@0.8.1.rbi → yard-sorbet@0.9.0.rbi} +36 -29
  53. data/sorbet/rbi/gems/{yard@0.9.36.rbi → yard@0.9.37.rbi} +394 -236
  54. metadata +46 -40
  55. data/sorbet/rbi/gems/rbi@0.1.13.rbi +0 -3071
  56. data/sorbet/rbi/gems/rspec@3.10.0.rbi +0 -76
  57. data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +0 -216
  58. data/sorbet/rbi/gems/spoom@1.3.2.rbi +0 -4420
  59. data/sorbet/rbi/gems/unicode-display_width@2.5.0.rbi +0 -65
  60. /data/sorbet/rbi/gems/{docile@1.4.0.rbi → docile@1.4.1.rbi} +0 -0
@@ -4,19 +4,27 @@
4
4
  # This is an autogenerated file for types exported from the `json` gem.
5
5
  # Please instead update this file by running `bin/tapioca gem json`.
6
6
 
7
- # Extends any Class to include _json_creatable?_ method.
8
- #
9
- # source://json//lib/json/common.rb#690
10
- class Class < ::Module
11
- # Returns true if this class can be used to create an instance
12
- # from a serialised JSON string. The class has to implement a class
13
- # method _json_create_ that expects a hash as first parameter. The hash
14
- # should include the required data.
15
- #
16
- # @return [Boolean]
17
- #
18
- # source://json//lib/json/common.rb#695
19
- def json_creatable?; end
7
+
8
+ class Array
9
+ include ::Enumerable
10
+ include ::JSON::Ext::Generator::GeneratorMethods::Array
11
+ end
12
+
13
+ class FalseClass
14
+ include ::JSON::Ext::Generator::GeneratorMethods::FalseClass
15
+ end
16
+
17
+ class Float < ::Numeric
18
+ include ::JSON::Ext::Generator::GeneratorMethods::Float
19
+ end
20
+
21
+ class Hash
22
+ include ::Enumerable
23
+ include ::JSON::Ext::Generator::GeneratorMethods::Hash
24
+ end
25
+
26
+ class Integer < ::Numeric
27
+ include ::JSON::Ext::Generator::GeneratorMethods::Integer
20
28
  end
21
29
 
22
30
  # = JavaScript \Object Notation (\JSON)
@@ -144,6 +152,24 @@ end
144
152
  #
145
153
  # ---
146
154
  #
155
+ # Option +allow_duplicate_key+ specifies whether duplicate keys in objects
156
+ # should be ignored or cause an error to be raised:
157
+ #
158
+ # When not specified:
159
+ # # The last value is used and a deprecation warning emitted.
160
+ # JSON.parse('{"a": 1, "a":2}') => {"a" => 2}
161
+ # # waring: detected duplicate keys in JSON object.
162
+ # # This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`
163
+ #
164
+ # When set to `+true+`
165
+ # # The last value is used.
166
+ # JSON.parse('{"a": 1, "a":2}') => {"a" => 2}
167
+ #
168
+ # When set to `+false+`, the future default:
169
+ # JSON.parse('{"a": 1, "a":2}') => duplicate key at line 1 column 1 (JSON::ParserError)
170
+ #
171
+ # ---
172
+ #
147
173
  # Option +allow_nan+ (boolean) specifies whether to allow
148
174
  # NaN, Infinity, and MinusInfinity in +source+;
149
175
  # defaults to +false+.
@@ -160,8 +186,23 @@ end
160
186
  # ruby = JSON.parse(source, {allow_nan: true})
161
187
  # ruby # => [NaN, Infinity, -Infinity]
162
188
  #
189
+ # ---
190
+ #
191
+ # Option +allow_trailing_comma+ (boolean) specifies whether to allow
192
+ # trailing commas in objects and arrays;
193
+ # defaults to +false+.
194
+ #
195
+ # With the default, +false+:
196
+ # JSON.parse('[1,]') # unexpected character: ']' at line 1 column 4 (JSON::ParserError)
197
+ #
198
+ # When enabled:
199
+ # JSON.parse('[1,]', allow_trailing_comma: true) # => [1]
200
+ #
163
201
  # ====== Output Options
164
202
  #
203
+ # Option +freeze+ (boolean) specifies whether the returned objects will be frozen;
204
+ # defaults to +false+.
205
+ #
165
206
  # Option +symbolize_names+ (boolean) specifies whether returned \Hash keys
166
207
  # should be Symbols;
167
208
  # defaults to +false+ (use Strings).
@@ -395,13 +436,13 @@ end
395
436
  # json1 = JSON.generate(ruby)
396
437
  # ruby1 = JSON.parse(json1, create_additions: true)
397
438
  # # Make a nice display.
398
- # display = <<EOT
399
- # Generated JSON:
400
- # Without addition: #{json0} (#{json0.class})
401
- # With addition: #{json1} (#{json1.class})
402
- # Parsed JSON:
403
- # Without addition: #{ruby0.inspect} (#{ruby0.class})
404
- # With addition: #{ruby1.inspect} (#{ruby1.class})
439
+ # display = <<~EOT
440
+ # Generated JSON:
441
+ # Without addition: #{json0} (#{json0.class})
442
+ # With addition: #{json1} (#{json1.class})
443
+ # Parsed JSON:
444
+ # Without addition: #{ruby0.inspect} (#{ruby0.class})
445
+ # With addition: #{ruby1.inspect} (#{ruby1.class})
405
446
  # EOT
406
447
  # puts display
407
448
  #
@@ -579,13 +620,13 @@ end
579
620
  # json1 = JSON.generate(foo1)
580
621
  # obj1 = JSON.parse(json1, create_additions: true)
581
622
  # # Make a nice display.
582
- # display = <<EOT
583
- # Generated JSON:
584
- # Without custom addition: #{json0} (#{json0.class})
585
- # With custom addition: #{json1} (#{json1.class})
586
- # Parsed JSON:
587
- # Without custom addition: #{obj0.inspect} (#{obj0.class})
588
- # With custom addition: #{obj1.inspect} (#{obj1.class})
623
+ # display = <<~EOT
624
+ # Generated JSON:
625
+ # Without custom addition: #{json0} (#{json0.class})
626
+ # With custom addition: #{json1} (#{json1.class})
627
+ # Parsed JSON:
628
+ # Without custom addition: #{obj0.inspect} (#{obj0.class})
629
+ # With custom addition: #{obj1.inspect} (#{obj1.class})
589
630
  # EOT
590
631
  # puts display
591
632
  #
@@ -598,7 +639,7 @@ end
598
639
  # Without custom addition: "#<Foo:0x0000000006534e80>" (String)
599
640
  # With custom addition: #<Foo:0x0000000006473bb8 @bar=0, @baz=1> (Foo)
600
641
  #
601
- # source://json//lib/json/version.rb#2
642
+ # source://json//lib/json/version.rb#3
602
643
  module JSON
603
644
  private
604
645
 
@@ -630,7 +671,7 @@ module JSON
630
671
  # Output:
631
672
  # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
632
673
  #
633
- # source://json//lib/json/common.rb#615
674
+ # source://json//lib/json/common.rb#893
634
675
  def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
635
676
 
636
677
  # :call-seq:
@@ -647,14 +688,11 @@ module JSON
647
688
  # # Raises SystemStackError (stack level too deep):
648
689
  # JSON.fast_generate(a)
649
690
  #
650
- # source://json//lib/json/common.rb#329
691
+ # source://json//lib/json/common.rb#446
651
692
  def fast_generate(obj, opts = T.unsafe(nil)); end
652
693
 
653
- # :stopdoc:
654
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
655
- #
656
- # source://json//lib/json/common.rb#329
657
- def fast_unparse(obj, opts = T.unsafe(nil)); end
694
+ # source://json//lib/json/common.rb#938
695
+ def fast_unparse(*_arg0, **_arg1, &_arg2); end
658
696
 
659
697
  # :call-seq:
660
698
  # JSON.generate(obj, opts = nil) -> new_string
@@ -692,7 +730,7 @@ module JSON
692
730
  # # Raises JSON::NestingError (nesting of 100 is too deep):
693
731
  # JSON.generate(a)
694
732
  #
695
- # source://json//lib/json/common.rb#300
733
+ # source://json//lib/json/common.rb#425
696
734
  def generate(obj, opts = T.unsafe(nil)); end
697
735
 
698
736
  # :call-seq:
@@ -700,6 +738,16 @@ module JSON
700
738
  #
701
739
  # Returns the Ruby objects created by parsing the given +source+.
702
740
  #
741
+ # BEWARE: This method is meant to serialise data from trusted user input,
742
+ # like from your own database server or clients under your control, it could
743
+ # be dangerous to allow untrusted users to pass JSON sources into it.
744
+ # If you must use it, use JSON.unsafe_load instead to make it clear.
745
+ #
746
+ # Since JSON version 2.8.0, `load` emits a deprecation warning when a
747
+ # non native type is deserialized, without `create_additions` being explicitly
748
+ # enabled, and in JSON version 3.0, `load` will have `create_additions` disabled
749
+ # by default.
750
+ #
703
751
  # - Argument +source+ must be, or be convertible to, a \String:
704
752
  # - If +source+ responds to instance method +to_str+,
705
753
  # <tt>source.to_str</tt> becomes the source.
@@ -714,9 +762,6 @@ module JSON
714
762
  # - Argument +proc+, if given, must be a \Proc that accepts one argument.
715
763
  # It will be called recursively with each result (depth-first order).
716
764
  # See details below.
717
- # BEWARE: This method is meant to serialise data from trusted user input,
718
- # like from your own database server or clients under your control, it could
719
- # be dangerous to allow untrusted users to pass JSON sources into it.
720
765
  # - Argument +opts+, if given, contains a \Hash of options for the parsing.
721
766
  # See {Parsing Options}[#module-JSON-label-Parsing+Options].
722
767
  # The default options can be changed via method JSON.load_default_options=.
@@ -727,17 +772,17 @@ module JSON
727
772
  # <tt>parse(source, opts)</tt>; see #parse.
728
773
  #
729
774
  # Source for following examples:
730
- # source = <<-EOT
731
- # {
732
- # "name": "Dave",
733
- # "age" :40,
734
- # "hats": [
735
- # "Cattleman's",
736
- # "Panama",
737
- # "Tophat"
738
- # ]
739
- # }
740
- # EOT
775
+ # source = <<~JSON
776
+ # {
777
+ # "name": "Dave",
778
+ # "age" :40,
779
+ # "hats": [
780
+ # "Cattleman's",
781
+ # "Panama",
782
+ # "Tophat"
783
+ # ]
784
+ # }
785
+ # JSON
741
786
  #
742
787
  # Load a \String:
743
788
  # ruby = JSON.load(source)
@@ -823,7 +868,7 @@ module JSON
823
868
  # #<Admin:0x00000000064c41f8
824
869
  # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
825
870
  #
826
- # source://json//lib/json/common.rb#541
871
+ # source://json//lib/json/common.rb#827
827
872
  def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
828
873
 
829
874
  # :call-seq:
@@ -834,7 +879,7 @@ module JSON
834
879
  #
835
880
  # See method #parse.
836
881
  #
837
- # source://json//lib/json/common.rb#249
882
+ # source://json//lib/json/common.rb#374
838
883
  def load_file(filespec, opts = T.unsafe(nil)); end
839
884
 
840
885
  # :call-seq:
@@ -845,12 +890,9 @@ module JSON
845
890
  #
846
891
  # See method #parse!
847
892
  #
848
- # source://json//lib/json/common.rb#260
893
+ # source://json//lib/json/common.rb#385
849
894
  def load_file!(filespec, opts = T.unsafe(nil)); end
850
895
 
851
- # source://json//lib/json/common.rb#643
852
- def merge_dump_options(opts, strict: T.unsafe(nil)); end
853
-
854
896
  # :call-seq:
855
897
  # JSON.parse(source, opts) -> object
856
898
  #
@@ -879,17 +921,17 @@ module JSON
879
921
  # {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
880
922
  #
881
923
  # Parses nested JSON objects:
882
- # source = <<-EOT
883
- # {
884
- # "name": "Dave",
885
- # "age" :40,
886
- # "hats": [
887
- # "Cattleman's",
888
- # "Panama",
889
- # "Tophat"
890
- # ]
891
- # }
892
- # EOT
924
+ # source = <<~JSON
925
+ # {
926
+ # "name": "Dave",
927
+ # "age" :40,
928
+ # "hats": [
929
+ # "Cattleman's",
930
+ # "Panama",
931
+ # "Tophat"
932
+ # ]
933
+ # }
934
+ # JSON
893
935
  # ruby = JSON.parse(source)
894
936
  # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
895
937
  #
@@ -899,7 +941,7 @@ module JSON
899
941
  # # Raises JSON::ParserError (783: unexpected token at ''):
900
942
  # JSON.parse('')
901
943
  #
902
- # source://json//lib/json/common.rb#219
944
+ # source://json//lib/json/common.rb#337
903
945
  def parse(source, opts = T.unsafe(nil)); end
904
946
 
905
947
  # :call-seq:
@@ -914,7 +956,7 @@ module JSON
914
956
  # which disables checking for nesting depth.
915
957
  # - Option +allow_nan+, if not provided, defaults to +true+.
916
958
  #
917
- # source://json//lib/json/common.rb#234
959
+ # source://json//lib/json/common.rb#359
918
960
  def parse!(source, opts = T.unsafe(nil)); end
919
961
 
920
962
  # :call-seq:
@@ -947,29 +989,153 @@ module JSON
947
989
  # }
948
990
  # }
949
991
  #
950
- # source://json//lib/json/common.rb#374
992
+ # source://json//lib/json/common.rb#493
951
993
  def pretty_generate(obj, opts = T.unsafe(nil)); end
952
994
 
995
+ # source://json//lib/json/common.rb#948
996
+ def pretty_unparse(*_arg0, **_arg1, &_arg2); end
997
+
998
+ # source://json//lib/json/common.rb#958
999
+ def restore(*_arg0, **_arg1, &_arg2); end
1000
+
953
1001
  # :stopdoc:
954
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
1002
+ # All these were meant to be deprecated circa 2009, but were just set as undocumented
1003
+ # so usage still exist in the wild.
955
1004
  #
956
- # source://json//lib/json/common.rb#374
957
- def pretty_unparse(obj, opts = T.unsafe(nil)); end
1005
+ # source://json//lib/json/common.rb#928
1006
+ def unparse(*_arg0, **_arg1, &_arg2); end
958
1007
 
959
- # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
1008
+ # :call-seq:
1009
+ # JSON.unsafe_load(source, proc = nil, options = {}) -> object
960
1010
  #
961
- # source://json//lib/json/common.rb#559
962
- def recurse_proc(result, &proc); end
963
-
964
- # source://json//lib/json/common.rb#541
965
- def restore(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
966
-
967
- # :stopdoc:
968
- # I want to deprecate these later, so I'll first be silent about them, and
969
- # later delete them.
1011
+ # Returns the Ruby objects created by parsing the given +source+.
970
1012
  #
971
- # source://json//lib/json/common.rb#300
972
- def unparse(obj, opts = T.unsafe(nil)); end
1013
+ # BEWARE: This method is meant to serialise data from trusted user input,
1014
+ # like from your own database server or clients under your control, it could
1015
+ # be dangerous to allow untrusted users to pass JSON sources into it.
1016
+ #
1017
+ # - Argument +source+ must be, or be convertible to, a \String:
1018
+ # - If +source+ responds to instance method +to_str+,
1019
+ # <tt>source.to_str</tt> becomes the source.
1020
+ # - If +source+ responds to instance method +to_io+,
1021
+ # <tt>source.to_io.read</tt> becomes the source.
1022
+ # - If +source+ responds to instance method +read+,
1023
+ # <tt>source.read</tt> becomes the source.
1024
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
1025
+ # - Option +allow_blank+ specifies a truthy value.
1026
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
1027
+ # - Otherwise, +source+ remains the source.
1028
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
1029
+ # It will be called recursively with each result (depth-first order).
1030
+ # See details below.
1031
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
1032
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1033
+ # The default options can be changed via method JSON.unsafe_load_default_options=.
1034
+ #
1035
+ # ---
1036
+ #
1037
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
1038
+ # <tt>parse(source, opts)</tt>; see #parse.
1039
+ #
1040
+ # Source for following examples:
1041
+ # source = <<~JSON
1042
+ # {
1043
+ # "name": "Dave",
1044
+ # "age" :40,
1045
+ # "hats": [
1046
+ # "Cattleman's",
1047
+ # "Panama",
1048
+ # "Tophat"
1049
+ # ]
1050
+ # }
1051
+ # JSON
1052
+ #
1053
+ # Load a \String:
1054
+ # ruby = JSON.unsafe_load(source)
1055
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1056
+ #
1057
+ # Load an \IO object:
1058
+ # require 'stringio'
1059
+ # object = JSON.unsafe_load(StringIO.new(source))
1060
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1061
+ #
1062
+ # Load a \File object:
1063
+ # path = 't.json'
1064
+ # File.write(path, source)
1065
+ # File.open(path) do |file|
1066
+ # JSON.unsafe_load(file)
1067
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1068
+ #
1069
+ # ---
1070
+ #
1071
+ # When +proc+ is given:
1072
+ # - Modifies +source+ as above.
1073
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
1074
+ # - Recursively calls <tt>proc(result)</tt>.
1075
+ # - Returns the final result.
1076
+ #
1077
+ # Example:
1078
+ # require 'json'
1079
+ #
1080
+ # # Some classes for the example.
1081
+ # class Base
1082
+ # def initialize(attributes)
1083
+ # @attributes = attributes
1084
+ # end
1085
+ # end
1086
+ # class User < Base; end
1087
+ # class Account < Base; end
1088
+ # class Admin < Base; end
1089
+ # # The JSON source.
1090
+ # json = <<-EOF
1091
+ # {
1092
+ # "users": [
1093
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
1094
+ # {"type": "User", "username": "john", "email": "john@example.com"}
1095
+ # ],
1096
+ # "accounts": [
1097
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
1098
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
1099
+ # ],
1100
+ # "admins": {"type": "Admin", "password": "0wn3d"}
1101
+ # }
1102
+ # EOF
1103
+ # # Deserializer method.
1104
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
1105
+ # type = obj.is_a?(Hash) && obj["type"]
1106
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
1107
+ # end
1108
+ # # Call to JSON.unsafe_load
1109
+ # ruby = JSON.unsafe_load(json, proc {|obj|
1110
+ # case obj
1111
+ # when Hash
1112
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
1113
+ # when Array
1114
+ # obj.map! {|v| deserialize_obj v }
1115
+ # end
1116
+ # })
1117
+ # pp ruby
1118
+ # Output:
1119
+ # {"users"=>
1120
+ # [#<User:0x00000000064c4c98
1121
+ # @attributes=
1122
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
1123
+ # #<User:0x00000000064c4bd0
1124
+ # @attributes=
1125
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
1126
+ # "accounts"=>
1127
+ # [{"account"=>
1128
+ # #<Account:0x00000000064c4928
1129
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
1130
+ # {"account"=>
1131
+ # #<Account:0x00000000064c4680
1132
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
1133
+ # "admins"=>
1134
+ # #<Admin:0x00000000064c41f8
1135
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
1136
+ #
1137
+ # source://json//lib/json/common.rb#667
1138
+ def unsafe_load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
973
1139
 
974
1140
  class << self
975
1141
  # :call-seq:
@@ -984,36 +1150,33 @@ module JSON
984
1150
  # ruby = [0, 1, nil]
985
1151
  # JSON[ruby] # => '[0,1,null]'
986
1152
  #
987
- # source://json//lib/json/common.rb#22
1153
+ # source://json//lib/json/common.rb#127
988
1154
  def [](object, opts = T.unsafe(nil)); end
989
1155
 
990
- # source://json//lib/json/common.rb#85
991
- def create_fast_state; end
992
-
993
1156
  # Returns the current create identifier.
994
1157
  # See also JSON.create_id=.
995
1158
  #
996
- # source://json//lib/json/common.rb#130
1159
+ # source://json//lib/json/common.rb#220
997
1160
  def create_id; end
998
1161
 
999
1162
  # Sets create identifier, which is used to decide if the _json_create_
1000
1163
  # hook of a class should be called; initial value is +json_class+:
1001
1164
  # JSON.create_id # => 'json_class'
1002
1165
  #
1003
- # source://json//lib/json/common.rb#124
1166
+ # source://json//lib/json/common.rb#214
1004
1167
  def create_id=(new_value); end
1005
1168
 
1006
- # source://json//lib/json/common.rb#95
1007
- def create_pretty_state; end
1008
-
1009
1169
  # Return the constant located at _path_. The format of _path_ has to be
1010
1170
  # either ::A::B::C or A::B::C. In any case, A has to be located at the top
1011
1171
  # level (absolute namespace path?). If there doesn't exist a constant at
1012
1172
  # the given path, an ArgumentError is raised.
1013
1173
  #
1014
- # source://json//lib/json/common.rb#46
1174
+ # source://json//lib/json/common.rb#154
1015
1175
  def deep_const_get(path); end
1016
1176
 
1177
+ # source://json//lib/json/common.rb#99
1178
+ def deprecation_warning(message, uplevel = T.unsafe(nil)); end
1179
+
1017
1180
  # :call-seq:
1018
1181
  # JSON.dump(obj, io = nil, limit = nil)
1019
1182
  #
@@ -1042,25 +1205,9 @@ module JSON
1042
1205
  # Output:
1043
1206
  # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
1044
1207
  #
1045
- # source://json//lib/json/common.rb#615
1208
+ # source://json//lib/json/common.rb#893
1046
1209
  def dump(obj, anIO = T.unsafe(nil), limit = T.unsafe(nil), kwargs = T.unsafe(nil)); end
1047
1210
 
1048
- # Sets or returns the default options for the JSON.dump method.
1049
- # Initially:
1050
- # opts = JSON.dump_default_options
1051
- # opts # => {:max_nesting=>false, :allow_nan=>true, :script_safe=>false}
1052
- #
1053
- # source://json//lib/json/common.rb#580
1054
- def dump_default_options; end
1055
-
1056
- # Sets or returns the default options for the JSON.dump method.
1057
- # Initially:
1058
- # opts = JSON.dump_default_options
1059
- # opts # => {:max_nesting=>false, :allow_nan=>true, :script_safe=>false}
1060
- #
1061
- # source://json//lib/json/common.rb#580
1062
- def dump_default_options=(_arg0); end
1063
-
1064
1211
  # :call-seq:
1065
1212
  # JSON.fast_generate(obj, opts) -> new_string
1066
1213
  #
@@ -1075,14 +1222,11 @@ module JSON
1075
1222
  # # Raises SystemStackError (stack level too deep):
1076
1223
  # JSON.fast_generate(a)
1077
1224
  #
1078
- # source://json//lib/json/common.rb#329
1225
+ # source://json//lib/json/common.rb#446
1079
1226
  def fast_generate(obj, opts = T.unsafe(nil)); end
1080
1227
 
1081
- # :stopdoc:
1082
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
1083
- #
1084
- # source://json//lib/json/common.rb#329
1085
- def fast_unparse(obj, opts = T.unsafe(nil)); end
1228
+ # source://json//lib/json/common.rb#938
1229
+ def fast_unparse(*_arg0, **_arg1, &_arg2); end
1086
1230
 
1087
1231
  # :call-seq:
1088
1232
  # JSON.generate(obj, opts = nil) -> new_string
@@ -1120,31 +1264,34 @@ module JSON
1120
1264
  # # Raises JSON::NestingError (nesting of 100 is too deep):
1121
1265
  # JSON.generate(a)
1122
1266
  #
1123
- # source://json//lib/json/common.rb#300
1267
+ # source://json//lib/json/common.rb#425
1124
1268
  def generate(obj, opts = T.unsafe(nil)); end
1125
1269
 
1126
- # Returns the JSON generator module that is used by JSON. This is
1127
- # either JSON::Ext::Generator or JSON::Pure::Generator:
1128
- # JSON.generator # => JSON::Ext::Generator
1270
+ # Returns the JSON generator module that is used by JSON.
1129
1271
  #
1130
- # source://json//lib/json/common.rb#107
1272
+ # source://json//lib/json/common.rb#182
1131
1273
  def generator; end
1132
1274
 
1133
1275
  # Set the module _generator_ to be used by JSON.
1134
1276
  #
1135
- # source://json//lib/json/common.rb#62
1277
+ # source://json//lib/json/common.rb#161
1136
1278
  def generator=(generator); end
1137
1279
 
1138
- # Encodes string using String.encode.
1139
- #
1140
- # source://json//lib/json/common.rb#639
1141
- def iconv(to, from, string); end
1142
-
1143
1280
  # :call-seq:
1144
1281
  # JSON.load(source, proc = nil, options = {}) -> object
1145
1282
  #
1146
1283
  # Returns the Ruby objects created by parsing the given +source+.
1147
1284
  #
1285
+ # BEWARE: This method is meant to serialise data from trusted user input,
1286
+ # like from your own database server or clients under your control, it could
1287
+ # be dangerous to allow untrusted users to pass JSON sources into it.
1288
+ # If you must use it, use JSON.unsafe_load instead to make it clear.
1289
+ #
1290
+ # Since JSON version 2.8.0, `load` emits a deprecation warning when a
1291
+ # non native type is deserialized, without `create_additions` being explicitly
1292
+ # enabled, and in JSON version 3.0, `load` will have `create_additions` disabled
1293
+ # by default.
1294
+ #
1148
1295
  # - Argument +source+ must be, or be convertible to, a \String:
1149
1296
  # - If +source+ responds to instance method +to_str+,
1150
1297
  # <tt>source.to_str</tt> becomes the source.
@@ -1159,9 +1306,6 @@ module JSON
1159
1306
  # - Argument +proc+, if given, must be a \Proc that accepts one argument.
1160
1307
  # It will be called recursively with each result (depth-first order).
1161
1308
  # See details below.
1162
- # BEWARE: This method is meant to serialise data from trusted user input,
1163
- # like from your own database server or clients under your control, it could
1164
- # be dangerous to allow untrusted users to pass JSON sources into it.
1165
1309
  # - Argument +opts+, if given, contains a \Hash of options for the parsing.
1166
1310
  # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1167
1311
  # The default options can be changed via method JSON.load_default_options=.
@@ -1172,17 +1316,17 @@ module JSON
1172
1316
  # <tt>parse(source, opts)</tt>; see #parse.
1173
1317
  #
1174
1318
  # Source for following examples:
1175
- # source = <<-EOT
1176
- # {
1177
- # "name": "Dave",
1178
- # "age" :40,
1179
- # "hats": [
1180
- # "Cattleman's",
1181
- # "Panama",
1182
- # "Tophat"
1183
- # ]
1184
- # }
1185
- # EOT
1319
+ # source = <<~JSON
1320
+ # {
1321
+ # "name": "Dave",
1322
+ # "age" :40,
1323
+ # "hats": [
1324
+ # "Cattleman's",
1325
+ # "Panama",
1326
+ # "Tophat"
1327
+ # ]
1328
+ # }
1329
+ # JSON
1186
1330
  #
1187
1331
  # Load a \String:
1188
1332
  # ruby = JSON.load(source)
@@ -1268,25 +1412,9 @@ module JSON
1268
1412
  # #<Admin:0x00000000064c41f8
1269
1413
  # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
1270
1414
  #
1271
- # source://json//lib/json/common.rb#541
1415
+ # source://json//lib/json/common.rb#827
1272
1416
  def load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1273
1417
 
1274
- # Sets or returns default options for the JSON.load method.
1275
- # Initially:
1276
- # opts = JSON.load_default_options
1277
- # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
1278
- #
1279
- # source://json//lib/json/common.rb#404
1280
- def load_default_options; end
1281
-
1282
- # Sets or returns default options for the JSON.load method.
1283
- # Initially:
1284
- # opts = JSON.load_default_options
1285
- # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
1286
- #
1287
- # source://json//lib/json/common.rb#404
1288
- def load_default_options=(_arg0); end
1289
-
1290
1418
  # :call-seq:
1291
1419
  # JSON.load_file(path, opts={}) -> object
1292
1420
  #
@@ -1295,7 +1423,7 @@ module JSON
1295
1423
  #
1296
1424
  # See method #parse.
1297
1425
  #
1298
- # source://json//lib/json/common.rb#249
1426
+ # source://json//lib/json/common.rb#374
1299
1427
  def load_file(filespec, opts = T.unsafe(nil)); end
1300
1428
 
1301
1429
  # :call-seq:
@@ -1306,7 +1434,7 @@ module JSON
1306
1434
  #
1307
1435
  # See method #parse!
1308
1436
  #
1309
- # source://json//lib/json/common.rb#260
1437
+ # source://json//lib/json/common.rb#385
1310
1438
  def load_file!(filespec, opts = T.unsafe(nil)); end
1311
1439
 
1312
1440
  # :call-seq:
@@ -1337,17 +1465,17 @@ module JSON
1337
1465
  # {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
1338
1466
  #
1339
1467
  # Parses nested JSON objects:
1340
- # source = <<-EOT
1341
- # {
1342
- # "name": "Dave",
1343
- # "age" :40,
1344
- # "hats": [
1345
- # "Cattleman's",
1346
- # "Panama",
1347
- # "Tophat"
1348
- # ]
1349
- # }
1350
- # EOT
1468
+ # source = <<~JSON
1469
+ # {
1470
+ # "name": "Dave",
1471
+ # "age" :40,
1472
+ # "hats": [
1473
+ # "Cattleman's",
1474
+ # "Panama",
1475
+ # "Tophat"
1476
+ # ]
1477
+ # }
1478
+ # JSON
1351
1479
  # ruby = JSON.parse(source)
1352
1480
  # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1353
1481
  #
@@ -1357,7 +1485,7 @@ module JSON
1357
1485
  # # Raises JSON::ParserError (783: unexpected token at ''):
1358
1486
  # JSON.parse('')
1359
1487
  #
1360
- # source://json//lib/json/common.rb#219
1488
+ # source://json//lib/json/common.rb#337
1361
1489
  def parse(source, opts = T.unsafe(nil)); end
1362
1490
 
1363
1491
  # :call-seq:
@@ -1372,19 +1500,17 @@ module JSON
1372
1500
  # which disables checking for nesting depth.
1373
1501
  # - Option +allow_nan+, if not provided, defaults to +true+.
1374
1502
  #
1375
- # source://json//lib/json/common.rb#234
1503
+ # source://json//lib/json/common.rb#359
1376
1504
  def parse!(source, opts = T.unsafe(nil)); end
1377
1505
 
1378
- # Returns the JSON parser class that is used by JSON. This is either
1379
- # JSON::Ext::Parser or JSON::Pure::Parser:
1380
- # JSON.parser # => JSON::Ext::Parser
1506
+ # Returns the JSON parser class that is used by JSON.
1381
1507
  #
1382
- # source://json//lib/json/common.rb#33
1508
+ # source://json//lib/json/common.rb#141
1383
1509
  def parser; end
1384
1510
 
1385
1511
  # Set the JSON parser class _parser_ to be used by JSON.
1386
1512
  #
1387
- # source://json//lib/json/common.rb#36
1513
+ # source://json//lib/json/common.rb#144
1388
1514
  def parser=(parser); end
1389
1515
 
1390
1516
  # :call-seq:
@@ -1417,56 +1543,409 @@ module JSON
1417
1543
  # }
1418
1544
  # }
1419
1545
  #
1420
- # source://json//lib/json/common.rb#374
1546
+ # source://json//lib/json/common.rb#493
1421
1547
  def pretty_generate(obj, opts = T.unsafe(nil)); end
1422
1548
 
1423
- # :stopdoc:
1424
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
1425
- #
1426
- # source://json//lib/json/common.rb#374
1427
- def pretty_unparse(obj, opts = T.unsafe(nil)); end
1549
+ # source://json//lib/json/common.rb#948
1550
+ def pretty_unparse(*_arg0, **_arg1, &_arg2); end
1428
1551
 
1429
- # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
1430
- #
1431
- # source://json//lib/json/common.rb#559
1432
- def recurse_proc(result, &proc); end
1552
+ # source://json//lib/json/common.rb#958
1553
+ def restore(*_arg0, **_arg1, &_arg2); end
1433
1554
 
1434
- # source://json//lib/json/common.rb#541
1435
- def restore(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1436
-
1437
- # Sets or Returns the JSON generator state class that is used by JSON. This is
1438
- # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
1439
- # JSON.state # => JSON::Ext::Generator::State
1555
+ # Sets or Returns the JSON generator state class that is used by JSON.
1440
1556
  #
1441
- # source://json//lib/json/common.rb#112
1557
+ # source://json//lib/json/common.rb#185
1442
1558
  def state; end
1443
1559
 
1444
- # Sets or Returns the JSON generator state class that is used by JSON. This is
1445
- # either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
1446
- # JSON.state # => JSON::Ext::Generator::State
1560
+ # Sets or Returns the JSON generator state class that is used by JSON.
1447
1561
  #
1448
- # source://json//lib/json/common.rb#112
1562
+ # source://json//lib/json/common.rb#185
1449
1563
  def state=(_arg0); end
1450
1564
 
1451
1565
  # :stopdoc:
1452
- # I want to deprecate these later, so I'll first be silent about them, and
1453
- # later delete them.
1566
+ # All these were meant to be deprecated circa 2009, but were just set as undocumented
1567
+ # so usage still exist in the wild.
1568
+ #
1569
+ # source://json//lib/json/common.rb#928
1570
+ def unparse(*_arg0, **_arg1, &_arg2); end
1571
+
1572
+ # :call-seq:
1573
+ # JSON.unsafe_load(source, proc = nil, options = {}) -> object
1574
+ #
1575
+ # Returns the Ruby objects created by parsing the given +source+.
1576
+ #
1577
+ # BEWARE: This method is meant to serialise data from trusted user input,
1578
+ # like from your own database server or clients under your control, it could
1579
+ # be dangerous to allow untrusted users to pass JSON sources into it.
1580
+ #
1581
+ # - Argument +source+ must be, or be convertible to, a \String:
1582
+ # - If +source+ responds to instance method +to_str+,
1583
+ # <tt>source.to_str</tt> becomes the source.
1584
+ # - If +source+ responds to instance method +to_io+,
1585
+ # <tt>source.to_io.read</tt> becomes the source.
1586
+ # - If +source+ responds to instance method +read+,
1587
+ # <tt>source.read</tt> becomes the source.
1588
+ # - If both of the following are true, source becomes the \String <tt>'null'</tt>:
1589
+ # - Option +allow_blank+ specifies a truthy value.
1590
+ # - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
1591
+ # - Otherwise, +source+ remains the source.
1592
+ # - Argument +proc+, if given, must be a \Proc that accepts one argument.
1593
+ # It will be called recursively with each result (depth-first order).
1594
+ # See details below.
1595
+ # - Argument +opts+, if given, contains a \Hash of options for the parsing.
1596
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options].
1597
+ # The default options can be changed via method JSON.unsafe_load_default_options=.
1598
+ #
1599
+ # ---
1600
+ #
1601
+ # When no +proc+ is given, modifies +source+ as above and returns the result of
1602
+ # <tt>parse(source, opts)</tt>; see #parse.
1603
+ #
1604
+ # Source for following examples:
1605
+ # source = <<~JSON
1606
+ # {
1607
+ # "name": "Dave",
1608
+ # "age" :40,
1609
+ # "hats": [
1610
+ # "Cattleman's",
1611
+ # "Panama",
1612
+ # "Tophat"
1613
+ # ]
1614
+ # }
1615
+ # JSON
1616
+ #
1617
+ # Load a \String:
1618
+ # ruby = JSON.unsafe_load(source)
1619
+ # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1620
+ #
1621
+ # Load an \IO object:
1622
+ # require 'stringio'
1623
+ # object = JSON.unsafe_load(StringIO.new(source))
1624
+ # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1625
+ #
1626
+ # Load a \File object:
1627
+ # path = 't.json'
1628
+ # File.write(path, source)
1629
+ # File.open(path) do |file|
1630
+ # JSON.unsafe_load(file)
1631
+ # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
1632
+ #
1633
+ # ---
1454
1634
  #
1455
- # source://json//lib/json/common.rb#300
1456
- def unparse(obj, opts = T.unsafe(nil)); end
1635
+ # When +proc+ is given:
1636
+ # - Modifies +source+ as above.
1637
+ # - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
1638
+ # - Recursively calls <tt>proc(result)</tt>.
1639
+ # - Returns the final result.
1640
+ #
1641
+ # Example:
1642
+ # require 'json'
1643
+ #
1644
+ # # Some classes for the example.
1645
+ # class Base
1646
+ # def initialize(attributes)
1647
+ # @attributes = attributes
1648
+ # end
1649
+ # end
1650
+ # class User < Base; end
1651
+ # class Account < Base; end
1652
+ # class Admin < Base; end
1653
+ # # The JSON source.
1654
+ # json = <<-EOF
1655
+ # {
1656
+ # "users": [
1657
+ # {"type": "User", "username": "jane", "email": "jane@example.com"},
1658
+ # {"type": "User", "username": "john", "email": "john@example.com"}
1659
+ # ],
1660
+ # "accounts": [
1661
+ # {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
1662
+ # {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
1663
+ # ],
1664
+ # "admins": {"type": "Admin", "password": "0wn3d"}
1665
+ # }
1666
+ # EOF
1667
+ # # Deserializer method.
1668
+ # def deserialize_obj(obj, safe_types = %w(User Account Admin))
1669
+ # type = obj.is_a?(Hash) && obj["type"]
1670
+ # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
1671
+ # end
1672
+ # # Call to JSON.unsafe_load
1673
+ # ruby = JSON.unsafe_load(json, proc {|obj|
1674
+ # case obj
1675
+ # when Hash
1676
+ # obj.each {|k, v| obj[k] = deserialize_obj v }
1677
+ # when Array
1678
+ # obj.map! {|v| deserialize_obj v }
1679
+ # end
1680
+ # })
1681
+ # pp ruby
1682
+ # Output:
1683
+ # {"users"=>
1684
+ # [#<User:0x00000000064c4c98
1685
+ # @attributes=
1686
+ # {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
1687
+ # #<User:0x00000000064c4bd0
1688
+ # @attributes=
1689
+ # {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
1690
+ # "accounts"=>
1691
+ # [{"account"=>
1692
+ # #<Account:0x00000000064c4928
1693
+ # @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
1694
+ # {"account"=>
1695
+ # #<Account:0x00000000064c4680
1696
+ # @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
1697
+ # "admins"=>
1698
+ # #<Admin:0x00000000064c41f8
1699
+ # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
1700
+ #
1701
+ # source://json//lib/json/common.rb#667
1702
+ def unsafe_load(source, proc = T.unsafe(nil), options = T.unsafe(nil)); end
1457
1703
 
1458
1704
  private
1459
1705
 
1460
- # source://json//lib/json/common.rb#643
1461
- def merge_dump_options(opts, strict: T.unsafe(nil)); end
1706
+ # source://json//lib/json/common.rb#971
1707
+ def const_missing(const_name); end
1708
+
1709
+ # source://json//lib/json/common.rb#189
1710
+ def deprecated_singleton_attr_accessor(*attrs); end
1462
1711
  end
1463
1712
  end
1464
1713
 
1465
- # source://json//lib/json/common.rb#118
1466
- JSON::CREATE_ID_TLS_KEY = T.let(T.unsafe(nil), String)
1714
+ # JSON::Coder holds a parser and generator configuration.
1715
+ #
1716
+ # module MyApp
1717
+ # JSONC_CODER = JSON::Coder.new(
1718
+ # allow_trailing_comma: true
1719
+ # )
1720
+ # end
1721
+ #
1722
+ # MyApp::JSONC_CODER.load(document)
1723
+ #
1724
+ # source://json//lib/json/common.rb#997
1725
+ class JSON::Coder
1726
+ # :call-seq:
1727
+ # JSON.new(options = nil, &block)
1728
+ #
1729
+ # Argument +options+, if given, contains a \Hash of options for both parsing and generating.
1730
+ # See {Parsing Options}[#module-JSON-label-Parsing+Options], and {Generating Options}[#module-JSON-label-Generating+Options].
1731
+ #
1732
+ # For generation, the <tt>strict: true</tt> option is always set. When a Ruby object with no native \JSON counterpart is
1733
+ # encoutered, the block provided to the initialize method is invoked, and must return a Ruby object that has a native
1734
+ # \JSON counterpart:
1735
+ #
1736
+ # module MyApp
1737
+ # API_JSON_CODER = JSON::Coder.new do |object|
1738
+ # case object
1739
+ # when Time
1740
+ # object.iso8601(3)
1741
+ # else
1742
+ # object # Unknown type, will raise
1743
+ # end
1744
+ # end
1745
+ # end
1746
+ #
1747
+ # puts MyApp::API_JSON_CODER.dump(Time.now.utc) # => "2025-01-21T08:41:44.286Z"
1748
+ #
1749
+ # @return [Coder] a new instance of Coder
1750
+ #
1751
+ # source://json//lib/json/common.rb#1021
1752
+ def initialize(options = T.unsafe(nil), &as_json); end
1753
+
1754
+ # call-seq:
1755
+ # dump(object) -> String
1756
+ # dump(object, io) -> io
1757
+ #
1758
+ # Serialize the given object into a \JSON document.
1759
+ #
1760
+ # source://json//lib/json/common.rb#1039
1761
+ def dump(object, io = T.unsafe(nil)); end
1762
+
1763
+ # call-seq:
1764
+ # dump(object) -> String
1765
+ # dump(object, io) -> io
1766
+ #
1767
+ # Serialize the given object into a \JSON document.
1768
+ #
1769
+ # source://json//lib/json/common.rb#1039
1770
+ def generate(object, io = T.unsafe(nil)); end
1771
+
1772
+ # call-seq:
1773
+ # load(string) -> Object
1774
+ #
1775
+ # Parse the given \JSON document and return an equivalent Ruby object.
1776
+ #
1777
+ # source://json//lib/json/common.rb#1048
1778
+ def load(source); end
1779
+
1780
+ # call-seq:
1781
+ # load(path) -> Object
1782
+ #
1783
+ # Parse the given \JSON document and return an equivalent Ruby object.
1784
+ #
1785
+ # source://json//lib/json/common.rb#1057
1786
+ def load_file(path); end
1787
+
1788
+ # call-seq:
1789
+ # load(string) -> Object
1790
+ #
1791
+ # Parse the given \JSON document and return an equivalent Ruby object.
1792
+ #
1793
+ # source://json//lib/json/common.rb#1048
1794
+ def parse(source); end
1795
+ end
1796
+
1797
+ module JSON::Ext::Generator::GeneratorMethods::String
1798
+ mixes_in_class_methods ::JSON::Ext::Generator::GeneratorMethods::String::Extend
1799
+ end
1800
+
1801
+ # source://json//lib/json/ext/generator/state.rb#6
1802
+ class JSON::Ext::Generator::State
1803
+ # call-seq: new(opts = {})
1804
+ #
1805
+ # Instantiates a new State object, configured by _opts_.
1806
+ #
1807
+ # _opts_ can have the following keys:
1808
+ #
1809
+ # * *indent*: a string used to indent levels (default: ''),
1810
+ # * *space*: a string that is put after, a : or , delimiter (default: ''),
1811
+ # * *space_before*: a string that is put before a : pair delimiter (default: ''),
1812
+ # * *object_nl*: a string that is put at the end of a JSON object (default: ''),
1813
+ # * *array_nl*: a string that is put at the end of a JSON array (default: ''),
1814
+ # * *allow_nan*: true if NaN, Infinity, and -Infinity should be
1815
+ # generated, otherwise an exception is thrown, if these values are
1816
+ # encountered. This options defaults to false.
1817
+ # * *ascii_only*: true if only ASCII characters should be generated. This
1818
+ # option defaults to false.
1819
+ # * *buffer_initial_length*: sets the initial length of the generator's
1820
+ # internal buffer.
1821
+ #
1822
+ # @return [State] a new instance of State
1823
+ #
1824
+ # source://json//lib/json/ext/generator/state.rb#25
1825
+ def initialize(opts = T.unsafe(nil)); end
1826
+
1827
+ # call-seq: [](name)
1828
+ #
1829
+ # Returns the value returned by method +name+.
1830
+ #
1831
+ # source://json//lib/json/ext/generator/state.rb#84
1832
+ def [](name); end
1833
+
1834
+ # call-seq: []=(name, value)
1835
+ #
1836
+ # Sets the attribute name to value.
1837
+ #
1838
+ # source://json//lib/json/ext/generator/state.rb#96
1839
+ def []=(name, value); end
1840
+
1841
+ # call-seq: configure(opts)
1842
+ #
1843
+ # Configure this State instance with the Hash _opts_, and return
1844
+ # itself.
1845
+ #
1846
+ # source://json//lib/json/ext/generator/state.rb#35
1847
+ def configure(opts); end
1848
+
1849
+ # call-seq: configure(opts)
1850
+ #
1851
+ # Configure this State instance with the Hash _opts_, and return
1852
+ # itself.
1853
+ #
1854
+ # source://json//lib/json/ext/generator/state.rb#35
1855
+ def merge(opts); end
1856
+
1857
+ # call-seq: to_h
1858
+ #
1859
+ # Returns the configuration instance variables as a hash, that can be
1860
+ # passed to the configure method.
1861
+ #
1862
+ # source://json//lib/json/ext/generator/state.rb#54
1863
+ def to_h; end
1864
+
1865
+ # call-seq: to_h
1866
+ #
1867
+ # Returns the configuration instance variables as a hash, that can be
1868
+ # passed to the configure method.
1869
+ #
1870
+ # source://json//lib/json/ext/generator/state.rb#54
1871
+ def to_hash; end
1872
+ end
1873
+
1874
+ # source://json//lib/json/ext.rb#9
1875
+ class JSON::Ext::Parser
1876
+ # @return [Parser] a new instance of Parser
1877
+ #
1878
+ # source://json//lib/json/ext.rb#17
1879
+ def initialize(source, opts = T.unsafe(nil)); end
1880
+
1881
+ # source://json//lib/json/ext.rb#26
1882
+ def parse; end
1883
+
1884
+ # source://json//lib/json/ext.rb#22
1885
+ def source; end
1886
+ end
1467
1887
 
1468
- # source://json//lib/json/common.rb#115
1469
- JSON::DEFAULT_CREATE_ID = T.let(T.unsafe(nil), String)
1888
+ # source://json//lib/json/ext.rb#32
1889
+ JSON::Ext::Parser::Config = JSON::Ext::ParserConfig
1890
+
1891
+ # Fragment of JSON document that is to be included as is:
1892
+ # fragment = JSON::Fragment.new("[1, 2, 3]")
1893
+ # JSON.generate({ count: 3, items: fragments })
1894
+ #
1895
+ # This allows to easily assemble multiple JSON fragments that have
1896
+ # been persisted somewhere without having to parse them nor resorting
1897
+ # to string interpolation.
1898
+ #
1899
+ # Note: no validation is performed on the provided string. It is the
1900
+ # responsibility of the caller to ensure the string contains valid JSON.
1901
+ #
1902
+ # source://json//lib/json/common.rb#273
1903
+ class JSON::Fragment < ::Struct
1904
+ # @return [Fragment] a new instance of Fragment
1905
+ #
1906
+ # source://json//lib/json/common.rb#274
1907
+ def initialize(json); end
1908
+
1909
+ # Returns the value of attribute json
1910
+ #
1911
+ # @return [Object] the current value of json
1912
+ def json; end
1913
+
1914
+ # Sets the attribute json
1915
+ #
1916
+ # @param value [Object] the value to set the attribute json to.
1917
+ # @return [Object] the newly set value
1918
+ def json=(_); end
1919
+
1920
+ # source://json//lib/json/common.rb#282
1921
+ def to_json(state = T.unsafe(nil), *_arg1); end
1922
+
1923
+ class << self
1924
+ def [](*_arg0); end
1925
+ def inspect; end
1926
+ def keyword_init?; end
1927
+ def members; end
1928
+ def new(*_arg0); end
1929
+ end
1930
+ end
1931
+
1932
+ # This exception is raised if a generator or unparser error occurs.
1933
+ #
1934
+ # source://json//lib/json/common.rb#243
1935
+ class JSON::GeneratorError < ::JSON::JSONError
1936
+ # @return [GeneratorError] a new instance of GeneratorError
1937
+ #
1938
+ # source://json//lib/json/common.rb#246
1939
+ def initialize(message, invalid_object = T.unsafe(nil)); end
1940
+
1941
+ # source://json//lib/json/common.rb#251
1942
+ def detailed_message(*_arg0, **_arg1, &_arg2); end
1943
+
1944
+ # Returns the value of attribute invalid_object.
1945
+ #
1946
+ # source://json//lib/json/common.rb#244
1947
+ def invalid_object; end
1948
+ end
1470
1949
 
1471
1950
  # source://json//lib/json/generic_object.rb#9
1472
1951
  class JSON::GenericObject < ::OpenStruct
@@ -1509,31 +1988,58 @@ class JSON::GenericObject < ::OpenStruct
1509
1988
  end
1510
1989
  end
1511
1990
 
1512
- # The base exception for JSON errors.
1991
+ # source://json//lib/json/common.rb#342
1992
+ JSON::PARSE_L_OPTIONS = T.let(T.unsafe(nil), Hash)
1993
+
1994
+ # source://json//lib/json/common.rb#455
1995
+ JSON::PRETTY_GENERATE_OPTIONS = T.let(T.unsafe(nil), Hash)
1996
+
1997
+ # source://json//lib/json/common.rb#147
1998
+ JSON::Parser = JSON::Ext::Parser
1999
+
2000
+ # This exception is raised if a parser error occurs.
1513
2001
  #
1514
- # source://json//lib/json/common.rb#141
1515
- class JSON::JSONError < ::StandardError
1516
- class << self
1517
- # source://json//lib/json/common.rb#142
1518
- def wrap(exception); end
1519
- end
2002
+ # source://json//lib/json/common.rb#234
2003
+ class JSON::ParserError < ::JSON::JSONError
2004
+ # Returns the value of attribute column.
2005
+ #
2006
+ # source://json//lib/json/common.rb#235
2007
+ def column; end
2008
+
2009
+ # Returns the value of attribute line.
2010
+ #
2011
+ # source://json//lib/json/common.rb#235
2012
+ def line; end
1520
2013
  end
1521
2014
 
1522
- # source://json//lib/json/common.rb#7
1523
- JSON::NOT_SET = T.let(T.unsafe(nil), Object)
2015
+ # source://json//lib/json/common.rb#8
2016
+ module JSON::ParserOptions
2017
+ class << self
2018
+ # source://json//lib/json/common.rb#10
2019
+ def prepare(opts); end
1524
2020
 
1525
- # source://json//lib/json/common.rb#39
1526
- JSON::Parser = JSON::Ext::Parser
2021
+ private
1527
2022
 
1528
- # source://json//lib/json/common.rb#77
1529
- JSON::State = JSON::Ext::Generator::State
2023
+ # source://json//lib/json/common.rb#40
2024
+ def array_class_proc(array_class, on_load); end
1530
2025
 
1531
- # For backwards compatibility
1532
- #
1533
- # source://json//lib/json/common.rb#163
1534
- JSON::UnparserError = JSON::GeneratorError
2026
+ # TODO: extract :create_additions support to another gem for version 3.0
2027
+ #
2028
+ # source://json//lib/json/common.rb#52
2029
+ def create_additions_proc(opts); end
1535
2030
 
1536
- # source://json//lib/json/common.rb#653
2031
+ # source://json//lib/json/common.rb#90
2032
+ def create_additions_warning; end
2033
+
2034
+ # source://json//lib/json/common.rb#29
2035
+ def object_class_proc(object_class, on_load); end
2036
+ end
2037
+ end
2038
+
2039
+ # source://json//lib/json/common.rb#176
2040
+ JSON::State = JSON::Ext::Generator::State
2041
+
2042
+ # source://json//lib/json/common.rb#1063
1537
2043
  module Kernel
1538
2044
  private
1539
2045
 
@@ -1544,18 +2050,38 @@ module Kernel
1544
2050
  # The _opts_ argument is passed through to generate/parse respectively. See
1545
2051
  # generate and parse for their documentation.
1546
2052
  #
1547
- # source://json//lib/json/common.rb#680
1548
- def JSON(object, *args); end
2053
+ # source://json//lib/json/common.rb#1102
2054
+ def JSON(object, opts = T.unsafe(nil)); end
1549
2055
 
1550
2056
  # Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
1551
2057
  # one line.
1552
2058
  #
1553
- # source://json//lib/json/common.rb#658
2059
+ # source://json//lib/json/common.rb#1068
1554
2060
  def j(*objs); end
1555
2061
 
1556
2062
  # Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
1557
2063
  # indentation and over many lines.
1558
2064
  #
1559
- # source://json//lib/json/common.rb#667
2065
+ # source://json//lib/json/common.rb#1083
1560
2066
  def jj(*objs); end
1561
2067
  end
2068
+
2069
+ class NilClass
2070
+ include ::JSON::Ext::Generator::GeneratorMethods::NilClass
2071
+ end
2072
+
2073
+ class Object < ::BasicObject
2074
+ include ::Kernel
2075
+ include ::PP::ObjectMixin
2076
+ include ::JSON::Ext::Generator::GeneratorMethods::Object
2077
+ end
2078
+
2079
+ class String
2080
+ include ::Comparable
2081
+ include ::JSON::Ext::Generator::GeneratorMethods::String
2082
+ extend ::JSON::Ext::Generator::GeneratorMethods::String::Extend
2083
+ end
2084
+
2085
+ class TrueClass
2086
+ include ::JSON::Ext::Generator::GeneratorMethods::TrueClass
2087
+ end