oj 3.9.2 → 3.10.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/ext/oj/buf.h +2 -30
  4. data/ext/oj/cache8.h +1 -29
  5. data/ext/oj/circarray.c +4 -8
  6. data/ext/oj/circarray.h +1 -4
  7. data/ext/oj/code.c +3 -6
  8. data/ext/oj/code.h +1 -4
  9. data/ext/oj/compat.c +6 -9
  10. data/ext/oj/custom.c +8 -7
  11. data/ext/oj/dump.c +33 -26
  12. data/ext/oj/dump.h +1 -4
  13. data/ext/oj/dump_compat.c +9 -14
  14. data/ext/oj/dump_leaf.c +2 -5
  15. data/ext/oj/dump_object.c +19 -15
  16. data/ext/oj/dump_strict.c +7 -9
  17. data/ext/oj/encode.h +1 -29
  18. data/ext/oj/err.c +1 -4
  19. data/ext/oj/err.h +1 -29
  20. data/ext/oj/extconf.rb +5 -0
  21. data/ext/oj/fast.c +14 -42
  22. data/ext/oj/hash.c +4 -32
  23. data/ext/oj/hash.h +1 -29
  24. data/ext/oj/hash_test.c +1 -29
  25. data/ext/oj/mimic_json.c +28 -10
  26. data/ext/oj/object.c +4 -6
  27. data/ext/oj/odd.c +1 -4
  28. data/ext/oj/odd.h +1 -4
  29. data/ext/oj/oj.c +74 -38
  30. data/ext/oj/oj.h +9 -7
  31. data/ext/oj/parse.c +127 -52
  32. data/ext/oj/parse.h +4 -5
  33. data/ext/oj/rails.c +38 -8
  34. data/ext/oj/rails.h +1 -4
  35. data/ext/oj/reader.c +5 -8
  36. data/ext/oj/reader.h +2 -5
  37. data/ext/oj/resolve.c +1 -4
  38. data/ext/oj/resolve.h +1 -4
  39. data/ext/oj/rxclass.c +3 -6
  40. data/ext/oj/rxclass.h +1 -4
  41. data/ext/oj/saj.c +6 -9
  42. data/ext/oj/scp.c +1 -4
  43. data/ext/oj/sparse.c +31 -26
  44. data/ext/oj/stream_writer.c +4 -9
  45. data/ext/oj/strict.c +3 -6
  46. data/ext/oj/string_writer.c +1 -4
  47. data/ext/oj/trace.c +5 -8
  48. data/ext/oj/trace.h +1 -4
  49. data/ext/oj/util.c +1 -1
  50. data/ext/oj/util.h +1 -1
  51. data/ext/oj/val_stack.c +1 -29
  52. data/ext/oj/val_stack.h +1 -29
  53. data/ext/oj/wab.c +10 -13
  54. data/lib/oj/mimic.rb +45 -1
  55. data/lib/oj/version.rb +1 -1
  56. data/lib/oj.rb +0 -8
  57. data/pages/Modes.md +1 -1
  58. data/pages/Options.md +15 -11
  59. data/pages/Rails.md +60 -21
  60. data/test/activesupport5/abstract_unit.rb +45 -0
  61. data/test/activesupport5/decoding_test.rb +68 -60
  62. data/test/activesupport5/encoding_test.rb +111 -96
  63. data/test/activesupport5/encoding_test_cases.rb +33 -25
  64. data/test/activesupport5/test_helper.rb +43 -21
  65. data/test/activesupport5/time_zone_test_helpers.rb +18 -3
  66. data/test/activesupport6/abstract_unit.rb +44 -0
  67. data/test/activesupport6/decoding_test.rb +133 -0
  68. data/test/activesupport6/encoding_test.rb +507 -0
  69. data/test/activesupport6/encoding_test_cases.rb +98 -0
  70. data/test/activesupport6/test_common.rb +17 -0
  71. data/test/activesupport6/test_helper.rb +163 -0
  72. data/test/activesupport6/time_zone_test_helpers.rb +39 -0
  73. data/test/bar.rb +21 -11
  74. data/test/baz.rb +16 -0
  75. data/test/foo.rb +39 -8
  76. data/test/json_gem/json_common_interface_test.rb +8 -3
  77. data/test/prec.rb +23 -0
  78. data/test/sample_json.rb +1 -1
  79. data/test/test_compat.rb +14 -8
  80. data/test/test_custom.rb +36 -6
  81. data/test/test_integer_range.rb +1 -2
  82. data/test/test_object.rb +12 -3
  83. data/test/test_rails.rb +35 -0
  84. data/test/test_strict.rb +24 -1
  85. data/test/test_various.rb +42 -64
  86. data/test/tests.rb +1 -0
  87. metadata +29 -7
data/test/test_various.rb CHANGED
@@ -96,70 +96,46 @@ class Juice < Minitest::Test
96
96
  Oj.default_options = @default_options
97
97
  end
98
98
 
