oj 3.7.9 → 3.7.10

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: 73661a33c10dd2efe5e942e8eb7b584a065803d5ab0516c7362210e0b7f6ce29
4
- data.tar.gz: 6091f05664c4f290858f86efb405b1e17732b1eecb7ccb1829c1d2944a6a5a8c
3
+ metadata.gz: 19c25560b508ae039d9d517cb5eacb44b658e1359e11e95317b51ff94581ea6d
4
+ data.tar.gz: 2ea2c2a50e8cf6d14a7c19427def90fefc460fbb626226c6299a91c8890fbeaf
5
5
  SHA512:
6
- metadata.gz: 3a54eb58d01658e36c63f29128c47e026ce05687261465793f4328146807d5b32a4af6c8286f3f4dbe176e1bd1613214ea6e260051ee0477abd1e7ab27173fa7
7
- data.tar.gz: b90c7c8e526636640b5b346fad295fe4b0a7c97671e7acafd5e55ee71b9e6f0727c0dae9eeec58dc1b8729040f91ea14717e6cadb13bce65bf7f428bbfe6cb6e
6
+ metadata.gz: 91ee09165357ad4955030f2d395f61578375c70672245483831d1c291fe76b50c1166c4d6d75435d4961a6aac394d03069320cb8e15e6b352cf6c634d5ab0b5d
7
+ data.tar.gz: ea098163b5b4297777de3dcdfc1468673114ba264fd7f2733620ffe14d3ef784384ac0b8fa8c0482f5303b5c4f47164943462266af91d1662ed4eeee5d893656
@@ -74,7 +74,7 @@ sec_as_time(int64_t secs, TimeInfo ti) {
74
74
  y = secs / SECS_PER_YEAR;
75
75
  secs = secs - y * SECS_PER_YEAR;
76
76
  y++;
77
- leap = true;
77
+ leap = false;
78
78
  }
79
79
  } else if (secs < SECS_PER_LEAP_CENT) { // first century in 400 years is a leap century (one extra day)
80
80
  qy = secs / SECS_PER_QUAD_YEAR;
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
- # Current version of the module.
4
- VERSION = '3.7.9'
3
+ # Current version of the module.
4
+ VERSION = '3.7.10'
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
+
@@ -0,0 +1,22 @@
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'
13
+ require 'oj'
14
+
15
+ Oj.optimize_rails
16
+
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}]}
18
+
19
+ 100000.times {
20
+ JSON.pretty_generate(h)
21
+ }
22
+ #puts JSON.generate(h)
@@ -420,6 +420,14 @@ class Juice < Minitest::Test
420
420
  assert_equal('-2208987661.000000000', json)
421
421
  end
422
422
 
423
+ def test_time_years
424
+ (-2020..2020).each { |year|
425
+ s = "%04d-03-01T15:14:13Z" % [year]
426
+ json = Oj.dump(Time.parse(s), mode: :custom, time_format: :xmlschema)
427
+ assert_equal(s, json[1..-2])
428
+ }
429
+ end
430
+
423
431
  # Class
424
432
  def test_class_null
425
433
  json = Oj.dump(Juice, :mode => :null)
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.7.9
4
+ version: 3.7.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-18 00:00:00.000000000 Z
11
+ date: 2019-03-14 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/Rails.md
83
- - pages/JsonGem.md
84
- - pages/Encoding.md
85
- - pages/WAB.md
86
- - pages/Custom.md
87
82
  - pages/Advanced.md
88
- - pages/Options.md
89
83
  - pages/Compatibility.md
84
+ - pages/Custom.md
85
+ - pages/Encoding.md
86
+ - pages/JsonGem.md
90
87
  - pages/Modes.md
88
+ - pages/Options.md
89
+ - pages/Rails.md
91
90
  - pages/Security.md
91
+ - pages/WAB.md
92
92
  files:
93
93
  - LICENSE
94
94
  - README.md
@@ -177,9 +177,9 @@ files:
177
177
  - test/activesupport5/encoding_test_cases.rb
178
178
  - test/activesupport5/test_helper.rb
179
179
  - test/activesupport5/time_zone_test_helpers.rb
180
- - test/bar.rb
180
+ - test/bug.rb
181
+ - test/crash.rb
181
182
  - test/files.rb
182
- - test/foo.rb
183
183
  - test/helper.rb
184
184
  - test/isolated/shared.rb
185
185
  - test/isolated/test_mimic_after.rb
@@ -243,7 +243,6 @@ files:
243
243
  - test/tests.rb
244
244
  - test/tests_mimic.rb
245
245
  - test/tests_mimic_addition.rb
246
- - test/zoo.rb
247
246
  homepage: http://www.ohler.com/oj
248
247
  licenses:
249
248
  - MIT
@@ -278,82 +277,81 @@ signing_key:
278
277
  specification_version: 4
279
278
  summary: A fast JSON parser and serializer.
280
279
  test_files:
