oj 3.6.5 → 3.6.6

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: 7f4e0a767653f34a793b28037b299f5580e6b24cec56edbc7c01add6067a8a8f
4
- data.tar.gz: ec009f0e9ce5bb255dd11325ccfbeef78d9cb35bb0e0bdba9cc718e3f511e85d
3
+ metadata.gz: 21e115cf6ad860db71f8e6da0bfeffd4fe3a14fb57cf172c4e63a5ed763920d9
4
+ data.tar.gz: d410b8c08e883052ae23e82b58f491a814244c5da1285588de6cf0b565514deb
5
5
  SHA512:
6
- metadata.gz: c457ef279848a3ccaacb4c28e60f6433f5a5735fcec526d29cda2557ebef7edb112d0d9b548027832eff669ccf74a795d3fda77bc59d25babb9637f9f81bc433
7
- data.tar.gz: 397a8d2c6666228766180aca8482c9f528fa31c240638708d68c92ccc1d96ac2f3d513ad4a0e838012c04ba536328063b7a7e00e63366fd1f86fc408d3af5f7e
6
+ metadata.gz: 3e9ad858b8013d6b342d1e2e5288cba4cbb7d00f9229fd3dbcafc90a83396ea112014cbf9f6df5dc0f3c32bed6a36be99fc405a8f1ad527c18801d62657c3e43
7
+ data.tar.gz: e822f75524cf73cf586bc61a8519ecfc1ff0282e764673d4f38daac08dc30731a7ad3c9617445ad30379c0fadd1c7234899c4f7ae34e1c844dda15bbb8fc02de
data/README.md CHANGED
@@ -67,7 +67,7 @@ See [{file:CHANGELOG.md}](CHANGELOG.md)
67
67
 
68
68
  - *RubyGems* *repo*: https://rubygems.org/gems/oj
69
69
 
