oj 3.14.2 → 3.15.0

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 (150) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -1
  3. data/README.md +0 -1
  4. data/ext/oj/buf.h +2 -2
  5. data/ext/oj/cache.c +16 -16
  6. data/ext/oj/cache8.c +7 -7
  7. data/ext/oj/circarray.c +2 -1
  8. data/ext/oj/circarray.h +2 -2
  9. data/ext/oj/code.c +2 -2
  10. data/ext/oj/code.h +2 -2
  11. data/ext/oj/compat.c +6 -14
  12. data/ext/oj/custom.c +6 -16
  13. data/ext/oj/debug.c +3 -9
  14. data/ext/oj/dump.c +43 -18
  15. data/ext/oj/dump_compat.c +551 -576
  16. data/ext/oj/dump_leaf.c +3 -5
  17. data/ext/oj/dump_object.c +35 -36
  18. data/ext/oj/dump_strict.c +2 -4
  19. data/ext/oj/encoder.c +1 -1
  20. data/ext/oj/err.c +2 -13
  21. data/ext/oj/err.h +9 -12
  22. data/ext/oj/extconf.rb +1 -1
  23. data/ext/oj/fast.c +24 -38
  24. data/ext/oj/intern.c +38 -42
  25. data/ext/oj/intern.h +3 -7
  26. data/ext/oj/mem.c +211 -217
  27. data/ext/oj/mem.h +10 -10
  28. data/ext/oj/mimic_json.c +39 -24
  29. data/ext/oj/object.c +12 -26
  30. data/ext/oj/odd.c +2 -1
  31. data/ext/oj/odd.h +4 -4
  32. data/ext/oj/oj.c +80 -81
  33. data/ext/oj/oj.h +56 -54
  34. data/ext/oj/parse.c +55 -118
  35. data/ext/oj/parse.h +5 -10
  36. data/ext/oj/parser.c +7 -8
  37. data/ext/oj/parser.h +7 -8
  38. data/ext/oj/rails.c +28 -59
  39. data/ext/oj/reader.c +5 -9
  40. data/ext/oj/reader.h +1 -1
  41. data/ext/oj/resolve.c +3 -4
  42. data/ext/oj/rxclass.c +1 -1
  43. data/ext/oj/rxclass.h +1 -1
  44. data/ext/oj/saj.c +4 -4
  45. data/ext/oj/saj2.c +32 -49
  46. data/ext/oj/saj2.h +1 -1
  47. data/ext/oj/scp.c +3 -14
  48. data/ext/oj/sparse.c +18 -67
  49. data/ext/oj/stream_writer.c +5 -18
  50. data/ext/oj/strict.c +16 -40
  51. data/ext/oj/string_writer.c +6 -14
  52. data/ext/oj/trace.h +27 -16
  53. data/ext/oj/usual.c +62 -61
  54. data/ext/oj/usual.h +6 -6
  55. data/ext/oj/util.h +1 -1
  56. data/ext/oj/val_stack.h +4 -4
  57. data/ext/oj/wab.c +16 -36
  58. data/lib/oj/active_support_helper.rb +0 -1
  59. data/lib/oj/bag.rb +7 -1
  60. data/lib/oj/easy_hash.rb +4 -5
  61. data/lib/oj/error.rb +0 -1
  62. data/lib/oj/json.rb +4 -2
  63. data/lib/oj/mimic.rb +4 -2
  64. data/lib/oj/state.rb +8 -5
  65. data/lib/oj/version.rb +1 -2
  66. data/lib/oj.rb +2 -0
  67. data/pages/Options.md +4 -0
  68. data/test/_test_active.rb +8 -9
  69. data/test/_test_active_mimic.rb +7 -8
  70. data/test/_test_mimic_rails.rb +17 -20
  71. data/test/activerecord/result_test.rb +5 -6
  72. data/test/files.rb +15 -15
  73. data/test/foo.rb +9 -52
  74. data/test/helper.rb +5 -8
  75. data/test/isolated/shared.rb +3 -2
  76. data/test/json_gem/json_addition_test.rb +2 -2
  77. data/test/json_gem/json_common_interface_test.rb +4 -4
  78. data/test/json_gem/json_encoding_test.rb +0 -0
  79. data/test/json_gem/json_ext_parser_test.rb +1 -0
  80. data/test/json_gem/json_fixtures_test.rb +3 -2
  81. data/test/json_gem/json_generator_test.rb +43 -32
  82. data/test/json_gem/json_generic_object_test.rb +11 -11
  83. data/test/json_gem/json_parser_test.rb +46 -46
  84. data/test/json_gem/json_string_matching_test.rb +9 -9
  85. data/test/mem.rb +13 -12
  86. data/test/perf.rb +21 -26
  87. data/test/perf_compat.rb +31 -33
  88. data/test/perf_dump.rb +25 -25
  89. data/test/perf_fast.rb +80 -82
  90. data/test/perf_file.rb +27 -29
  91. data/test/perf_object.rb +65 -69
  92. data/test/perf_once.rb +12 -11
  93. data/test/perf_parser.rb +41 -48
  94. data/test/perf_saj.rb +46 -54
  95. data/test/perf_scp.rb +57 -69
  96. data/test/perf_simple.rb +41 -39
  97. data/test/perf_strict.rb +68 -70
  98. data/test/perf_wab.rb +67 -69
  99. data/test/prec.rb +3 -3
  100. data/test/sample/change.rb +0 -1
  101. data/test/sample/dir.rb +0 -1
  102. data/test/sample/doc.rb +0 -1
  103. data/test/sample/file.rb +0 -1
  104. data/test/sample/group.rb +0 -1
  105. data/test/sample/hasprops.rb +0 -1
  106. data/test/sample/layer.rb +0 -1
  107. data/test/sample/rect.rb +0 -1
  108. data/test/sample/shape.rb +0 -1
  109. data/test/sample/text.rb +0 -1
  110. data/test/sample.rb +16 -16
  111. data/test/sample_json.rb +8 -8
  112. data/test/test_compat.rb +52 -52
  113. data/test/test_custom.rb +61 -51
  114. data/test/test_debian.rb +7 -10
  115. data/test/test_fast.rb +86 -90
  116. data/test/test_file.rb +24 -29
  117. data/test/test_gc.rb +5 -5
  118. data/test/test_generate.rb +5 -5
  119. data/test/test_hash.rb +4 -4
  120. data/test/test_integer_range.rb +9 -9
  121. data/test/test_null.rb +20 -20
  122. data/test/test_object.rb +78 -87
  123. data/test/test_parser.rb +4 -4
  124. data/test/test_parser_debug.rb +4 -4
  125. data/test/test_parser_saj.rb +27 -25
  126. data/test/test_parser_usual.rb +6 -6
  127. data/test/test_rails.rb +2 -2
  128. data/test/test_saj.rb +10 -8
  129. data/test/test_scp.rb +35 -35
  130. data/test/test_strict.rb +28 -32
  131. data/test/test_various.rb +140 -97
  132. data/test/test_wab.rb +46 -44
  133. data/test/test_writer.rb +47 -47
  134. data/test/tests.rb +7 -7
  135. data/test/tests_mimic.rb +6 -6
  136. data/test/tests_mimic_addition.rb +6 -6
  137. metadata +18 -30
  138. data/test/activesupport4/decoding_test.rb +0 -108
  139. data/test/activesupport4/encoding_test.rb +0 -531
  140. data/test/activesupport4/test_helper.rb +0 -41
  141. data/test/activesupport5/abstract_unit.rb +0 -45
  142. data/test/activesupport5/decoding_test.rb +0 -133
  143. data/test/activesupport5/encoding_test.rb +0 -500
  144. data/test/activesupport5/encoding_test_cases.rb +0 -98
  145. data/test/activesupport5/test_helper.rb +0 -72
  146. data/test/activesupport5/time_zone_test_helpers.rb +0 -39
  147. data/test/bar.rb +0 -11
  148. data/test/baz.rb +0 -16
  149. data/test/bug.rb +0 -16
  150. data/test/zoo.rb +0 -13
