oj 3.16.5 → 3.16.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6eef89e8f6c362f4ff8c384bba7a892bff9e730a1225bb0bc986acf50ba45dd4
4
- data.tar.gz: 2d915ffcec2b55a4a91ad2292053e847efa5aa4ee6ef24e686cadd30218d7533
3
+ metadata.gz: 71fccfc65816b5412064b2295b66c038029cbea37dcae9475002753850d47740
4
+ data.tar.gz: f559a6cbe6ebce9443564d679ade4e527da6784d35c7a71bf7a85c4e2c0b2f75
5
5
  SHA512:
6
- metadata.gz: 845799a9624881305218a82d4d7ceb1ee535da2192ee44e30d38cd4727739749b5c9b18d891e5b363ca0a9b8e8025ee89a66f789f0bf4338493f2c34e1f6a576
7
- data.tar.gz: f2cad391b8de831efbf419332b5cc12f29e9cfae1a7a1cf4bf98348de722a3b400cddb4aa29a98576f38cf929061fd57f6e97424eff2bf0e33a9d5f78cfa27c1
6
+ metadata.gz: 5cc33a15e43c946351d281b65f1f692a9ad8b4055c3848f8f540f9b7f1043a1f4f8844b67ff17ffe072193d4a1922a596f4b941ee3a93c2f4eb4b52fedf191ec
7
+ data.tar.gz: 1314ce1b2d92fe30dd971832a294ee2052ac1434a3f026fa534573c55488a60de3f2ff0f81bb1577c0dc8941c84c75e5a18ac8d79d2f86c9b52c56fc225a4eca
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 3.16.7 - 2024-11-01
4
+
5
+ - Changed string_writer_as_json to allow multiple arguments.
6
+
7
+ - Fixed Global variable registration added to mimic_json and rails code thanks to @byroot.
8
+
9
+ ## 3.16.6 - 2024-09-09
10
+
11
+ - Fixed issue with Rails 7.2 that changed the order of calls to to_json and as_json.
12
+
3
13
  ## 3.16.5 - 2024-08-07
4
14
 
5
15
  - Fixed Oj::Parser so that block procedures work correctly.
data/ext/oj/mimic_json.c CHANGED
@@ -837,11 +837,15 @@ void oj_mimic_json_methods(VALUE json) {
837
837
  } else {
838
838
  json_error = rb_define_class_under(json, "JSONError", rb_eStandardError);
839
839
  }
840
+
841
+ rb_global_variable(&oj_json_parser_error_class);
840
842
  if (rb_const_defined_at(json, rb_intern("ParserError"))) {
841
843
  oj_json_parser_error_class = rb_const_get(json, rb_intern("ParserError"));
842
844
  } else {
843
845
  oj_json_parser_error_class = rb_define_class_under(json, "ParserError", json_error);
844
846
  }
847
+
848
+ rb_global_variable(&oj_json_generator_error_class);
845
849
  if (rb_const_defined_at(json, rb_intern("GeneratorError"))) {
846
850
  oj_json_generator_error_class = rb_const_get(json, rb_intern("GeneratorError"));
847
851
  } else {
@@ -867,8 +871,8 @@ void oj_mimic_json_methods(VALUE json) {
867
871
  rb_require("oj/state");
868
872
  }
869
873
  // Pull in the JSON::State mimic file.
874
+ rb_global_variable(&state_class);
870
875
  state_class = rb_const_get_at(generator, rb_intern("State"));
871
- rb_gc_register_mark_object(state_class);
872
876
  }
873
877
 