70
- Follow [@peterohler on Twitter](http://twitter.com/#!/peterohler) for announcements and news about the Oj gem.
70
+ Follow [@peterohler on Twitter](http://twitter.com/peterohler) for announcements and news about the Oj gem.
71
71
 
72
72
  #### Performance Comparisons
73
73
 
@@ -347,13 +347,14 @@ oj_dump_time(VALUE obj, Out out, int withZone) {
347
347
  char *dot;
348
348
  int neg = 0;
349
349
  long one = 1000000000;
350
- time_t sec;
350
+ long long sec;
351
351
  long long nsec;
352
352
 
353
353
  #if HAS_RB_TIME_TIMESPEC
354
354
  {
355
355
  struct timespec ts = rb_time_timespec(obj);
356
- sec = ts.tv_sec;
356
+
357
+ sec = (long long)ts.tv_sec;
357
358
  nsec = ts.tv_nsec;
358
359
  }
359
360
  #else
@@ -20,7 +20,14 @@ dflags = {
20
20
  'RUBY_VERSION_MAJOR' => version[0],
21
21
  'RUBY_VERSION_MINOR' => version[1],
22
22
  'RUBY_VERSION_MICRO' => version[2],
23
- 'HAS_RB_TIME_TIMESPEC' => (!is_windows && 'ruby' == type && ('1.9.3' == RUBY_VERSION || '2' <= version[0])) ? 1 : 0,
23
+ 'HAS_RB_TIME_TIMESPEC' => (!is_windows &&
24
+ !['arm-linux-gnueabi',
25
+ 'arm-linux-gnueabihf',
26
+ 'i386-linux-gnu',
27
+ 'mips-linux-gnu',
28
+ 'mipsel-linux-gnu'].include?(platform) &&
29
+ 'ruby' == type &&
30
+ ('1.9.3' == RUBY_VERSION || '2' <= version[0])) ? 1 : 0,
24
31
  'HAS_ENCODING_SUPPORT' => (('ruby' == type || 'rubinius' == type) &&
25
32
  (('1' == version[0] && '9' == version[1]) || '2' <= version[0])) ? 1 : 0,
26
33
  'HAS_NANO_TIME' => ('ruby' == type && ('1' == version[0] && '9' == version[1]) || '2' <= version[0]) ? 1 : 0,
@@ -1691,6 +1691,7 @@ Init_oj() {
1691
1691
  xss_safe_sym = ID2SYM(rb_intern("xss_safe")); rb_gc_register_address(&xss_safe_sym);
1692
1692
 
1693
1693
  oj_slash_string = rb_str_new2("/"); rb_gc_register_address(&oj_slash_string);
1694
+ OBJ_FREEZE(oj_slash_string);
1694
1695
 
1695
1696
  oj_default_options.mode = ObjectMode;
1696
1697
 
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '3.6.5'
4
+ VERSION = '3.6.6'
5
5
  end
@@ -0,0 +1,25 @@
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
+
@@ -1,15 +1,22 @@
1
- #require 'active_support'
2
- #require 'active_support/core_ext'
3
- #require 'active_support/json'
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'
4
13
  require 'oj'
5
14
 
6
- #Oj.optimize_rails
7
- Oj.mimic_JSON
15
+ Oj.optimize_rails
8
16
 
9
17
  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}]}
10
18
 
11
- #Oj.dump(h)
12
- puts JSON.pretty_generate(h)
13
- #puts JSON.fast_generate(h)
19
+ 100000.times {
20
+ JSON.pretty_generate(h)
21
+ }
14
22
  #puts JSON.generate(h)
15
-
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.5
4
+ version: 3.6.6
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-07-26 00:00:00.000000000 Z
11
+ date: 2018-08-16 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
83
82
  - pages/Advanced.md
84
- - pages/Options.md
85
- - pages/Custom.md
86
83
  - pages/Compatibility.md
87
- - pages/WAB.md
88
- - pages/Security.md
84
+ - pages/Custom.md
89
85
  - pages/Encoding.md
90
86
  - pages/JsonGem.md
87
+ - pages/Modes.md
88
+ - pages/Options.md
91
89
  - 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/big.rb
178
+ - test/bug.rb
179
+ - test/crash.rb
179
180
  - 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.6
273
+ rubygems_version: 2.7.3
274
274
  signing_key:
275
275
  specification_version: 4
276
276
  summary: A fast JSON parser and serializer.
277
277
  test_files:
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
278
+ - test/_test_active.rb
279
+ - test/_test_active_mimic.rb
280
+ - test/_test_mimic_rails.rb
281
+ - test/activerecord/result_test.rb
301
282
  - test/activesupport4/decoding_test.rb
302
283
  - test/activesupport4/encoding_test.rb
303
- - test/activerecord/result_test.rb
304
- - test/_test_active.rb
305
- - test/test_file.rb
306
- - test/activesupport5/encoding_test_cases.rb
307
- - test/activesupport5/time_zone_test_helpers.rb
308
- - test/activesupport5/test_helper.rb
284
+ - test/activesupport4/test_helper.rb
309
285
  - test/activesupport5/decoding_test.rb
310
286
  - 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
287
+ - test/activesupport5/encoding_test_cases.rb
288
+ - test/activesupport5/test_helper.rb
289
+ - test/activesupport5/time_zone_test_helpers.rb
290
+ - test/bug.rb
291
+ - test/crash.rb
292
+ - test/files.rb
319
293
  - test/helper.rb
294
+ - test/isolated/shared.rb
295
+ - test/isolated/test_mimic_after.rb
320
296
  - test/isolated/test_mimic_alone.rb
297
+ - test/isolated/test_mimic_as_json.rb
298
+ - test/isolated/test_mimic_before.rb
321
299
  - test/isolated/test_mimic_define.rb
322
300
  - test/isolated/test_mimic_rails_after.rb
323
- - test/isolated/test_mimic_after.rb
324
301
  - test/isolated/test_mimic_rails_before.rb
325
- - test/isolated/test_mimic_as_json.rb
326
302
  - test/isolated/test_mimic_redefine.rb
327
- - test/isolated/shared.rb
328
- - test/isolated/test_mimic_before.rb
329
- - test/sample_json.rb
330
- - test/test_debian.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
331
315
  - test/perf_fast.rb
332
- - test/test_writer.rb
333
- - test/test_fast.rb
334
- - test/sample/line.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
335
323
  - test/sample/change.rb
336
324
  - test/sample/dir.rb
337
- - test/sample/text.rb
338
- - test/sample/layer.rb
339
- - test/sample/rect.rb
340
- - test/sample/group.rb
341
- - test/sample/oval.rb
342
325
  - test/sample/doc.rb
326
+ - test/sample/file.rb
327
+ - test/sample/group.rb
343
328
  - test/sample/hasprops.rb
329
+ - test/sample/layer.rb
330
+ - test/sample/line.rb
331
+ - test/sample/oval.rb
332
+ - test/sample/rect.rb
344
333
  - test/sample/shape.rb
345
- - test/sample/file.rb
346
- - test/files.rb
347
- - test/big.rb
348
- - test/perf_saj.rb
349
- - test/foo.rb
350
- - test/tests_mimic.rb
351
- - test/perf_strict.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
352
349
  - test/test_various.rb
353
- - test/_test_mimic_rails.rb
354
- - test/perf_simple.rb
350
+ - test/test_wab.rb
351
+ - test/test_writer.rb
352
+ - test/tests.rb
353
+ - test/tests_mimic.rb
354
+ - test/tests_mimic_addition.rb
@@ -1,58 +0,0 @@
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