oj 3.13.7 → 3.13.23

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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +75 -0
  3. data/README.md +11 -0
  4. data/ext/oj/buf.h +4 -0
  5. data/ext/oj/circarray.c +1 -1
  6. data/ext/oj/code.c +15 -22
  7. data/ext/oj/compat.c +10 -10
  8. data/ext/oj/custom.c +66 -112
  9. data/ext/oj/dump.c +147 -184
  10. data/ext/oj/dump.h +25 -8
  11. data/ext/oj/dump_compat.c +47 -89
  12. data/ext/oj/dump_leaf.c +14 -58
  13. data/ext/oj/dump_object.c +72 -188
  14. data/ext/oj/dump_strict.c +19 -31
  15. data/ext/oj/encoder.c +43 -0
  16. data/ext/oj/extconf.rb +5 -4
  17. data/ext/oj/fast.c +36 -24
  18. data/ext/oj/intern.c +22 -12
  19. data/ext/oj/intern.h +1 -1
  20. data/ext/oj/mimic_json.c +74 -73
  21. data/ext/oj/object.c +54 -72
  22. data/ext/oj/odd.c +83 -63
  23. data/ext/oj/odd.h +13 -13
  24. data/ext/oj/oj.c +166 -175
  25. data/ext/oj/oj.h +25 -3
  26. data/ext/oj/parse.c +123 -79
  27. data/ext/oj/parse.h +2 -0
  28. data/ext/oj/parser.c +77 -21
  29. data/ext/oj/parser.h +12 -0
  30. data/ext/oj/rails.c +46 -70
  31. data/ext/oj/rails.h +1 -1
  32. data/ext/oj/reader.c +2 -0
  33. data/ext/oj/saj.c +11 -23
  34. data/ext/oj/saj2.c +333 -85
  35. data/ext/oj/saj2.h +23 -0
  36. data/ext/oj/sparse.c +4 -0
  37. data/ext/oj/stream_writer.c +3 -1
  38. data/ext/oj/strict.c +13 -13
  39. data/ext/oj/string_writer.c +12 -5
  40. data/ext/oj/usual.c +86 -131
  41. data/ext/oj/usual.h +68 -0
  42. data/ext/oj/val_stack.c +1 -1
  43. data/ext/oj/validate.c +21 -26
  44. data/ext/oj/wab.c +22 -27
  45. data/lib/oj/saj.rb +20 -6
  46. data/lib/oj/state.rb +1 -1
  47. data/lib/oj/version.rb +1 -1
  48. data/pages/Compatibility.md +1 -1
  49. data/pages/JsonGem.md +15 -0
  50. data/pages/Modes.md +6 -3
  51. data/pages/Options.md +6 -0
  52. data/pages/Rails.md +12 -0
  53. data/test/activesupport7/abstract_unit.rb +49 -0
  54. data/test/activesupport7/decoding_test.rb +125 -0
  55. data/test/activesupport7/encoding_test.rb +486 -0
  56. data/test/activesupport7/encoding_test_cases.rb +104 -0
  57. data/test/activesupport7/time_zone_test_helpers.rb +47 -0
  58. data/test/bar.rb +3 -8
  59. data/test/bug.rb +16 -0
  60. data/test/foo.rb +71 -7
  61. data/test/helper.rb +8 -2
  62. data/test/json_gem/json_generator_test.rb +5 -4
  63. data/test/json_gem/json_parser_test.rb +8 -1
  64. data/test/json_gem/test_helper.rb +7 -3
  65. data/test/perf_dump.rb +50 -0
  66. data/test/test_compat.rb +25 -0
  67. data/test/test_custom.rb +13 -2
  68. data/test/test_fast.rb +37 -7
  69. data/test/test_file.rb +23 -7
  70. data/test/test_gc.rb +11 -0
  71. data/test/test_object.rb +8 -10
  72. data/test/test_parser.rb +3 -19
  73. data/test/test_parser_debug.rb +27 -0
  74. data/test/test_parser_saj.rb +92 -2
  75. data/test/test_saj.rb +1 -1
  76. data/test/test_scp.rb +2 -4
  77. data/test/test_strict.rb +2 -0
  78. data/test/test_various.rb +32 -2
  79. data/test/test_wab.rb +2 -0
  80. data/test/tests.rb +9 -1
  81. data/test/tests_mimic.rb +9 -0
  82. data/test/tests_mimic_addition.rb +9 -0
  83. metadata +15 -115
data/test/test_saj.rb CHANGED
@@ -180,7 +180,7 @@ class SajTest < Minitest::Test
180
180
  assert_equal([:add_value, 12345, nil], handler.calls.first)