99
- =begin
100
- # Depending on the order the values may have changed. The set_options sets
101
- # should cover the function itself.
102
- def test_get_options
103
- opts = Oj.default_options()
104
- assert_equal({ :indent=>0,
105
- :second_precision=>9,
106
- :circular=>false,
107
- :class_cache=>true,
108
- :auto_define=>false,
109
- :symbol_keys=>false,
110
- :bigdecimal_as_decimal=>true,
111
- :use_to_json=>true,
112
- :nilnil=>false,
113
- :allow_gc=>true,
114
- :quirks_mode=>true,
115
- :allow_invalid_unicode=>false,
116
- :float_precision=>15,
117
- :mode=>:object,
118
- :escape_mode=>:json,
119
- :time_format=>:unix_zone,
120
- :bigdecimal_load=>:auto,
121
- :create_id=>'json_class'}, opts)
122
- end
123
- =end
124
99
  def test_set_options
125
100
  orig = Oj.default_options()
126
101
  alt ={
127
- :indent=>" - ",
128
- :second_precision=>5,
129
- :circular=>true,
130
- :class_cache=>false,
131
- :auto_define=>true,
132
- :symbol_keys=>true,
133
- :bigdecimal_as_decimal=>false,
134
- :use_to_json=>false,
135
- :use_to_hash=>false,
136
- :use_as_json=>false,
137
- :use_raw_json=>false,
138
- :nilnil=>true,
139
- :empty_string=>true,
140
- :allow_gc=>false,
141
- :quirks_mode=>false,
142
- :allow_invalid_unicode=>true,
143
- :float_precision=>13,
144
- :mode=>:strict,
145
- :escape_mode=>:ascii,
146
- :time_format=>:unix_zone,
147
- :bigdecimal_load=>:float,
148
- :create_id=>'classy',
149
- :create_additions=>true,
150
- :space=>'z',
151
- :array_nl=>'a',
152
- :object_nl=>'o',
153
- :space_before=>'b',
154
- :nan=>:huge,
155
- :hash_class=>Hash,
156
- :omit_nil=>false,
157
- :allow_nan=>true,
158
- :integer_range=>nil,
159
- :array_class=>Array,
160
- :ignore=>nil,
161
- :trace=>true,
162
- :safe=>true,
102
+ indent: " - ",
103
+ second_precision: 5,
104
+ circular: true,
105
+ class_cache: false,
106
+ auto_define: true,
107
+ symbol_keys: true,
108
+ bigdecimal_as_decimal: false,
109
+ use_to_json: false,
110
+ use_to_hash: false,
111
+ use_as_json: false,
112
+ use_raw_json: false,
113
+ nilnil: true,
114
+ empty_string: true,
115
+ allow_gc: false,
116
+ quirks_mode: false,
117
+ allow_invalid_unicode: true,
118
+ float_precision: 13,
119
+ mode: :strict,
120
+ escape_mode: :ascii,
121
+ time_format: :unix_zone,
122
+ bigdecimal_load: :float,
123
+ create_id: 'classy',
124
+ create_additions: true,
125
+ space: 'z',
126
+ array_nl: 'a',
127
+ object_nl: 'o',
128
+ space_before: 'b',
129
+ nan: :huge,
130
+ hash_class: Hash,
131
+ omit_nil: false,
132
+ allow_nan: true,
133
+ integer_range: nil,
134
+ array_class: Array,
135
+ ignore: nil,
136
+ ignore_under: true,
137
+ trace: true,
138
+ safe: true,
163
139
  }
164
140
  Oj.default_options = alt
165
141
  #keys = alt.keys
@@ -209,7 +185,6 @@ class Juice < Minitest::Test
209
185
  n = Oj.load('-0.000012345678901234567')
210
186
  assert_equal(BigDecimal, n.class)
211
187
  assert_equal('-0.12345678901234567E-4', n.to_s.upcase)
212
-
213
188
  end
214
189
 
215
190
  =begin
@@ -425,8 +400,11 @@ class Juice < Minitest::Test
425
400
  def test_time_years
426
401
  (-2020..2020).each { |year|
427
402
  s = "%04d-03-01T15:14:13Z" % [year]
428
- json = Oj.dump(Time.parse(s), mode: :custom, time_format: :xmlschema)
403
+ json = Oj.dump(Time.parse(s), mode: :custom, time_format: :xmlschema, second_precision: -1)
429
404
  assert_equal(s, json[1..-2])
405
+
406
+ json = Oj.dump(Time.parse(s), mode: :custom, time_format: :xmlschema, second_precision: 3)
407
+ assert_equal(s[0..-2] + '.000Z', json[1..-2])
430
408
  }
431
409
  end
432
410
 
@@ -692,7 +670,7 @@ class Juice < Minitest::Test
692
670
  raise e
693
671
  end
694
672
  }
695
- assert_equal('first[2].third', msg.split('(')[1].split(')')[0])
673
+ assert_equal('after first[2].third', msg.split('(')[1].split(')')[0])
696
674
  end
697
675
 
698
676
  def test_bad_bignum