281
- - test/foo.rb
282
- - test/test_integer_range.rb
283
- - test/test_strict.rb
284
- - test/perf_strict.rb
285
- - test/tests.rb
286
- - test/perf_saj.rb
287
- - test/test_compat.rb
280
+ - test/_test_active.rb
281
+ - test/_test_active_mimic.rb
282
+ - test/_test_mimic_rails.rb
283
+ - test/activerecord/result_test.rb
284
+ - test/activesupport4/decoding_test.rb
285
+ - test/activesupport4/encoding_test.rb
286
+ - test/activesupport4/test_helper.rb
287
+ - test/activesupport5/decoding_test.rb
288
+ - test/activesupport5/encoding_test.rb
289
+ - test/activesupport5/encoding_test_cases.rb
290
+ - test/activesupport5/test_helper.rb
291
+ - test/activesupport5/time_zone_test_helpers.rb
292
+ - test/bug.rb
293
+ - test/crash.rb
294
+ - test/files.rb
288
295
  - test/helper.rb
289
- - test/perf_file.rb
290
- - test/test_scp.rb
291
- - test/perf_compat.rb
292
- - test/json_gem/json_common_interface_test.rb
296
+ - test/isolated/shared.rb
297
+ - test/isolated/test_mimic_after.rb
298
+ - test/isolated/test_mimic_alone.rb
299
+ - test/isolated/test_mimic_as_json.rb
300
+ - test/isolated/test_mimic_before.rb
301
+ - test/isolated/test_mimic_define.rb
302
+ - test/isolated/test_mimic_rails_after.rb
303
+ - test/isolated/test_mimic_rails_before.rb
304
+ - test/isolated/test_mimic_redefine.rb
293
305
  - test/json_gem/json_addition_test.rb
294
- - test/json_gem/json_fixtures_test.rb
306
+ - test/json_gem/json_common_interface_test.rb
307
+ - test/json_gem/json_encoding_test.rb
295
308
  - test/json_gem/json_ext_parser_test.rb
296
- - test/json_gem/json_string_matching_test.rb
297
- - test/json_gem/json_generic_object_test.rb
309
+ - test/json_gem/json_fixtures_test.rb
298
310
  - test/json_gem/json_generator_test.rb
299
- - test/json_gem/test_helper.rb
300
- - test/json_gem/json_encoding_test.rb
311
+ - test/json_gem/json_generic_object_test.rb
301
312
  - test/json_gem/json_parser_test.rb
302
- - test/perf_wab.rb
303
- - test/test_file.rb
304
- - test/test_object.rb
305
- - test/sample.rb
313
+ - test/json_gem/json_string_matching_test.rb
314
+ - test/json_gem/test_helper.rb
315
+ - test/perf.rb
316
+ - test/perf_compat.rb
317
+ - test/perf_fast.rb
318
+ - test/perf_file.rb
306
319
  - test/perf_object.rb
307
- - test/test_hash.rb
308
- - test/test_custom.rb
309
- - test/bar.rb
310
- - test/activesupport4/encoding_test.rb
311
- - test/activesupport4/test_helper.rb
312
- - test/activesupport4/decoding_test.rb
313
- - test/sample_json.rb
314
- - test/activesupport5/encoding_test_cases.rb
315
- - test/activesupport5/encoding_test.rb
316
- - test/activesupport5/time_zone_test_helpers.rb
317
- - test/activesupport5/test_helper.rb
318
- - test/activesupport5/decoding_test.rb
319
- - test/test_saj.rb
320
+ - test/perf_saj.rb
320
321
  - test/perf_scp.rb
321
- - test/test_wab.rb
322
- - test/test_null.rb
323
- - test/_test_active.rb
324
- - test/_test_mimic_rails.rb
325
- - test/test_fast.rb
326
- - test/perf_fast.rb
322
+ - test/perf_simple.rb
323
+ - test/perf_strict.rb
324
+ - test/perf_wab.rb
327
325
  - test/sample/change.rb
328
- - test/sample/text.rb
326
+ - test/sample/dir.rb
329
327
  - test/sample/doc.rb
330
- - test/sample/shape.rb
331
- - test/sample/layer.rb
332
- - test/sample/group.rb
333
328
  - test/sample/file.rb
334
- - test/sample/rect.rb
329
+ - test/sample/group.rb
335
330
  - test/sample/hasprops.rb
331
+ - test/sample/layer.rb
336
332
  - test/sample/line.rb
337
- - test/sample/dir.rb
338
333
  - test/sample/oval.rb
339
- - test/tests_mimic.rb
340
- - test/perf_simple.rb
341
- - test/zoo.rb
342
- - test/activerecord/result_test.rb
343
- - test/_test_active_mimic.rb
344
- - test/tests_mimic_addition.rb
345
- - test/test_writer.rb
346
- - test/perf.rb
347
- - test/isolated/test_mimic_define.rb
348
- - test/isolated/test_mimic_after.rb
349
- - test/isolated/test_mimic_rails_after.rb
350
- - test/isolated/test_mimic_before.rb
351
- - test/isolated/test_mimic_rails_before.rb
352
- - test/isolated/test_mimic_redefine.rb
353
- - test/isolated/shared.rb
354
- - test/isolated/test_mimic_alone.rb
355
- - test/isolated/test_mimic_as_json.rb
334
+ - test/sample/rect.rb
335
+ - test/sample/shape.rb
336
+ - test/sample/text.rb
337
+ - test/sample.rb
338
+ - test/sample_json.rb
339
+ - test/test_compat.rb
340
+ - test/test_custom.rb
356
341
  - test/test_debian.rb