data/test/test_wab.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: UTF-8
2
+ # frozen_string_literal: true
3
3
 
4
- $: << File.dirname(__FILE__)
5
- $oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
4
+ $LOAD_PATH << __dir__
5
+ @oj_dir = File.dirname(File.expand_path(__dir__))
6
6
  %w(lib ext).each do |dir|
7
- $: << File.join($oj_dir, dir)
7
+ $LOAD_PATH << File.join(@oj_dir, dir)
8
8
  end
9
9
 
10
10
  require 'minitest'
@@ -19,20 +19,22 @@ require 'oj'
19
19
  module WAB
20
20
  class UUID
21
21
  attr_reader :id
22
+
22
23
  def initialize(id)
23
24
  @id = id.downcase
24
- raise Exception.new("Invalid UUID format.") if /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.match(@id).nil?
25
+ raise StandardError.new('Invalid UUID format.') if /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.match(@id).nil?
25
26
  end
27
+
26
28
  def to_s
27
29
  @id
28
30
  end
31
+
29
32
  def ==(other)
30
33
  other.is_a?(self.class) && @id == other.id
31
34
  end
32
35
  end # UUID
33
36
  end # WAB
34
37
 
35
-
36
38
  class WabJuice < Minitest::Test
37
39
 
38
40
  module TestModule