data/test/tests.rb CHANGED
@@ -19,6 +19,7 @@ require 'test_saj'
19
19
  require 'test_scp'
20
20
  require 'test_strict'
21
21
  require 'test_various'
22
+ require 'test_rails'
22
23
  require 'test_wab'
23
24
  require 'test_writer'
24
25
  require 'test_integer_range'
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.9.2
4
+ version: 3.10.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-02 00:00:00.000000000 Z
11
+ date: 2020-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -172,12 +172,21 @@ files:
172
172
  - test/activesupport4/decoding_test.rb
173
173
  - test/activesupport4/encoding_test.rb
174
174
  - test/activesupport4/test_helper.rb
175
+ - test/activesupport5/abstract_unit.rb
175
176
  - test/activesupport5/decoding_test.rb
176
177
  - test/activesupport5/encoding_test.rb
177
178
  - test/activesupport5/encoding_test_cases.rb
178
179
  - test/activesupport5/test_helper.rb
179
180
  - test/activesupport5/time_zone_test_helpers.rb
181
+ - test/activesupport6/abstract_unit.rb
182
+ - test/activesupport6/decoding_test.rb
183
+ - test/activesupport6/encoding_test.rb
184
+ - test/activesupport6/encoding_test_cases.rb
185
+ - test/activesupport6/test_common.rb
186
+ - test/activesupport6/test_helper.rb
187
+ - test/activesupport6/time_zone_test_helpers.rb
180
188
  - test/bar.rb
189
+ - test/baz.rb
181
190
  - test/files.rb
182
191
  - test/foo.rb
183
192
  - test/helper.rb
@@ -210,6 +219,7 @@ files:
210
219
  - test/perf_simple.rb
211
220
  - test/perf_strict.rb
212
221
  - test/perf_wab.rb
222
+ - test/prec.rb
213
223
  - test/sample.rb
214
224
  - test/sample/change.rb
215
225
  - test/sample/dir.rb
@@ -234,6 +244,7 @@ files:
234
244
  - test/test_integer_range.rb
235
245
  - test/test_null.rb
236
246
  - test/test_object.rb
247
+ - test/test_rails.rb
237
248
  - test/test_saj.rb
238
249
  - test/test_scp.rb
239
250
  - test/test_strict.rb
@@ -254,7 +265,7 @@ metadata:
254
265
  homepage_uri: http://www.ohler.com/oj/
255
266
  source_code_uri: https://github.com/ohler55/oj
256
267
  wiki_uri: https://github.com/ohler55/oj/wiki
257
- post_install_message:
268
+ post_install_message:
258
269
  rdoc_options:
259
270
  - "--title"
260
271
  - Oj
@@ -266,19 +277,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
266
277
  requirements:
267
278
  - - ">="
268
279
  - !ruby/object:Gem::Version
269
- version: '2.3'
280
+ version: '2.4'
270
281
  required_rubygems_version: !ruby/object:Gem::Requirement
271
282
  requirements:
272
283
  - - ">="
273
284
  - !ruby/object:Gem::Version
274
285
  version: '0'
275
286
  requirements: []
276
- rubygems_version: 3.0.3
277
- signing_key:
287
+ rubygems_version: 3.1.4
288
+ signing_key:
278
289
  specification_version: 4
279
290
  summary: A fast JSON parser and serializer.
280
291
  test_files:
281
292
  - test/foo.rb
293
+ - test/prec.rb
282
294
  - test/test_integer_range.rb
283
295
  - test/test_strict.rb
284
296
  - test/perf_strict.rb
@@ -313,6 +325,7 @@ test_files:
313
325
  - test/sample_json.rb
314
326
  - test/activesupport5/encoding_test_cases.rb
315
327
  - test/activesupport5/encoding_test.rb
328
+ - test/activesupport5/abstract_unit.rb
316
329
  - test/activesupport5/time_zone_test_helpers.rb
317
330
  - test/activesupport5/test_helper.rb
318
331
  - test/activesupport5/decoding_test.rb
@@ -341,8 +354,10 @@ test_files:
341
354
  - test/zoo.rb
342
355
  - test/activerecord/result_test.rb
343
356
  - test/_test_active_mimic.rb
357
+ - test/baz.rb
344
358
  - test/tests_mimic_addition.rb
345
359
  - test/test_writer.rb
360
+ - test/test_rails.rb
346
361
  - test/perf.rb
347
362
  - test/isolated/test_mimic_define.rb
348
363
  - test/isolated/test_mimic_after.rb
@@ -357,3 +372,10 @@ test_files:
357
372
  - test/test_gc.rb
358
373
  - test/files.rb
359
374
  - test/test_various.rb
375
+ - test/activesupport6/encoding_test_cases.rb
376
+ - test/activesupport6/encoding_test.rb
377
+ - test/activesupport6/abstract_unit.rb
378
+ - test/activesupport6/time_zone_test_helpers.rb
379
+ - test/activesupport6/test_helper.rb
380
+ - test/activesupport6/test_common.rb
381
+ - test/activesupport6/decoding_test.rb