181
181
  type, message, line, column = handler.calls.last
182
182
  assert_equal([:error, 1, 6], [type, line, column])
183
- assert_match(%r{invalid format, extra characters at line 1, column 6 \[(?:[a-z\.]+/)*saj\.c:\d+\]}, message)
183
+ assert_match(%r{invalid format, extra characters at line 1, column 6 \[(?:[A-Za-z]:\/)?(?:[a-z\.]+/)*saj\.c:\d+\]}, message)
184
184
  end
185
185
 
186
186
  end
data/test/test_scp.rb CHANGED
@@ -320,8 +320,7 @@ class ScpTest < Minitest::Test
320
320
  end
321
321
 
322
322
  def test_pipe
323
- # Windows does not support fork
324
- return if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
323
+ skip 'needs fork' unless Process.respond_to?(:fork)
325
324
 
326
325
  handler = AllHandler.new()
327
326
  json = %{{"one":true,"two":false}}
@@ -357,8 +356,7 @@ class ScpTest < Minitest::Test
357
356
  end
358
357
 
359
358
  def test_pipe_close
360
- # Windows does not support fork
361
- return if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
359
+ skip 'needs fork' unless Process.respond_to?(:fork)
362
360
 
363
361
  json = %{{"one":true,"two":false}}
364
362
  IO.pipe do |read_io, write_io|
data/test/test_strict.rb CHANGED
@@ -156,6 +156,8 @@ class StrictJuice < Minitest::Test
156
156
  end
157
157
 
158
158
  def test_deep_nest
159
+ skip 'TruffleRuby causes SEGV' if RUBY_ENGINE == 'truffleruby'
160
+
159
161
  begin
160
162
  n = 10000
161
163
  Oj.strict_load('[' * n + ']' * n)
data/test/test_various.rb CHANGED
@@ -345,6 +345,12 @@ class Juice < Minitest::Test
345
345
  out = Oj.dump hash
346
346
  assert_equal(%{{"key":"I \\u003c3 this"}}, out)
347
347
  end
348
+ def test_escapes_slashes_by_default_when_configured_to_do_so
349
+ hash = {'key' => "I <3 this </script>"}
350
+ Oj.default_options = {:escape_mode => :slash}
351
+ out = Oj.dump hash
352
+ assert_equal(%{{"key":"I <3 this <\\/script>"}}, out)
353
+ end
348
354
  def test_escapes_entities_when_asked_to
349
355
  hash = {'key' => "I <3 this"}
350
356
  out = Oj.dump(hash, :escape_mode => :xss_safe)
@@ -528,7 +534,7 @@ class Juice < Minitest::Test
528
534
  assert_equal(58, obj.y)
529
535
  end
530
536
 
531
- # Stream Deeply Nested
537
+ # Stream Deeply Nested
532
538
  def test_deep_nest_dump
533
539
  begin
534
540
  a = []
@@ -541,7 +547,7 @@ class Juice < Minitest::Test
541
547
  assert(false, "*** expected an exception")
542
548
  end
543
549
 
544
- # Stream IO
550
+ # Stream IO
545
551
  def test_io_string
546
552
  src = { 'x' => true, 'y' => 58, 'z' => [1, 2, 3]}
547
553
  output = StringIO.open("", "w+")
@@ -564,6 +570,30 @@ class Juice < Minitest::Test
564
570
  assert_equal(src, obj)
565
571
  end
566
572
 
573
+ def test_io_stream
574
+ skip 'needs fork' unless Process.respond_to?(:fork)
575
+
576
+ IO.pipe do |r, w|
577
+ if fork
578
+ r.close
579
+ #w.nonblock = false
580
+ a = []
581
+ 10_000.times do |i|
582
+ a << i
583
+ end
584
+ Oj.to_stream(w, a, indent: 2)
585
+ w.close
586
+ else
587
+ w.close
588
+ sleep(0.1) # to force a busy
589
+ cnt = 0
590
+ r.each_line { cnt += 1 }
591
+ r.close
592
+ Process.exit(0)
593
+ end
594
+ end
595
+ end
596
+
567
597
  # comments
568
598
  def test_comment_slash
