oj 3.3.2 → 3.3.3

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
  SHA1:
3
- metadata.gz: 5751bb765a26b86b9e23a6fbc2bb4a127cdd8b10
4
- data.tar.gz: be164b60130dad88db2de417ecae84b542a47d68
3
+ metadata.gz: e210bbe1a4ca6481764cdbce1cf22a81cef57422
4
+ data.tar.gz: 498f055ca85353c634d9075ebfd4aa08b407ec9e
5
5
  SHA512:
6
- metadata.gz: 36f67b79a17e3bb452a3d10cdddaecb825b1cce08a4407e9ade9cee19a724e2ff73d99855b8da4da6d7bb0bf6d9f71708b4308c2f40e38c7d71d3d85f103180e
7
- data.tar.gz: 36681b67bcd1f6a62aff34b4b3e8121eceb9f14be749430405b07fe736bc4e2e6fc0a783e74ac1d25a77945790c478706fe1bf1ee8cd09c8e0a9210b6b75b72b
6
+ metadata.gz: 2ef63f7e0e438b91403adc11f8789ee0637a093e77f189713e2a1c8302eb4ba2b5a85c1a212a0773a9d51d6b53e799ef23f5a24bf1ef5ada26ef6c4cd1607eec
7
+ data.tar.gz: 22439e9541f4cee3f2524c4fecf114bb69f90693fddd4527f4ba56d632f060803ac021b745abeca80f45c7ab0171ac94159f98428e527e24e3eba3971c40e3af
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # [![{}j](http://www.ohler.com/dev/images/oj_comet_64.svg)](http://www.ohler.com/oj) gem
2
2
 
