oj 2.11.1 → 2.11.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of oj might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d3e4872cc8b3155f8547f4ab99ad2f0767ba878
4
- data.tar.gz: 5ca0ea5af332edfdda45af2deca6323543395bfb
3
+ metadata.gz: f27c42c67b86cac4812b8452cbc81242a348e8e0
4
+ data.tar.gz: 71dd249f7dccc0136180b8661e6f33208025c237
5
5
  SHA512:
6
- metadata.gz: 951e8ce648c1afb634ef3b4b21387043dd918cc513b3f26c7966c5ef08c6ee03b41cb531ecc7065ac667612e334870a4ff3eac063606a626f799ea6a84ef3b24
7
- data.tar.gz: 8c3fa952247342e7f58ce3c6a0966beba3dc89701a15fd72affa1cdcd1c2c5542df07db734753499cb363d51fba4a63e569ff31765cab006615d592c369ce60a
6
+ metadata.gz: c033fbec5b0af79396795bb4d1dd8c4be2984d27c1d87d008c7994e3fcd46f1e2f41caa85b0a3d0b9f0642ab9abac643c8c014e4b01c186775b3454797adb25b
7
+ data.tar.gz: 61d7bb7f02ddeaf63b94d6f27bfbc496a4d3a15f1fb85b714119d34762bcc432b80fa668c68cc65f2c55608d0bd3dc47b35d112477c2a43198fc500ffd7728a2
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2012 Peter Ohler
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -26,7 +26,15 @@ Follow [@peterohler on Twitter](http://twitter.com/#!/peterohler) for announceme
26
26
 
27
27
  [![Build Status](https://secure.travis-ci.org/ohler55/oj.png?branch=master)](http://travis-ci.org/ohler55/oj)
28
28
 
29
- ### Current Release 2.11.1
29
+ ## Current Release 2.11.2
30
+
31
+ - Changed the defaults for mimic_JSON to use 16 significant digits instead of
32
+ the default 15.
33
+
34
+ - Fixed bug where a subclass of Array would be serialized as if in object mode
35
+ instead of compat when in compat mode.
36
+
37
+ ### Release 2.11.1
30
38
 
31
39
  - Changed the use_to_json option to still allow as_json even when set to false.
32
40
 
@@ -654,7 +654,7 @@ dump_array(VALUE a, VALUE clas, int depth, Out out) {
654
654
  if (id < 0) {
655
655
  return;
656
656
  }
657
- if (Qundef != clas && rb_cArray != clas) {
657
+ if (Qundef != clas && rb_cArray != clas && ObjectMode == out->opts->mode) {
658
658
  dump_obj_attrs(a, clas, 0, depth, out);
659
659
  return;
660
660
  }
@@ -1760,7 +1760,7 @@ static struct _Options mimic_object_to_json_options = {
1760
1760
  No, // class_cache
1761
1761
  RubyTime, // time_format
1762
1762
  No, // bigdec_as_num
1763
- AutoDec, // bigdec_load
1763
+ FloatDec, // bigdec_load
1764
1764
  No, // to_json
1765
1765
  Yes, // nilnil
1766
1766
  Yes, // allow_gc
@@ -1769,8 +1769,8 @@ static struct _Options mimic_object_to_json_options = {
1769
1769
  10, // create_id_len
1770
1770
  9, // sec_prec
1771
1771
  0, // dump_opts
1772
- 15, // float_prec
1773
- "%0.15g", // float_fmt
1772
+ 16, // float_prec
1773
+ "%0.16g", // float_fmt
1774
1774
  };
1775
1775
 
1776
1776
  static VALUE
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '2.11.1'
4
+ VERSION = '2.11.2'
5
5
  end
@@ -4,7 +4,7 @@
4
4
  $: << File.dirname(__FILE__)
5
5
 
6
6
  require 'helper'
7
- Oj.mimic_JSON
7
+ #Oj.mimic_JSON
8
8
  require 'rails/all'
9
9
 
10
10
  require 'active_model'
@@ -15,7 +15,7 @@ require 'active_support/all'
15
15
 
16
16
  require 'oj/active_support_helper'
17
17
 
18
- #Oj.mimic_JSON
18
+ Oj.mimic_JSON
19
19
 
20
20
  class Category
21
21
  include ActiveModel::Model
@@ -4,6 +4,7 @@
4
4
  $: << File.dirname(__FILE__)
5
5
 
6
6
  require 'helper'
7
+ require 'socket'
7
8
 
8
9
  $json = %{{
9
10
  "array": [
@@ -71,6 +72,25 @@ class AllHandler < Oj::ScHandler
71
72
 
72
73
  end # AllHandler
73
74
 
75
+ class Closer < AllHandler
76
+ def initialize(io)
77
+ super()
78
+ @io = io
79
+ end
80
+
81
+ def hash_start()
82
+ @calls << [:hash_start]
83
+ @io.close
84
+ {}
85
+ end
86
+
87
+ def hash_set(h, key, value)
88
+ @calls << [:hash_set, key, value]
89
+ @io.close
90
+ end
91
+
92
+ end # Closer
93
+
74
94
  class ScpTest < Minitest::Test
75
95
 
76
96
  def setup
@@ -303,4 +323,52 @@ class ScpTest < Minitest::Test
303
323
  end
304
324
  end
305
325
 
326
+ def test_pipe_close
327
+ json = %{{"one":true,"two":false}}
328
+ IO.pipe do |read_io, write_io|
329
+ if fork
330
+ write_io.close
331
+ handler = Closer.new(read_io)
332
+ err = nil
333
+ begin
334
+ Oj.sc_parse(handler, read_io)
335
+ read_io.close
336
+ rescue Exception => e
337
+ err = e.class.to_s
338
+ end
339
+ assert_equal("IOError", err)
340
+ assert_equal([[:hash_start],
341
+ [:hash_key, 'one'],
342
+ [:hash_set, 'one', true]], handler.calls)
343
+ else
344
+ read_io.close
345
+ write_io.write json
346
+ write_io.close
347
+ Process.exit(0)
348
+ end
349
+ end
350
+ end
351
+
352
+ def test_socket_close
353
+ json = %{{"one":true,"two":false}}
354
+ Thread.start(json) do |j|
355
+ server = TCPServer.new(6969)
356
+ c = server.accept()
357
+ c.puts json
358
+ c.close
359
+ end
360
+ sock = TCPSocket.new('localhost', 6969)
361
+ handler = Closer.new(sock)
362
+ err = nil
363
+ begin
364
+ Oj.sc_parse(handler, sock)
365
+ rescue Exception => e
366
+ err = e.class.to_s
367
+ end
368
+ assert_equal("IOError", err)
369
+ assert_equal([[:hash_start],
370
+ [:hash_key, 'one'],
371
+ [:hash_set, 'one', true]], handler.calls)
372
+ end
373
+
306
374
  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: 2.11.1
4
+ version: 2.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-09 00:00:00.000000000 Z
11
+ date: 2015-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -60,6 +60,7 @@ extensions:
60
60
  extra_rdoc_files:
61
61
  - README.md
62
62
  files:
63
+ - LICENSE
63
64
  - README.md
64
65
  - ext/oj/buf.h
65
66
  - ext/oj/cache8.c
@@ -178,9 +179,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
179
  version: '0'
179
180
  requirements: []
180
181
  rubyforge_project: oj
181
- rubygems_version: 2.2.2
182
+ rubygems_version: 2.4.5
182
183
  signing_key:
183
184
  specification_version: 4
184
185
  summary: A fast JSON parser and serializer.
185
186
  test_files: []
186
- has_rdoc: true