569
599
  json = %{{
data/test/test_wab.rb CHANGED
@@ -105,6 +105,8 @@ class WabJuice < Minitest::Test
105
105
  end
106
106
 
107
107
  def test_deep_nest
108
+ skip 'TruffleRuby causes SEGV' if RUBY_ENGINE == 'truffleruby'
109
+
108
110
  begin
109
111
  n = 10000
110
112
  Oj.wab_load('[' * n + ']' * n)
data/test/tests.rb CHANGED
@@ -18,8 +18,16 @@ require 'test_object'
18
18
  require 'test_saj'
19
19
  require 'test_scp'
20
20
  require 'test_strict'
21
- require 'test_various'
22
21
  require 'test_rails'
23
22
  require 'test_wab'
24
23
  require 'test_writer'
25
24
  require 'test_integer_range'
25
+
26
+ at_exit do
27
+ require 'helper'
28
+ if '3.1.0' <= RUBY_VERSION && !(RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/)
29
+ #Oj::debug_odd("teardown before GC.verify_compaction_references")
30
+ verify_gc_compaction
31
+ #Oj::debug_odd("teardown after GC.verify_compaction_references")
32
+ end
33
+ end
data/test/tests_mimic.rb CHANGED
@@ -12,3 +12,12 @@ require 'json_generator_test'
12
12
  require 'json_generic_object_test'
13
13
  require 'json_parser_test'
14
14
  require 'json_string_matching_test'
15
+
16
+ at_exit do
17
+ require 'helper'
18
+ if '3.1.0' <= RUBY_VERSION && !(RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/)
19
+ #Oj::debug_odd("teardown before GC.verify_compaction_references")
20
+ verify_gc_compaction
21
+ #Oj::debug_odd("teardown after GC.verify_compaction_references")
22
+ end
23
+ end
@@ -5,3 +5,12 @@ $: << File.dirname(__FILE__)
5
5
  $: << File.join(File.dirname(__FILE__), 'json_gem')
6
6
 
7
7
  require 'json_addition_test'
8
+
9
+ at_exit do
10
+ require 'helper'
11
+ if '3.1.0' <= RUBY_VERSION && !(RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/)
12
+ #Oj::debug_odd("teardown before GC.verify_compaction_references")
13
+ verify_gc_compaction
14
+ #Oj::debug_odd("teardown after GC.verify_compaction_references")
15
+ end
16
+ end
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.13.7
4
+ version: 3.13.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-16 00:00:00.000000000 Z
11
+ date: 2022-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -58,20 +58,6 @@ dependencies:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '3.0'
61
- - !ruby/object:Gem::Dependency
62
- name: wwtd
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '0'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
61
  description: The fastest JSON parser and object serializer.
76
62
  email: peter@ohler.com
77
63
  executables: []
@@ -117,6 +103,7 @@ files:
117
103
  - ext/oj/dump_object.c
118
104
  - ext/oj/dump_strict.c
119
105
  - ext/oj/encode.h
106
+ - ext/oj/encoder.c
120
107
  - ext/oj/err.c
121
108
  - ext/oj/err.h
122
109
  - ext/oj/extconf.rb
@@ -143,6 +130,7 @@ files:
143
130
  - ext/oj/rxclass.h
144
131
  - ext/oj/saj.c
145
132
  - ext/oj/saj2.c
133
+ - ext/oj/saj2.h
146
134
  - ext/oj/scp.c
147
135
  - ext/oj/sparse.c
148
136
  - ext/oj/stream_writer.c
@@ -151,6 +139,7 @@ files:
151
139
  - ext/oj/trace.c
152
140
  - ext/oj/trace.h
153
141
  - ext/oj/usual.c
142
+ - ext/oj/usual.h
154
143
  - ext/oj/util.c
155
144
  - ext/oj/util.h
156
145
  - ext/oj/val_stack.c
@@ -199,8 +188,14 @@ files:
199
188
  - test/activesupport6/test_common.rb
200
189
  - test/activesupport6/test_helper.rb
201
190
  - test/activesupport6/time_zone_test_helpers.rb
191
+ - test/activesupport7/abstract_unit.rb
192
+ - test/activesupport7/decoding_test.rb
193
+ - test/activesupport7/encoding_test.rb
194
+ - test/activesupport7/encoding_test_cases.rb
195
+ - test/activesupport7/time_zone_test_helpers.rb
202
196
  - test/bar.rb
203
197
  - test/baz.rb
198
+ - test/bug.rb
204
199
  - test/files.rb
205
200
  - test/foo.rb
206
201
  - test/helper.rb
@@ -226,6 +221,7 @@ files:
226
221
  - test/mem.rb
227
222
  - test/perf.rb
228
223
  - test/perf_compat.rb
224
+ - test/perf_dump.rb
229
225
  - test/perf_fast.rb
230
226
  - test/perf_file.rb
231
227
  - test/perf_object.rb
@@ -263,6 +259,7 @@ files:
263
259
  - test/test_null.rb
264
260
  - test/test_object.rb
265
261
  - test/test_parser.rb
262
+ - test/test_parser_debug.rb
266
263
  - test/test_parser_saj.rb
267
264
  - test/test_parser_usual.rb
268
265
  - test/test_rails.rb
@@ -305,105 +302,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
305
302
  - !ruby/object:Gem::Version
306
303
  version: '0'
307
304
  requirements: []
308
- rubygems_version: 3.2.22
305
+ rubygems_version: 3.3.3
309
306
  signing_key:
310
307
  specification_version: 4
311
308
  summary: A fast JSON parser and serializer.
312
- test_files:
313
- - test/_test_active.rb
314
- - test/_test_active_mimic.rb
315
- - test/_test_mimic_rails.rb
316
- - test/activerecord/result_test.rb
317
- - test/activesupport4/decoding_test.rb
318
- - test/activesupport4/encoding_test.rb
319
- - test/activesupport4/test_helper.rb
320
- - test/activesupport5/abstract_unit.rb
321
- - test/activesupport5/decoding_test.rb
322
- - test/activesupport5/encoding_test.rb
323
- - test/activesupport5/encoding_test_cases.rb
324
- - test/activesupport5/test_helper.rb
325
- - test/activesupport5/time_zone_test_helpers.rb
326
- - test/activesupport6/abstract_unit.rb
327
- - test/activesupport6/decoding_test.rb
328
- - test/activesupport6/encoding_test.rb
329
- - test/activesupport6/encoding_test_cases.rb
330
- - test/activesupport6/test_common.rb
331
- - test/activesupport6/test_helper.rb
332
- - test/activesupport6/time_zone_test_helpers.rb
333
- - test/bar.rb
334
- - test/baz.rb
335
- - test/files.rb
336
- - test/foo.rb
337
- - test/helper.rb
338
- - test/isolated/shared.rb
339
- - test/isolated/test_mimic_after.rb
340
- - test/isolated/test_mimic_alone.rb
341
- - test/isolated/test_mimic_as_json.rb
342
- - test/isolated/test_mimic_before.rb
343
- - test/isolated/test_mimic_define.rb
344
- - test/isolated/test_mimic_rails_after.rb
345
- - test/isolated/test_mimic_rails_before.rb
346
- - test/isolated/test_mimic_redefine.rb
347
- - test/json_gem/json_addition_test.rb
348
- - test/json_gem/json_common_interface_test.rb
349
- - test/json_gem/json_encoding_test.rb
350
- - test/json_gem/json_ext_parser_test.rb
351
- - test/json_gem/json_fixtures_test.rb
352
- - test/json_gem/json_generator_test.rb
353
- - test/json_gem/json_generic_object_test.rb
354
- - test/json_gem/json_parser_test.rb
355
- - test/json_gem/json_string_matching_test.rb
356
- - test/json_gem/test_helper.rb
357
- - test/mem.rb
358
- - test/perf.rb
359
- - test/perf_compat.rb
360
- - test/perf_fast.rb
361
- - test/perf_file.rb
362
- - test/perf_object.rb
363
- - test/perf_once.rb
364
- - test/perf_parser.rb
365
- - test/perf_saj.rb
366
- - test/perf_scp.rb
367
- - test/perf_simple.rb
368
- - test/perf_strict.rb
369
- - test/perf_wab.rb
370
- - test/prec.rb
371
- - test/sample/change.rb
372
- - test/sample/dir.rb
373
- - test/sample/doc.rb
374
- - test/sample/file.rb
375
- - test/sample/group.rb
376
- - test/sample/hasprops.rb
377
- - test/sample/layer.rb
378
- - test/sample/line.rb
379
- - test/sample/oval.rb
380
- - test/sample/rect.rb
381
- - test/sample/shape.rb
382
- - test/sample/text.rb
383
- - test/sample.rb
384
- - test/sample_json.rb
385
- - test/test_compat.rb
386
- - test/test_custom.rb
387
- - test/test_debian.rb
388
- - test/test_fast.rb
389
- - test/test_file.rb
390
- - test/test_gc.rb
391
- - test/test_generate.rb
392
- - test/test_hash.rb
393
- - test/test_integer_range.rb
394
- - test/test_null.rb
395
- - test/test_object.rb
396
- - test/test_parser.rb
397
- - test/test_parser_saj.rb
398
- - test/test_parser_usual.rb
399
- - test/test_rails.rb
400
- - test/test_saj.rb
401
- - test/test_scp.rb
402
- - test/test_strict.rb
403
- - test/test_various.rb
404
- - test/test_wab.rb
405
- - test/test_writer.rb
406
- - test/tests.rb
407
- - test/tests_mimic.rb
408
- - test/tests_mimic_addition.rb
409
- - test/zoo.rb
309
+ test_files: []