@@ -52,16 +54,16 @@ class WabJuice < Minitest::Test
52
54
 
53
55
  def test_fixnum
54
56
  dump_and_load(0, false)
55
- dump_and_load(12345, false)
56
- dump_and_load(-54321, false)
57
+ dump_and_load(12_345, false)
58
+ dump_and_load(-54_321, false)
57
59
  dump_and_load(1, false)
58
60
  end
59
61
 
60
62
  def test_float
61
63
  dump_and_load(0.0, false)
62
- dump_and_load(12345.6789, false)
64
+ dump_and_load(12_345.6789, false)
63
65
  dump_and_load(70.35, false)
64
- dump_and_load(-54321.012, false)
66
+ dump_and_load(-54_321.012, false)
65
67
  dump_and_load(1.7775, false)
66
68
  dump_and_load(2.5024, false)
67
69
  dump_and_load(2.48e16, false)
@@ -89,7 +91,7 @@ class WabJuice < Minitest::Test
89
91
  end
90
92
 
91
93
  def test_encode
92
- dump_and_load("ぴーたー", false)
94
+ dump_and_load('ぴーたー', false)
93
95
  end
94
96
 
95
97
  def test_array
@@ -101,25 +103,25 @@ class WabJuice < Minitest::Test
101
103
  end
102
104
 
103
105
  def test_array_deep
104
- dump_and_load([1,[2,[3,[4,[5,[6,[7,[8,[9,[10,[11,[12,[13,[14,[15,[16,[17,[18,[19,[20]]]]]]]]]]]]]]]]]]]], false)
106
+ dump_and_load([1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12, [13, [14, [15, [16, [17, [18, [19, [20]]]]]]]]]]]]]]]]]]]], false)
105
107
  end
106
108
 
107
109
  def test_deep_nest
108
110
  skip 'TruffleRuby causes SEGV' if RUBY_ENGINE == 'truffleruby'
109
111
 
110
112
  begin
111
- n = 10000
112
- Oj.wab_load('[' * n + ']' * n)
113
+ n = 10_000
114
+ Oj.wab_load(('[' * n) + (']' * n))
113
115
  rescue Exception => e
114
- assert(false, e.message)
116
+ refute(e.message)
115
117
  end
116
118
  end
117
119
 
118
120
  # Hash
119
121
  def test_hash
120
122
  dump_and_load({}, false)
121
- dump_and_load({ true: true, false: false}, false)
122
- dump_and_load({ true: true, array: [], hash: { }}, false)
123
+ dump_and_load({ tru: true, fals: false}, false)
124
+ dump_and_load({ tru: true, array: [], hash: {}}, false)
123
125
  end
