oj 3.6.6 → 3.6.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21e115cf6ad860db71f8e6da0bfeffd4fe3a14fb57cf172c4e63a5ed763920d9
4
- data.tar.gz: d410b8c08e883052ae23e82b58f491a814244c5da1285588de6cf0b565514deb
3
+ metadata.gz: 07f971139aede75d733d478ac64e4ecab5717b96df11fa251f64099ff070ad7d
4
+ data.tar.gz: 74c66fb18be035b5a6de58e2c7cef899eb85376d4b2f1be6b93dda18b458c791
5
5
  SHA512:
6
- metadata.gz: 3e9ad858b8013d6b342d1e2e5288cba4cbb7d00f9229fd3dbcafc90a83396ea112014cbf9f6df5dc0f3c32bed6a36be99fc405a8f1ad527c18801d62657c3e43
7
- data.tar.gz: e822f75524cf73cf586bc61a8519ecfc1ff0282e764673d4f38daac08dc30731a7ad3c9617445ad30379c0fadd1c7234899c4f7ae34e1c844dda15bbb8fc02de
6
+ metadata.gz: 5df299170f6aaa4dc85aa3b558a23d30603b3294960dc1fb23894cc9838d0a8d41cb54cc4b317e641047bb6671c712a6c0673fa05baf7e50c272a6e3cca5338a
7
+ data.tar.gz: 821d826ede14244308a4eff3b2e1ca9d968777ce14eae00649ac2ee51d039664b3ec26237a80bb1f2c9790cda9d2fade906ecfc60a92b7a4e5eb5b1bf2ce6dde
@@ -271,7 +271,7 @@ stream_writer_push_json(int argc, VALUE *argv, VALUE self) {
271
271
  oj_str_writer_push_json((StrWriter)DATA_PTR(self), StringValuePtr(*argv), 0);
272
272
  break;
273
273
  case 2:
274
- if (Qnil == argv[0]) {
274
+ if (Qnil == argv[1]) {
275
275
  oj_str_writer_push_json((StrWriter)DATA_PTR(self), StringValuePtr(*argv), 0);
276
276
  } else {
277
277
  rb_check_type(argv[1], T_STRING);
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '3.6.6'
4
+ VERSION = '3.6.7'
5
5
  end
@@ -1,22 +1,15 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- #$VERBOSE = true
5
-
6
- %w(lib ext test).each do |dir|
7
- $LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
8
- end
9
-
10
- require 'active_support'
11
- require 'active_support/core_ext'
12
- require 'active_support/json'
1
+ #require 'active_support'
2
+ #require 'active_support/core_ext'
3
+ #require 'active_support/json'
13
4
  require 'oj'
14
5
 
15
- Oj.optimize_rails
6
+ #Oj.optimize_rails
7
+ Oj.mimic_JSON
16
8
 
17
9
  h = {:type=>:record, :name=>:group, :namespace=>"com.salsify.identity", :fields=>[{:name=>"id", :type=>{:name=>:salsify_uuid, :type=>:fixed, :namespace=>"com.salsify", :size=>38}}, {:name=>"type", :type=>"string", :default=>"groups"}, {:name=>"external_id", :type=>[:null, "string"], :default=>nil}, {:name=>"created_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"updated_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"name", :type=>"string"}, {:name=>"policy", :type=>[:null, {:type=>:record, :name=>:policy, :namespace=>"com.salsify.security", :fields=>[{:name=>"created_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"updated_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"id", :type=>"com.salsify.salsify_uuid"}, {:name=>"type", :type=>"string", :default=>"policies"}, {:name=>"external_id", :type=>[:null, "string"], :default=>nil}, {:name=>"name", :type=>"string"}, {:name=>"statements", :type=>{:type=>:array, :items=>{:type=>:record, :name=>:statement, :namespace=>"com.salsify.security", :fields=>[{:name=>"created_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"updated_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"id", :type=>"com.salsify.salsify_uuid"}, {:name=>"type", :type=>"string", :default=>"statements"}, {:name=>"external_id", :type=>[:null, "string"], :default=>nil}, {:name=>"action", :type=>{:name=>"__statement_action_enum", :type=>:enum, :namespace=>"com.salsify.security", :symbols=>[:manage, :read]}}, {:name=>"resource", :type=>{:name=>"__statement_resource_enum", :type=>:enum, :namespace=>"com.salsify.security", :symbols=>[:product, :digital_asset]}}, {:name=>"conditions", :type=>{:type=>:array, :items=>{:type=>:record, :name=>:condition, :namespace=>"com.salsify.security", :fields=>[{:name=>"created_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"updated_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"id", :type=>"com.salsify.salsify_uuid"}, {:name=>"type", :type=>"string", :default=>"conditions"}, {:name=>"external_id", :type=>[:null, "string"], :default=>nil}, {:name=>"operator", :type=>{:name=>"__condition_operator_enum", :type=>:enum, :namespace=>"com.salsify.security", :symbols=>[:equals]}}, {:name=>"attribute_type", :type=>{:name=>"__condition_attribute_type_enum", :type=>:enum, :namespace=>"com.salsify.security", :symbols=>[:resource]}}, {:name=>"value", :type=>"string"}, {:name=>"attribute", :type=>[:null, {:type=>:record, :name=>:reference, :namespace=>"com.salsify", :fields=>[{:name=>"id", :type=>"com.salsify.salsify_uuid"}, {:name=>"type", :type=>"string", :doc=>"snake_case, plural name for the resource type"}, {:name=>"external_id", :type=>[:null, "string"], :default=>nil}]}], :default=>nil}, {:name=>"broken", :type=>[:null, "boolean"], :default=>nil}]}}}]}}}]}], :default=>nil}]}
18
10
 
19
- 100000.times {
20
- JSON.pretty_generate(h)
21
- }
11
+ #Oj.dump(h)
12
+ puts JSON.pretty_generate(h)
13
+ #puts JSON.fast_generate(h)
22
14
  #puts JSON.generate(h)
15
+
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << '.'
4
+ $: << '../lib'
5
+ $: << '../ext'
6
+
7
+ require 'oj'
8
+
9
+ Oj.default_options = {mode: :strict}
10
+ json = Oj.dump({ aggregations: { hashtags: { buckets: Array.new(100) { { key: 'foo', count: 100 } } } } }, mode: :strict)
11
+
12
+ def expect(a,b)
13
+ puts "*** #{a} != #{b}" unless a == b
14
+ end
15
+
16
+ def dig(obj, *path)
17
+ return obj if path.empty?
18
+
19
+ if obj.is_a?(Array)
20
+ obj.each { |v|
21
+ r = dig(v, *path)
22
+ return r unless r.nil?
23
+ }
24
+ end
25
+ return nil unless obj.is_a?(Hash)
26
+
27
+ dig(obj[path[0]], *path[1..-1])
28
+ end
29
+
30
+ 1000.times do |i|
31
+ Oj::Doc.open(json) do |doc|
32
+ # this always passes
33
+ doc.each_child('/aggregations/hashtags/buckets') do |bucket|
34
+ expect(bucket.fetch('key'), 'foo')
35
+ expect(bucket.fetch('count'), 100)
36
+ end
37
+
38
+ # load any other json using Oj.load
39
+ # this will pass
40
+ other = Oj.load(json)
41
+ dig(other, 'aggregations', 'hashtags', 'buckets').each do |bucket|
42
+ expect(bucket.fetch('key'), 'foo')
43
+ expect(bucket.fetch('count'), 100)
44
+ end
45
+ GC.start
46
+ doc.each_child('/aggregations/hashtags/buckets') do |bucket|
47
+ # This is where it fails!!!! It will be some other object (even an rspec matcher in some cases)
48
+ expect(bucket.fetch('key'), 'foo')
49
+ expect(bucket.fetch('count'), 100)
50
+ end
51
+
52
+ # this always passes if it gets this far
53
+ dig(other, 'aggregations', 'hashtags', 'buckets').each do |bucket|
54
+ expect(bucket.fetch('key'), 'foo')
55
+ expect(bucket.fetch('count'), 100)
56
+ end
57
+ end
58
+ 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.6.6
4
+ version: 3.6.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: 2018-08-16 00:00:00.000000000 Z
11
+ date: 2018-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -79,16 +79,16 @@ extensions:
79
79
  - ext/oj/extconf.rb
80
80
  extra_rdoc_files:
81
81
  - README.md
82
+ - pages/Modes.md
82
83
  - pages/Advanced.md
83
- - pages/Compatibility.md
84
+ - pages/Options.md
84
85
  - pages/Custom.md
86
+ - pages/Compatibility.md
87
+ - pages/WAB.md
88
+ - pages/Security.md
85
89
  - pages/Encoding.md
86
90
  - pages/JsonGem.md
87
- - pages/Modes.md
88
- - pages/Options.md
89
91
  - pages/Rails.md
90
- - pages/Security.md
91
- - pages/WAB.md
92
92
  files:
93
93
  - LICENSE
94
94
  - README.md
@@ -175,9 +175,9 @@ files:
175
175
  - test/activesupport5/encoding_test_cases.rb
176
176
  - test/activesupport5/test_helper.rb
177
177
  - test/activesupport5/time_zone_test_helpers.rb
178
- - test/bug.rb
179
- - test/crash.rb
178
+ - test/big.rb
180
179
  - test/files.rb
180
+ - test/foo.rb
181
181
  - test/helper.rb
182
182
  - test/isolated/shared.rb
183
183
  - test/isolated/test_mimic_after.rb
@@ -270,85 +270,85 @@ required_rubygems_version: !ruby/object:Gem::Requirement
270
270
  version: '0'
271
271
  requirements: []
272
272
  rubyforge_project:
273
- rubygems_version: 2.7.3
273
+ rubygems_version: 2.7.6
274
274
  signing_key:
275
275
  specification_version: 4
276
276
  summary: A fast JSON parser and serializer.
277
277
  test_files:
278
- - test/_test_active.rb
279
- - test/_test_active_mimic.rb
280
- - test/_test_mimic_rails.rb
281
- - test/activerecord/result_test.rb
278
+ - test/perf_file.rb
279
+ - test/test_hash.rb
280
+ - test/perf.rb
281
+ - test/test_object.rb
282
+ - test/test_null.rb
283
+ - test/test_compat.rb
284
+ - test/test_custom.rb
285
+ - test/perf_scp.rb
286
+ - test/test_gc.rb
287
+ - test/sample.rb
288
+ - test/json_gem/json_string_matching_test.rb
289
+ - test/json_gem/json_addition_test.rb
290
+ - test/json_gem/test_helper.rb
291
+ - test/json_gem/json_generator_test.rb
292
+ - test/json_gem/json_parser_test.rb
293
+ - test/json_gem/json_encoding_test.rb
294
+ - test/json_gem/json_common_interface_test.rb
295
+ - test/json_gem/json_generic_object_test.rb
296
+ - test/json_gem/json_ext_parser_test.rb
297
+ - test/json_gem/json_fixtures_test.rb
298
+ - test/tests_mimic_addition.rb
299
+ - test/test_wab.rb
300
+ - test/activesupport4/test_helper.rb
282
301
  - test/activesupport4/decoding_test.rb
283
302
  - test/activesupport4/encoding_test.rb
284
- - test/activesupport4/test_helper.rb
285
- - test/activesupport5/decoding_test.rb
286
- - test/activesupport5/encoding_test.rb
303
+ - test/activerecord/result_test.rb
304
+ - test/_test_active.rb
305
+ - test/test_file.rb
287
306
  - test/activesupport5/encoding_test_cases.rb
288
- - test/activesupport5/test_helper.rb
289
307
  - test/activesupport5/time_zone_test_helpers.rb
290
- - test/bug.rb
291
- - test/crash.rb
292
- - test/files.rb
308
+ - test/activesupport5/test_helper.rb
309
+ - test/activesupport5/decoding_test.rb
310
+ - test/activesupport5/encoding_test.rb
311
+ - test/tests.rb
312
+ - test/_test_active_mimic.rb
313
+ - test/perf_object.rb
314
+ - test/test_strict.rb
315
+ - test/test_scp.rb
316
+ - test/perf_wab.rb
317
+ - test/test_saj.rb
318
+ - test/perf_compat.rb
293
319
  - test/helper.rb
294
- - test/isolated/shared.rb
295
- - test/isolated/test_mimic_after.rb
296
320
  - test/isolated/test_mimic_alone.rb
297
- - test/isolated/test_mimic_as_json.rb
298
- - test/isolated/test_mimic_before.rb
299
321
  - test/isolated/test_mimic_define.rb
300
322
  - test/isolated/test_mimic_rails_after.rb
323
+ - test/isolated/test_mimic_after.rb
301
324
  - test/isolated/test_mimic_rails_before.rb
325
+ - test/isolated/test_mimic_as_json.rb
302
326
  - test/isolated/test_mimic_redefine.rb
303
- - test/json_gem/json_addition_test.rb
304
- - test/json_gem/json_common_interface_test.rb
305
- - test/json_gem/json_encoding_test.rb
306
- - test/json_gem/json_ext_parser_test.rb
307
- - test/json_gem/json_fixtures_test.rb
308
- - test/json_gem/json_generator_test.rb
309
- - test/json_gem/json_generic_object_test.rb
310
- - test/json_gem/json_parser_test.rb
311
- - test/json_gem/json_string_matching_test.rb
312
- - test/json_gem/test_helper.rb
313
- - test/perf.rb
314
- - test/perf_compat.rb
327
+ - test/isolated/shared.rb
328
+ - test/isolated/test_mimic_before.rb
329
+ - test/sample_json.rb
330
+ - test/test_debian.rb
315
331
  - test/perf_fast.rb
316
- - test/perf_file.rb
317
- - test/perf_object.rb
318
- - test/perf_saj.rb
319
- - test/perf_scp.rb
320
- - test/perf_simple.rb
321
- - test/perf_strict.rb
322
- - test/perf_wab.rb
332
+ - test/test_writer.rb
333
+ - test/test_fast.rb
334
+ - test/sample/line.rb
323
335
  - test/sample/change.rb
324
336
  - test/sample/dir.rb
325
- - test/sample/doc.rb
326
- - test/sample/file.rb
327
- - test/sample/group.rb
328
- - test/sample/hasprops.rb
337
+ - test/sample/text.rb
329
338
  - test/sample/layer.rb
330
- - test/sample/line.rb
331
- - test/sample/oval.rb
332
339
  - test/sample/rect.rb
340
+ - test/sample/group.rb
341
+ - test/sample/oval.rb
342
+ - test/sample/doc.rb
343
+ - test/sample/hasprops.rb
333
344
  - test/sample/shape.rb
334
- - test/sample/text.rb
335
- - test/sample.rb
336
- - test/sample_json.rb
337
- - test/test_compat.rb
338
- - test/test_custom.rb
339
- - test/test_debian.rb
340
- - test/test_fast.rb
341
- - test/test_file.rb
342
- - test/test_gc.rb
343
- - test/test_hash.rb
344
- - test/test_null.rb
345
- - test/test_object.rb
346
- - test/test_saj.rb
347
- - test/test_scp.rb
348
- - test/test_strict.rb
349
- - test/test_various.rb
350
- - test/test_wab.rb
351
- - test/test_writer.rb
352
- - test/tests.rb
345
+ - test/sample/file.rb
346
+ - test/files.rb
347
+ - test/big.rb
348
+ - test/perf_saj.rb
349
+ - test/foo.rb
353
350
  - test/tests_mimic.rb
354
- - test/tests_mimic_addition.rb
351
+ - test/perf_strict.rb
352
+ - test/test_various.rb
353
+ - test/_test_mimic_rails.rb
354
+ - test/perf_simple.rb
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- %w(lib ext test).each do |dir|
5
- $LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
6
- end
7
-
8
- require 'rails'
9
- require 'active_support'
10
- require 'active_support/json'
11
- require 'oj'
12
-
13
- x = {"a": BigDecimal("1.1"), "t": Time.now}
14
-
15
- #ActiveSupport.encode_big_decimal_as_string = false
16
-
17
- Oj.optimize_rails
18
-
19
- puts "to_json #{x.to_json}"
20
-
21
- Oj.default_options = { bigdecimal_as_decimal: true}
22
- #puts Oj.default_options
23
-
24
- puts "to_json #{x.to_json}"
25
-