3
- [![Build Status](https://img.shields.io/travis/ohler55/oj/master.svg)](http://travis-ci.org/ohler55/oj?branch=master) ![Gem](https://img.shields.io/gem/v/oj.svg) ![Gem](https://img.shields.io/gem/dt/oj.svg)
3
+ [![Build Status](https://img.shields.io/travis/ohler55/oj/master.svg)](http://travis-ci.org/ohler55/oj?branch=master) [![AppVeyor](https://img.shields.io/appveyor/ci/ohler55/oj/master.svg)](https://ci.appveyor.com/project/ohler55/oj) ![Gem](https://img.shields.io/gem/v/oj.svg) ![Gem](https://img.shields.io/gem/dt/oj.svg)
4
4
 
5
5
  A *fast* JSON parser and Object marshaller as a Ruby gem.
6
6
 
@@ -63,6 +63,6 @@ end
63
63
 
64
64
  $CPPFLAGS += ' -Wall'
65
65
  #puts "*** $CPPFLAGS: #{$CPPFLAGS}"
66
- create_makefile("#{extension_name}/#{extension_name}")
66
+ create_makefile(File.join(extension_name, extension_name))
67
67
 
68
- %x{make clean}
68
+ #%x{make clean}
@@ -92,6 +92,8 @@ oj_parse_mimic_dump_options(VALUE ropts, Options copts) {
92
92
  ropts = rb_funcall(ropts, oj_to_hash_id, 0);
93
93
  } else if (rb_respond_to(ropts, oj_to_h_id)) {
94
94
  ropts = rb_funcall(ropts, oj_to_h_id, 0);
95
+ } else if (Qnil == ropts) {
96
+ return;
95
97
  } else {
96
98
  rb_raise(rb_eArgError, "options must be a hash.");
97
99
  }
@@ -505,7 +507,7 @@ mimic_parse_core(int argc, VALUE *argv, VALUE self, bool bang) {
505
507
  pi.options.mode = CompatMode;
506
508
  pi.max_depth = 100;
507
509
 
508
- if (2 <= argc) {
510
+ if (2 <= argc && Qnil != argv[1]) {
509
511
  VALUE ropts = argv[1];
510
512
  VALUE v;
511
513
 
@@ -294,14 +294,20 @@ hat_num(ParseInfo pi, Val parent, Val kval, NumInfo ni) {
294
294
  struct tm *st = gmtime(&t);
295
295
  VALUE args[8];
296
296
 
297
- args[0] = LONG2NUM(1900 + st->tm_year);
298
- args[1] = LONG2NUM(1 + st->tm_mon);
299
- args[2] = LONG2NUM(st->tm_mday);
300
- args[3] = LONG2NUM(st->tm_hour);
301
- args[4] = LONG2NUM(st->tm_min);
302
- args[5] = rb_float_new((double)st->tm_sec + ((double)nsec + 0.5) / 1000000000.0);
303
- args[6] = LONG2NUM(ni->exp);
304
- parent->val = rb_funcall2(rb_cTime, oj_new_id, 7, args);
297
+ // Windows does not support dates before 1970 so ignore
298
+ // the zone and do the best we can.
299
+ if (NULL == st) {
300
+ parent->val = rb_time_nano_new(ni->i, (long)nsec);
301
+ } else {
302
+ args[0] = LONG2NUM((long)(1900 + st->tm_year));
303
+ args[1] = LONG2NUM(1 + st->tm_mon);
304
+ args[2] = LONG2NUM(st->tm_mday);
305
+ args[3] = LONG2NUM(st->tm_hour);
306
+ args[4] = LONG2NUM(st->tm_min);
307
+ args[5] = rb_float_new((double)st->tm_sec + ((double)nsec + 0.5) / 1000000000.0);
308
+ args[6] = LONG2NUM(ni->exp);
309
+ parent->val = rb_funcall2(rb_cTime, oj_new_id, 7, args);
310
+ }
305
311
  } else {
306
312
  parent->val = rb_time_nano_new(ni->i, (long)nsec);
307
313
  }
@@ -749,24 +749,26 @@ load(int argc, VALUE *argv, VALUE self) {
749
749
  VALUE ropts = argv[1];
750
750
  VALUE v;
751
751
 
752
- Check_Type(ropts, T_HASH);
753
- if (Qnil != (v = rb_hash_lookup(ropts, mode_sym))) {
754
- if (object_sym == v) {
755
- mode = ObjectMode;
756
- } else if (strict_sym == v) {
757
- mode = StrictMode;
758
- } else if (compat_sym == v || json_sym == v) {
759
- mode = CompatMode;
760
- } else if (null_sym == v) {
761
- mode = NullMode;
762
- } else if (custom_sym == v) {
763
- mode = CustomMode;
764
- } else if (rails_sym == v) {
765
- mode = RailsMode;
766
- } else if (wab_sym == v) {
767
- mode = WabMode;
768
- } else {
769
- rb_raise(rb_eArgError, ":mode must be :object, :strict, :compat, :null, :custom, :rails, or :wab.");
752
+ if (Qnil != ropts || CompatMode != mode) {
753
+ Check_Type(ropts, T_HASH);
754
+ if (Qnil != (v = rb_hash_lookup(ropts, mode_sym))) {
755
+ if (object_sym == v) {
756
+ mode = ObjectMode;
757
+ } else if (strict_sym == v) {
758
+ mode = StrictMode;
759
+ } else if (compat_sym == v || json_sym == v) {
760
+ mode = CompatMode;
761
+ } else if (null_sym == v) {
762
+ mode = NullMode;
763
+ } else if (custom_sym == v) {
764
+ mode = CustomMode;
765
+ } else if (rails_sym == v) {
766
+ mode = RailsMode;
767
+ } else if (wab_sym == v) {
768
+ mode = WabMode;
769
+ } else {
770
+ rb_raise(rb_eArgError, ":mode must be :object, :strict, :compat, :null, :custom, :rails, or :wab.");
771
+ }
770
772
  }
771
773
  }
772
774
  }
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '3.3.2'
4
+ VERSION = '3.3.3'
5
5
  end
@@ -0,0 +1,22 @@
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/json'
10
+ require 'oj'
11
+
12
+ #Oj.optimize_rails
13
+
14
+ #puts JSON.parse('{"a":1}', symbolize_names: true)
15
+
16
+ #Oj.mimic_JSON()
17
+
18
+ #puts Oj.dump({nan: Float::NAN}, mode: :compat, nan: :raise)
19
+
20
+ #puts({nan: Float::NAN}.to_json)
21
+
22
+ puts Oj.dump(NoMethodError.new, mode: :custom)
@@ -130,6 +130,8 @@ class FileJuice < Minitest::Test
130
130
  dump_and_load(t, false)
131
131
  end
132
132
  def test_time_object_early
133
+ # Windows does not support dates before 1970.
134
+ return if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
133
135
  t = Time.xmlschema("1954-01-05T00:00:00.123456")
134
136
  Oj.default_options = { :mode => :object, :time_format => :unix_zone }
135
137
  dump_and_load(t, false)
@@ -568,11 +568,10 @@ class ObjectJuice < Minitest::Test
568
568
  end
569
569
 
570
570
  def test_time_early
571
- if RUBY_VERSION.start_with?('1.8')
572
- t = Time.parse('1954-01-05T21:37:07.123456789-08:00')
573
- else
574
- t = Time.new(1954, 1, 5, 21, 37, 7.123456789, -8 * 3600)
575
- end
571
+ # Windows does not support dates before 1970.
572
+ return if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
573
+
574
+ t = Time.new(1954, 1, 5, 21, 37, 7.123456789, -8 * 3600)
576
575
  # The fractional seconds are not always recreated exactly which causes a
577
576
  # mismatch so instead the seconds, nsecs, and gmt_offset are checked
578
577
  # separately along with utc.
@@ -590,11 +589,7 @@ class ObjectJuice < Minitest::Test
590
589
  end
591
590
 
592
591
  def test_time_unix_zone
593
- if RUBY_VERSION.start_with?('1.8')
594
- t = Time.parse('2015-01-05T21:37:07.123456789-08:00')
595
- else
596
- t = Time.new(2015, 1, 5, 21, 37, 7.123456789, -8 * 3600)
597
- end
592
+ t = Time.new(2015, 1, 5, 21, 37, 7.123456789, -8 * 3600)
598
593
  # The fractional seconds are not always recreated exactly which causes a
599
594
  # mismatch so instead the seconds, nsecs, and gmt_offset are checked
600
595
  # separately along with utc.
@@ -320,6 +320,9 @@ 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)/
325
+
323
326
  handler = AllHandler.new()
324
327
  json = %{{"one":true,"two":false}}
325
328
  IO.pipe do |read_io, write_io|
@@ -344,6 +347,9 @@ class ScpTest < Minitest::Test
344
347
  end
345
348
 
346
349
  def test_pipe_close
350
+ # Windows does not support fork
351
+ return if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
352
+
347
353
  json = %{{"one":true,"two":false}}
348
354
  IO.pipe do |read_io, write_io|
349
355
  if fork
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.3.2
4
+ version: 3.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-11 00:00:00.000000000 Z
11
+ date: 2017-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -60,15 +60,15 @@ extensions:
60
60
  extra_rdoc_files:
61
61
  - README.md
62
62
  - pages/Advanced.md
63
- - pages/WAB.md
64
- - pages/Encoding.md
65
- - pages/Modes.md
66
- - pages/Security.md
67
- - pages/JsonGem.md
68
- - pages/Rails.md
69
63
  - pages/Compatibility.md
70
64
  - pages/Custom.md
65
+ - pages/Encoding.md
66
+ - pages/JsonGem.md
67
+ - pages/Modes.md
71
68
  - pages/Options.md
69
+ - pages/Rails.md
70
+ - pages/Security.md
71
+ - pages/WAB.md
72
72
  files:
73
73
  - LICENSE
74
74
  - README.md
@@ -152,6 +152,7 @@ files:
152
152
  - test/activesupport5/encoding_test_cases.rb
153
153
  - test/activesupport5/test_helper.rb
154
154
  - test/activesupport5/time_zone_test_helpers.rb
155
+ - test/bug.rb
155
156
  - test/files.rb
156
157
  - test/helper.rb
157
158
  - test/isolated/shared.rb
@@ -244,77 +245,78 @@ signing_key:
244
245
  specification_version: 4
245
246
  summary: A fast JSON parser and serializer.
246
247
  test_files:
247
- - test/activesupport5/test_helper.rb
248
- - test/activesupport5/time_zone_test_helpers.rb
248
+ - test/_test_active.rb
249
+ - test/_test_active_mimic.rb
250
+ - test/_test_mimic_rails.rb
251
+ - test/activesupport4/decoding_test.rb
252
+ - test/activesupport4/encoding_test.rb
253
+ - test/activesupport4/test_helper.rb
249
254
  - test/activesupport5/decoding_test.rb
250
- - test/activesupport5/encoding_test_cases.rb
251
255
  - test/activesupport5/encoding_test.rb
252
- - test/test_file.rb
256
+ - test/activesupport5/encoding_test_cases.rb
257
+ - test/activesupport5/test_helper.rb
258
+ - test/activesupport5/time_zone_test_helpers.rb
259
+ - test/bug.rb
253
260
  - test/files.rb
261
+ - test/helper.rb
262
+ - test/isolated/shared.rb
263
+ - test/isolated/test_mimic_after.rb
264
+ - test/isolated/test_mimic_alone.rb
265
+ - test/isolated/test_mimic_as_json.rb
266
+ - test/isolated/test_mimic_before.rb
267
+ - test/isolated/test_mimic_define.rb
268
+ - test/isolated/test_mimic_rails_after.rb
269
+ - test/isolated/test_mimic_rails_before.rb
270
+ - test/isolated/test_mimic_redefine.rb
271
+ - test/json_gem/json_addition_test.rb
272
+ - test/json_gem/json_common_interface_test.rb
273
+ - test/json_gem/json_encoding_test.rb
274
+ - test/json_gem/json_ext_parser_test.rb
275
+ - test/json_gem/json_fixtures_test.rb
276
+ - test/json_gem/json_generator_test.rb
277
+ - test/json_gem/json_generic_object_test.rb
278
+ - test/json_gem/json_parser_test.rb
279
+ - test/json_gem/json_string_matching_test.rb
280
+ - test/json_gem/test_helper.rb
281
+ - test/perf.rb
282
+ - test/perf_compat.rb
283
+ - test/perf_fast.rb
284
+ - test/perf_file.rb
285
+ - test/perf_object.rb
286
+ - test/perf_saj.rb
254
287
  - test/perf_scp.rb
255
- - test/test_debian.rb
256
- - test/test_gc.rb
257
- - test/_test_mimic_rails.rb
258
- - test/test_writer.rb
259
- - test/test_hash.rb
288
+ - test/perf_simple.rb
289
+ - test/perf_strict.rb
290
+ - test/perf_wab.rb
291
+ - test/sample/change.rb
292
+ - test/sample/dir.rb
293
+ - test/sample/doc.rb
260
294
  - test/sample/file.rb
295
+ - test/sample/group.rb
261
296
  - test/sample/hasprops.rb
262
297
  - test/sample/layer.rb
263
- - test/sample/change.rb
264
- - test/sample/doc.rb
298
+ - test/sample/line.rb
265
299
  - test/sample/oval.rb
300
+ - test/sample/rect.rb
266
301
  - test/sample/shape.rb
267
302
  - test/sample/text.rb
268
- - test/sample/group.rb
269
- - test/sample/dir.rb
270
- - test/sample/line.rb
271
- - test/sample/rect.rb
272
- - test/tests.rb
273
- - test/test_object.rb
274
- - test/perf_wab.rb
275
- - test/tests_mimic.rb
276
- - test/perf_saj.rb
277
- - test/tests_mimic_addition.rb
278
- - test/test_saj.rb
279
303
  - test/sample.rb
280
- - test/test_scp.rb
281
- - test/perf_object.rb
282
- - test/perf_simple.rb
283
- - test/test_null.rb
284
- - test/_test_active_mimic.rb
285
- - test/_test_active.rb
286
- - test/test_compat.rb
287
304
  - test/sample_json.rb
288
- - test/json_gem/test_helper.rb
289
- - test/json_gem/json_generic_object_test.rb
290
- - test/json_gem/json_common_interface_test.rb
291
- - test/json_gem/json_string_matching_test.rb
292
- - test/json_gem/json_addition_test.rb
293
- - test/json_gem/json_fixtures_test.rb
294
- - test/json_gem/json_generator_test.rb
295
- - test/json_gem/json_ext_parser_test.rb
296
- - test/json_gem/json_parser_test.rb
297
- - test/json_gem/json_encoding_test.rb
298
- - test/helper.rb
299
- - test/activesupport4/test_helper.rb
300
- - test/activesupport4/decoding_test.rb
301
- - test/activesupport4/encoding_test.rb
302
- - test/test_wab.rb
303
- - test/perf_file.rb
304
- - test/perf_compat.rb
305
- - test/test_various.rb
306
- - test/test_strict.rb
305
+ - test/test_compat.rb
307
306
  - test/test_custom.rb
308
- - test/perf_strict.rb
309
- - test/perf_fast.rb
310
- - test/isolated/test_mimic_alone.rb
311
- - test/isolated/test_mimic_after.rb
312
- - test/isolated/test_mimic_as_json.rb
313
- - test/isolated/test_mimic_rails_after.rb
314
- - test/isolated/test_mimic_before.rb
315
- - test/isolated/test_mimic_rails_before.rb
316
- - test/isolated/test_mimic_define.rb
317
- - test/isolated/shared.rb
318
- - test/isolated/test_mimic_redefine.rb
319
- - test/perf.rb
307
+ - test/test_debian.rb
320
308
  - test/test_fast.rb
309
+ - test/test_file.rb
310
+ - test/test_gc.rb
311
+ - test/test_hash.rb
312
+ - test/test_null.rb
313
+ - test/test_object.rb
314
+ - test/test_saj.rb
315
+ - test/test_scp.rb
316
+ - test/test_strict.rb
317
+ - test/test_various.rb
318
+ - test/test_wab.rb
319
+ - test/test_writer.rb
320
+ - test/tests.rb
321
+ - test/tests_mimic.rb
322
+ - test/tests_mimic_addition.rb