124
126
 
125
127
  def test_hash_non_sym_keys
@@ -128,25 +130,25 @@ class WabJuice < Minitest::Test
128
130
 
129
131
  def test_hash_deep
130
132
  dump_and_load({x1: {
131
- x2: {
132
- x3: {
133
- x4: {
134
- x5: {
135
- x6: {
136
- x7: {
137
- x8: {
138
- x9: {
139
- x10: {
140
- x11: {
141
- x12: {
142
- x13: {
143
- x14: {
144
- x15: {
145
- x16: {
146
- x17: {
147
- x18: {
148
- x19: {
149
- x20: {}}}}}}}}}}}}}}}}}}}}}, false)
133
+ x2: {
134
+ x3: {
135
+ x4: {
136
+ x5: {
137
+ x6: {
138
+ x7: {
139
+ x8: {
140
+ x9: {
141
+ x10: {
142
+ x11: {
143
+ x12: {
144
+ x13: {
145
+ x14: {
146
+ x15: {
147
+ x16: {
148
+ x17: {
149
+ x18: {
150
+ x19: {
151
+ x20: {}}}}}}}}}}}}}}}}}}}}}, false)
150
152
  end
151
153
 
152
154
  def test_non_str_hash
@@ -154,7 +156,7 @@ class WabJuice < Minitest::Test
154
156
  end
155
157
 
156
158
  def test_bignum_object
157
- dump_and_load(7 ** 55, false)
159
+ dump_and_load(7**55, false)
158
160
  end
159
161
 
160
162
  # BigDecimal
@@ -188,13 +190,13 @@ class WabJuice < Minitest::Test
188
190
  end
189
191
 
190
192
  def test_io_file