874
878
  /* Document-module: JSON
@@ -905,7 +909,9 @@ oj_define_mimic_json(int argc, VALUE *argv, VALUE self) {
905
909
  }
906
910
  oj_mimic_json_methods(json);
907
911
 
908
- rb_define_method(rb_cObject, "to_json", mimic_object_to_json, -1);
912
+ if (!rb_const_defined(rb_cObject, rb_intern("ActiveSupport"))) {
913
+ rb_define_method(rb_cObject, "to_json", mimic_object_to_json, -1);
914
+ }
909
915
 
910
916
  rb_gv_set("$VERBOSE", verbose);
911
917
 
data/ext/oj/rails.c CHANGED
@@ -1101,6 +1101,8 @@ static VALUE rails_set_decoder(VALUE self) {
1101
1101
  } else {
1102
1102
  json_error = rb_define_class_under(json, "JSONError", rb_eStandardError);
1103
1103
  }
1104
+
1105
+ rb_global_variable(&oj_json_parser_error_class);
1104
1106
  if (rb_const_defined_at(json, rb_intern("ParserError"))) {
1105
1107
  oj_json_parser_error_class = rb_const_get(json, rb_intern("ParserError"));
1106
1108
  } else {
@@ -475,16 +475,16 @@ static VALUE str_writer_to_s(VALUE self) {
475
475
  }
476
476
 
477
477
  /* Document-method: as_json
478
- * call-seq: as_json()
478
+ * call-seq: as_json(*)
479
479
  *
480
480
  * Returns the contents of the writer as a JSON element. If called from inside
481
481
  * an array or hash by Oj the raw buffer will be used othersize a more
482
482
  * inefficient parse of the contents and a return of the result is
483
- * completed. The parse uses the strict mode.
483
+ * completed. The parse uses the strict mode. Optional arguments are ignored.
484
484
  *
485
485
  * *return* [_Hash_|_Array_|_String_|_Integer_|_Float_|_True_|_False_|_nil|)
486
486
  */
487
- static VALUE str_writer_as_json(VALUE self) {
487
+ static VALUE str_writer_as_json(int argc, VALUE *argv, VALUE self) {
488
488
  if (string_writer_optimized) {
489
489
  return self;
490
490
  }
@@ -515,5 +515,5 @@ void oj_string_writer_init(void) {
515
515
  rb_define_method(oj_string_writer_class, "reset", str_writer_reset, 0);
516
516
  rb_define_method(oj_string_writer_class, "to_s", str_writer_to_s, 0);
517
517
  rb_define_method(oj_string_writer_class, "raw_json", str_writer_to_s, 0);
518
- rb_define_method(oj_string_writer_class, "as_json", str_writer_as_json, 0);
518
+ rb_define_method(oj_string_writer_class, "as_json", str_writer_as_json, -1);
519
519
  }
data/lib/oj/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Oj
2
2
  # Current version of the module.
3
- VERSION = '3.16.5'
3
+ VERSION = '3.16.7'
4
4
  end
@@ -19,7 +19,10 @@ require "active_support"
19
19
  Thread.abort_on_exception = true
20
20
 
21
21
  # Show backtraces for deprecated behavior for quicker cleanup.
22
- ActiveSupport::Deprecation.debug = true
22
+ if ActiveSupport::Deprecation.respond_to?(:debug)
23
+ # Rails 7.2 does not have ActiveSupport::Deprecation.debug
24
+ ActiveSupport::Deprecation.debug = true
25
+ end
23
26
 
24
27
  # Default to old to_time behavior but allow running tests with new behavior
25
28
  ActiveSupport.to_time_preserves_timezone = ENV["PRESERVE_TIMEZONES"] == "1"
data/test/test_compat.rb CHANGED
@@ -468,7 +468,7 @@ class CompatJuice < Minitest::Test
468
468
 
469
469
  def test_arg_passing
470
470
  json = Oj.to_json(Argy.new(), :max_nesting => 40)
471
- assert_equal(%|{"args":"[{:max_nesting=>40}]"}|, json)
471
+ assert_match(/.*max_nesting.*40.*/, json)
472
472
  end
473
473
 
474
474
  def test_max_nesting
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.16.5
4
+ version: 3.16.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-07 00:00:00.000000000 Z
11
+ date: 2024-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal
@@ -322,7 +322,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
322
322
  - !ruby/object:Gem::Version
323
323
  version: '0'
324
324
  requirements: []
325
- rubygems_version: 3.4.10
325
+ rubygems_version: 3.5.11
326
326
  signing_key:
327
327
  specification_version: 4
328
328
  summary: A fast JSON parser and serializer.