342
+ - test/test_fast.rb
343
+ - test/test_file.rb
357
344
  - test/test_gc.rb
358
- - test/files.rb
345
+ - test/test_hash.rb
346
+ - test/test_integer_range.rb
347
+ - test/test_null.rb
348
+ - test/test_object.rb
349
+ - test/test_saj.rb
350
+ - test/test_scp.rb
351
+ - test/test_strict.rb
359
352
  - test/test_various.rb
353
+ - test/test_wab.rb
354
+ - test/test_writer.rb
355
+ - test/tests.rb
356
+ - test/tests_mimic.rb
357
+ - test/tests_mimic_addition.rb
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- $: << File.dirname(__FILE__)
5
- $oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
6
- %w(lib ext).each do |dir|
7
- $: << File.join($oj_dir, dir)
8
- end
9
-
10
- require 'oj'
11
-
12
- #Oj.load_file(ARGV[0], mode: :strict) { |obj|
13
- # puts Oj.dump(obj, indent: 2)
14
- #}
15
-
16
- data = open('invalid_unicode.data').read
17
-
18
- puts data
19
-
20
- puts Oj.dump(data)
21
-
22
- Oj.mimic_JSON
23
- puts Oj.dump(data, escape_mode: :json)
24
-
25
- puts Oj.default_options
@@ -1,83 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- $: << File.dirname(__FILE__)
5
- $oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
6
- %w(lib ext).each do |dir|
7
- $: << File.join($oj_dir, dir)
8
- end
9
-
10
- require 'oj'
11
- require 'tracer'
12
-
13
- #Tracer.on
14
-
15
- class MyParser
16
- attr_accessor :enum
17
-
18
- def initialize
19
- @io = StringIO.new
20
- @writer = Oj::StreamWriter.new(@io)
21
-
22
- json_string = Oj.dump({ records: 1.upto(2).map{|i| { id: i, name: "record_#{i}" }} }, mode: :strict)
23
- @test_json = StringIO.new(json_string)
24
-
25
- @enum = Enumerator.new do |yielder|
26
- @yielder = yielder
27
- Oj.sc_parse(self, @test_json)
28
- end
29
- end
30
-
31
- # Stream parsing methods
32
- def hash_start
33
- @writer.push_object
34
- end
35
-
36
- def hash_end
37
- @writer.pop unless @io.eof
38
- end
39
-
40
- def hash_key(key)
41
- @writer.push_key(key)
42
- end
43
-
44
- def hash_set(h, key, value)
45
- @writer.push_value(value)
46
- end
47
-
48
- def array_start
49
- @writer.push_array
50
- end
51
-
52
- def array_end
53
- @writer.pop
54
- end
55
-
56
- def array_append(a, value)
57
- yield_data
58
- end
59
-
60
- def add_value(value);end
61
-
62
- def yield_data
63
- @writer.pop_all
64
- @yielder << @io.string
65
- @io.reopen("")
66
- array_start
67
- end
68
- end
69
-
70
- #puts MyParser.new.enum.to_a
71
-
72
- puts "------------"
73
-
74
- MyError = Class.new(StandardError)
75
-
76
- MyParser.new.enum.each.with_index do |r, i|
77
- puts "========="
78
- raise MyError.new('hello')
79
- #raise StopIteration if i == 0
80
- #break if i >= 4
81
- end
82
-
83
- #{"records":[{"id":1,"name":"record_1"},{"id":2,"name":"record_2"},{"id":3,"name":"record_3"},{"id":4,"name":"record_4"},{"id":5,"name":"record_5"},{"id":6,"name":"record_6"},{"id":7,"name":"record_7"},{"id":8,"name":"record_8"},{"id":9,"name":"record_9"},{"id":10,"name":"record_10"},{"id":11,"name":"record_11"},{"id":12,"name":"record_12"},{"id":13,"name":"record_13"},{"id":14,"name":"record_14"},{"id":15,"name":"record_15"},{"id":16,"name":"record_16"},{"id":17,"name":"record_17"},{"id":18,"name":"record_18"},{"id":19,"name":"record_19"},{"id":20,"name":"record_20"},{"id":21,"name":"record_21"},{"id":22,"name":"record_22"},{"id":23,"name":"record_23"},{"id":24,"name":"record_24"},{"id":25,"name":"record_25"}]}
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #require 'json'
4
-
5
- $: << File.dirname(__FILE__)
6
- require 'helper'
7
- require 'oj'
8
-
9
- Oj.mimic_JSON
10
- puts "\u3074"
11
-
12
- puts JSON.dump(["\u3074"])
13
- puts JSON.generate(["\u3074"])