191
- filename = File.join(File.dirname(__FILE__), 'open_file_test.json')
192
- File.open(filename, 'w') { |f| f.write(%{{
193
+ filename = File.join(__dir__, 'open_file_test.json')
194
+ File.write(filename, %{{
193
195
  "x":true,
194
196
  "y":58,
195
197
  "z": [1,2,3]
196
198
  }
197
- }) }
199
+ })
198
200
  f = File.new(filename)
199
201
  obj = Oj.wab_load(f)
200
202
  f.close()
@@ -207,13 +209,13 @@ class WabJuice < Minitest::Test
207
209
  end
208
210
 
209
211
  def test_time
210
- t = Time.gm(2017, 1, 5, 23, 58, 7, 123456.789)
212
+ t = Time.gm(2017, 1, 5, 23, 58, 7, 123_456.789)
211
213
  json = Oj.dump(t, mode: :wab)
212
214
  assert_equal('"2017-01-05T23:58:07.123456789Z"', json)
213
215
  # must load and convert to json as the Time#== does not match identical
214
216
  # times due to the way it tracks fractional seconds.
215
- loaded = Oj.wab_load(json);
216
- assert_equal(json, Oj.dump(loaded, mode: :wab), "json mismatch after load")
217
+ loaded = Oj.wab_load(json)
218
+ assert_equal(json, Oj.dump(loaded, mode: :wab), 'json mismatch after load')
217
219
  end
218
220
 
219
221
  def test_uuid
@@ -297,7 +299,7 @@ class WabJuice < Minitest::Test
297
299
  def dump_and_load(obj, trace=false)
298
300
  json = Oj.dump(obj, mode: :wab, indent: 2)
299
301
  puts json if trace
300
- loaded = Oj.wab_load(json);
302
+ loaded = Oj.wab_load(json)
301
303
  if obj.nil?
302
304
  assert_nil(loaded)
303
305
  else
data/test/test_writer.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+ # frozen_string_literal: false
3
3
 
4
- $: << File.dirname(__FILE__)
4
+ $LOAD_PATH << __dir__
5
5
 
6
6
  require 'helper'
7
7
 
@@ -55,13 +55,13 @@ class OjWriter < Minitest::Test
55
55
  def test_string_writer_nested_object
56
56
  w = Oj::StringWriter.new(:indent => 0)
57
57
  w.push_object()
58
- w.push_object("a1")
58
+ w.push_object('a1')
59
59
  w.pop()
60
- w.push_object("a2")
61
- w.push_object("b")
60
+ w.push_object('a2')
61
+ w.push_object('b')
62
62
  w.pop()
63
63
  w.pop()
64
- w.push_object("a3")
64
+ w.push_object('a3')
65
65
  w.pop()
66
66
  w.pop()
67
67
  assert_equal(%|{"a1":{},"a2":{"b":{}},"a3":{}}\n|, w.to_s)
@@ -94,9 +94,9 @@ class OjWriter < Minitest::Test
94
94
  w.push_value(7.3)
95
95
  w.push_value(true)
96
96
  w.push_value(nil)
97
- w.push_value("a string")
97
+ w.push_value('a string')
98
98
  w.push_value({'a' => 65})
99
- w.push_value([1,2])
99
+ w.push_value([1, 2])
100
100
  w.pop()
101
101
  assert_equal(%|[
102
102
  7,
@@ -118,10 +118,10 @@ class OjWriter < Minitest::Test
118
118
  def test_string_writer_block
119
119
  w = Oj::StringWriter.new(:indent => 0)
120
120
  w.push_object() {
121
- w.push_object("a1") {
121
+ w.push_object('a1') {
122
122
  w.push_value(7, 'a7')
123
123
  }
124
- w.push_array("a2") {
124
+ w.push_array('a2') {
125
125
  w.push_value('x')
126
126
  w.push_value(3)
127
127
  }
@@ -152,7 +152,7 @@ class OjWriter < Minitest::Test
152
152
  assert(true)
153
153
  return
154
154
  end
155
- assert(false, "*** expected an exception")
155
+ assert(false, '*** expected an exception')
156
156
  end
157
157
 
158
158
  def test_string_writer_array_key
@@ -166,7 +166,7 @@ class OjWriter < Minitest::Test
166
166
  assert(true)
167
167
  return
168
168
  end
169
- assert(false, "*** expected an exception")
169
+ assert(false, '*** expected an exception')
170
170
  end
171
171
 
172
172
  def test_string_writer_pop_with_key
@@ -177,7 +177,7 @@ class OjWriter < Minitest::Test
177
177
  assert(true)
178
178
  return
179
179
  end
180
- assert(false, "*** expected an exception")
180
+ assert(false, '*** expected an exception')
181
181
  end
182
182
 
183
183
  def test_string_writer_obj_no_key
@@ -189,7 +189,7 @@ class OjWriter < Minitest::Test
189
189
  assert(true)
190
190
  return
191
191
  end
192
- assert(false, "*** expected an exception")
192
+ assert(false, '*** expected an exception')
193
193
  end
194
194
 
195
195
  def test_string_writer_deep
@@ -208,9 +208,9 @@ class OjWriter < Minitest::Test
208
208
  def test_string_writer_pop_all
209
209
  w = Oj::StringWriter.new(:indent => 0)
210
210
  w.push_object()
211
- w.push_object("a1")
211
+ w.push_object('a1')
212
212
  w.pop()
213
- w.push_array("a2")
213
+ w.push_array('a2')
214
214
  w.push_value(3)
215
215
  w.push_array()
216
216
  w.pop_all()
@@ -228,23 +228,23 @@ class OjWriter < Minitest::Test
228
228
  # Stream Writer
229
229
 
230
230
  class SString < ::String
231
- alias :write :concat
231
+ alias write concat
232
232
  end
233
-
233
+
234
234
  def test_stream_writer_encoding
235
235
  output = SString.new.force_encoding(::Encoding::UTF_8)
236
236
  w = Oj::StreamWriter.new(output, :indent => 0)
237
237
  # Oddly enough, when pushing ASCII characters with UTF-8 encoding or even
238
238
  # ASCII-8BIT does not change the output encoding. Pushing any non-ASCII no
239
239
  # matter what the encoding changes the output encoding to ASCII-8BIT.
240
- x = "香港" # Hong Kong
240
+ x = '香港' # Hong Kong
241
241
  x = x.force_encoding('ASCII-8BIT')
242
242
  w.push_value(x)
243
243
  assert_equal(::Encoding::UTF_8, output.encoding)
244
244
  end
245
245
 
246
246
  def test_stream_writer_empty_array
247
- output = StringIO.open("", "w+")
247
+ output = StringIO.open('', 'w+')
248
248
  w = Oj::StreamWriter.new(output, :indent => 0)
249
249
  w.push_array()
250
250
  w.pop()
@@ -252,19 +252,19 @@ class OjWriter < Minitest::Test
252
252
  end
253
253
 
254
254
  def test_stream_writer_mixed_stringio
255
- output = StringIO.open("", "w+")
255
+ output = StringIO.open('', 'w+')
256
256
  w = Oj::StreamWriter.new(output, :indent => 0)
257
257
  w.push_object()
258
- w.push_object("a1")
258
+ w.push_object('a1')
259
259
  w.pop()
260
- w.push_object("a2")
261
- w.push_array("b")
260
+ w.push_object('a2')
261
+ w.push_array('b')
262
262
  w.push_value(7)
263
263
  w.push_value(true)
264
- w.push_value("string")
264
+ w.push_value('string')
265
265
  w.pop()
266
266
  w.pop()
267
- w.push_object("a3")
267
+ w.push_object('a3')
268
268
  w.pop()
269
269
  w.pop()
270
270
  result = output.string()
@@ -272,20 +272,20 @@ class OjWriter < Minitest::Test
272
272
  end
273
273
 
274
274
  def test_stream_writer_mixed_file
275
- filename = File.join(File.dirname(__FILE__), 'open_file_test.json')
276
- File.open(filename, "w") do |f|
275
+ filename = File.join(__dir__, 'open_file_test.json')
276
+ File.open(filename, 'w') do |f|
277
277
  w = Oj::StreamWriter.new(f, :indent => 0)
278
278
  w.push_object()
279
- w.push_object("a1")
279
+ w.push_object('a1')
280
280
  w.pop()
281
- w.push_object("a2")
282
- w.push_array("b")
281
+ w.push_object('a2')
282
+ w.push_array('b')
283
283
  w.push_value(7)
284
284
  w.push_value(true)
285
- w.push_value("string")
285
+ w.push_value('string')
286
286
  w.pop()
287
287
  w.pop()
288
- w.push_object("a3")
288
+ w.push_object('a3')
289
289
  w.pop()
290
290
  w.pop()
291
291
  end
@@ -294,7 +294,7 @@ class OjWriter < Minitest::Test
294
294
  end
295
295
 
296
296
  def test_stream_writer_nested_key_object
297
- output = StringIO.open("", "w+")
297
+ output = StringIO.open('', 'w+')
298
298
  w = Oj::StreamWriter.new(output, :indent => 0)
299
299
  w.push_object()
300
300
  w.push_key('a1')
@@ -316,16 +316,16 @@ class OjWriter < Minitest::Test
316
316
 
317
317
  def push_stuff(w, pop_all=true)
318
318
  w.push_object()
319
- w.push_object("a1")
319
+ w.push_object('a1')
320
320
  w.pop()
321
- w.push_object("a2")
322
- w.push_array("b")
321
+ w.push_object('a2')
322
+ w.push_array('b')
323
323
  w.push_value(7)
324
324
  w.push_value(true)
325
- w.push_value("string")
325
+ w.push_value('string')
326
326
  w.pop()
327
327
  w.pop()
328
- w.push_object("a3")
328
+ w.push_object('a3')
329
329
  if pop_all
330
330
  w.pop_all()
331
331
  else
@@ -335,31 +335,31 @@ class OjWriter < Minitest::Test
335
335
  end
336
336
 
337
337
  def test_stream_writer_buf_small
338
- output = StringIO.open("", "w+")
338
+ output = StringIO.open('', 'w+')
339
339
  w = Oj::StreamWriter.new(output, :indent => 0, :buffer_size => 20)
340
340
  push_stuff(w)
341
341
  assert_equal(%|{"a1":{},"a2":{"b":[7,true,"string"]},"a3":{}}\n|, output.string())
342
342
  end
343
343
 
344
344
  def test_stream_writer_buf_large
345
- output = StringIO.open("", "w+")
346
- w = Oj::StreamWriter.new(output, :indent => 0, :buffer_size => 16000)
345
+ output = StringIO.open('', 'w+')
346
+ w = Oj::StreamWriter.new(output, :indent => 0, :buffer_size => 16_000)
347
347
  push_stuff(w)
348
348
  assert_equal(%|{"a1":{},"a2":{"b":[7,true,"string"]},"a3":{}}\n|, output.string())
349
349
  end
350
350
 
351
351
  def test_stream_writer_buf_flush
352
- output = StringIO.open("", "w+")
352
+ output = StringIO.open('', 'w+')
353
353
  w = Oj::StreamWriter.new(output, :indent => 0, :buffer_size => 4096)
354
354
  push_stuff(w, false)
355
355
  # no flush so nothing should be in the output yet
356
- assert_equal("", output.string())
356
+ assert_equal('', output.string())
357
357
  w.flush()
358
358
  assert_equal(%|{"a1":{},"a2":{"b":[7,true,"string"]},"a3":{}}\n|, output.string())
359
359
  end
360
-
360
+
361
361
  def test_stream_writer_buf_flush_small
362
- output = StringIO.open("", "w+")
362
+ output = StringIO.open('', 'w+')
363
363
  w = Oj::StreamWriter.new(output, :indent => 0, :buffer_size => 30)
364
364
  push_stuff(w, false)
365
365
  # flush should be called at 30 bytes but since the writes are chunky flush
@@ -370,7 +370,7 @@ class OjWriter < Minitest::Test
370
370
  end
371
371
 
372
372
  def test_stream_writer_push_null_value_with_key
373
- output = StringIO.open("", "w+")
373
+ output = StringIO.open('', 'w+')
374
374
  w = Oj::StreamWriter.new(output, :indent => 0)
375
375
  w.push_object()
376
376
  w.push_value(nil, 'nothing')
data/test/tests.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: UTF-8
2
+ # frozen_string_literal: true
3
3
 
4
- $: << File.dirname(__FILE__)
5
- $oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
4
+ $LOAD_PATH << __dir__
5
+ @oj_dir = File.dirname(File.expand_path(__dir__))
6
6
  %w(lib ext).each do |dir|
7
- $: << File.join($oj_dir, dir)
7
+ $LOAD_PATH << File.join(@oj_dir, dir)
8
8
  end
9
9
 
10
10
  require 'test_compat'
@@ -25,9 +25,9 @@ require 'test_integer_range'
25
25
 
26
26
  at_exit do
27
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")
28
+ if '3.1.0' <= RUBY_VERSION && RbConfig::CONFIG['host_os'] !~ /(mingw|mswin)/
29
+ # Oj::debug_odd("teardown before GC.verify_compaction_references")
30
30
  verify_gc_compaction
31
- #Oj::debug_odd("teardown after GC.verify_compaction_references")
31
+ # Oj::debug_odd("teardown after GC.verify_compaction_references")
32
32
  end
33
33
  end
data/test/tests_mimic.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: UTF-8
2
+ # frozen_string_literal: true
3
3
 
4
- $: << File.dirname(__FILE__)
5
- $: << File.join(File.dirname(__FILE__), 'json_gem')
4
+ $LOAD_PATH << __dir__
5
+ $LOAD_PATH << File.join(__dir__, 'json_gem')
6
6
 
7
7
  require 'json_common_interface_test'
8
8
  require 'json_encoding_test'
@@ -15,9 +15,9 @@ require 'json_string_matching_test'
15
15
 
16
16
  at_exit do
17
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")
18
+ if '3.1.0' <= RUBY_VERSION && RbConfig::CONFIG['host_os'] !~ /(mingw|mswin)/
19
+ # Oj::debug_odd("teardown before GC.verify_compaction_references")
20
20
  verify_gc_compaction
21
- #Oj::debug_odd("teardown after GC.verify_compaction_references")
21
+ # Oj::debug_odd("teardown after GC.verify_compaction_references")
22
22
  end
23
23
  end
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: UTF-8
2
+ # frozen_string_literal: true
3
3
 
4
- $: << File.dirname(__FILE__)
5
- $: << File.join(File.dirname(__FILE__), 'json_gem')
4
+ $LOAD_PATH << __dir__
5
+ $LOAD_PATH << File.join(__dir__, 'json_gem')
6
6
 
7
7
  require 'json_addition_test'
8
8
 
9
9
  at_exit do
10
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")
11
+ if '3.1.0' <= RUBY_VERSION && RbConfig::CONFIG['host_os'] !~ /(mingw|mswin)/
12
+ # Oj::debug_odd("teardown before GC.verify_compaction_references")
13
13
  verify_gc_compaction
14
- #Oj::debug_odd("teardown after GC.verify_compaction_references")
14
+ # Oj::debug_odd("teardown after GC.verify_compaction_references")
15
15
  end
16
16
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.14.2
4
+ version: 3.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-10 00:00:00.000000000 Z
11
+ date: 2023-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rake-compiler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -30,20 +44,6 @@ dependencies:
30
44
  - - "<"
31
45
  - !ruby/object:Gem::Version
32
46
  version: '2.0'
33
- - !ruby/object:Gem::Dependency
34
- name: minitest
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '5'
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '5'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: test-unit
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -176,15 +176,6 @@ files:
176
176
  - test/_test_active_mimic.rb
177
177
  - test/_test_mimic_rails.rb
178
178
  - test/activerecord/result_test.rb
179
- - test/activesupport4/decoding_test.rb
180
- - test/activesupport4/encoding_test.rb
181
- - test/activesupport4/test_helper.rb
182
- - test/activesupport5/abstract_unit.rb
183
- - test/activesupport5/decoding_test.rb
184
- - test/activesupport5/encoding_test.rb
185
- - test/activesupport5/encoding_test_cases.rb
186
- - test/activesupport5/test_helper.rb
187
- - test/activesupport5/time_zone_test_helpers.rb
188
179
  - test/activesupport6/abstract_unit.rb
189
180
  - test/activesupport6/decoding_test.rb
190
181
  - test/activesupport6/encoding_test.rb
@@ -197,9 +188,6 @@ files:
197
188
  - test/activesupport7/encoding_test.rb
198
189
  - test/activesupport7/encoding_test_cases.rb
199
190
  - test/activesupport7/time_zone_test_helpers.rb
200
- - test/bar.rb
201
- - test/baz.rb
202
- - test/bug.rb
203
191
  - test/files.rb
204
192
  - test/foo.rb
205
193
  - test/helper.rb
@@ -276,7 +264,6 @@ files:
276
264
  - test/tests.rb
277
265
  - test/tests_mimic.rb
278
266
  - test/tests_mimic_addition.rb
279
- - test/zoo.rb
280
267
  homepage: http://www.ohler.com/oj
281
268
  licenses:
282
269
  - MIT
@@ -287,6 +274,7 @@ metadata:
287
274
  homepage_uri: http://www.ohler.com/oj/
288
275
  source_code_uri: https://github.com/ohler55/oj
289
276
  wiki_uri: https://github.com/ohler55/oj/wiki
277
+ rubygems_mfa_required: 'true'
290
278
  post_install_message:
291
279
  rdoc_options:
292
280
  - "--title"
@@ -299,7 +287,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
299
287
  requirements:
300
288
  - - ">="
301
289
  - !ruby/object:Gem::Version
302
- version: '2.4'
290
+ version: '2.7'
303
291
  required_rubygems_version: !ruby/object:Gem::Requirement
304
292
  requirements:
305
293
  - - ">="