oj 2.7.0 → 2.7.1

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: 874c4d47513efdd1f1a64da2ddfe403009f683bc
4
- data.tar.gz: 16969c09038d314da516230b5ed45787cc05f4cd
3
+ metadata.gz: d543163764b5c7910fcbd77662a531acb56d8cff
4
+ data.tar.gz: f9c6554f24fc5ccf9ea95b755e009ddfbd603567
5
5
  SHA512:
6
- metadata.gz: 5192373bff2623463ab580cf32b54a45ba380e66a16d342de37b79655c94d6e4ef61180e9332023d6601bc7243ba3f1a594d3a6ad427f0ceb79e2211d070e7b1
7
- data.tar.gz: 6457b838b18ad5b580b096db8f2ed5c474cc7a7841dd6c2fcde90360a2ec861c7ef0b33a63580339c0735a0f6822a75bdc35d88ed1b8cdd99360f5d85d7e645a
6
+ metadata.gz: b4363a5dab53fe54977632c92caec3a77e304893a70230066dfc3332c81b570e82715140330e4affcb0e69f6094c108b563675873bdd1896a667fa757d6f8249
7
+ data.tar.gz: 4c7cdfcb15522a3ced05947997f31e30d2a55b2386456ea2279eb48852cbac08b8bd6378115b2f835beea264c0aea34d616c2d0ad2d7d5257506526d36fcb7ed
data/README.md CHANGED
@@ -26,6 +26,10 @@ 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.7.1
30
+
31
+ - Fixed bug in new push_key which caused duplicate characters.
32
+
29
33
  ### Current Release 2.7.0
30
34
 
31
35
  - Added the push_key() method to the StringWriter and StreamWriter classes.
@@ -2053,6 +2053,9 @@ oj_str_writer_push_key(StrWriter sw, const char *key) {
2053
2053
  DumpType type = sw->types[sw->depth];
2054
2054
  long size;
2055
2055
 
2056
+ if (sw->keyWritten) {
2057
+ rb_raise(rb_eStandardError, "Can not push more than one key before pushing a non-key.");
2058
+ }
2056
2059
  if (ObjectNew != type && ObjectType != type) {
2057
2060
  rb_raise(rb_eStandardError, "Can only push a key onto an Object.");
2058
2061
  }
@@ -2073,6 +2076,9 @@ void
2073
2076
  oj_str_writer_push_object(StrWriter sw, const char *key) {
2074
2077
  if (sw->keyWritten) {
2075
2078
  sw->keyWritten = 0;
2079
+ if (sw->out.end - sw->out.cur <= 1) {
2080
+ grow(&sw->out, 1);
2081
+ }
2076
2082
  } else {
2077
2083
  long size;
2078
2084
 
@@ -2098,6 +2104,9 @@ void
2098
2104
  oj_str_writer_push_array(StrWriter sw, const char *key) {
2099
2105
  if (sw->keyWritten) {
2100
2106
  sw->keyWritten = 0;
2107
+ if (sw->out.end - sw->out.cur <= 1) {
2108
+ grow(&sw->out, 1);
2109
+ }
2101
2110
  } else {
2102
2111
  long size;
2103
2112
 
@@ -1187,6 +1187,7 @@ stream_writer_push_key(VALUE self, VALUE key) {
1187
1187
  StreamWriter sw = (StreamWriter)DATA_PTR(self);
1188
1188
 
1189
1189
  rb_check_type(key, T_STRING);
1190
+ stream_writer_reset_buf(sw);
1190
1191
  oj_str_writer_push_key(&sw->sw, StringValuePtr(key));
1191
1192
  stream_writer_write(sw);
1192
1193
  return Qnil;
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '2.7.0'
4
+ VERSION = '2.7.1'
5
5
  end
@@ -61,7 +61,7 @@ class OjWriter < ::Test::Unit::TestCase
61
61
  assert_equal('{"a1":{},"a2":{"b":{}},"a3":{}}', w.to_s)
62
62
  end
63
63
 
64
- def test_string_writer_nested_key_object
64
+ def test_string_writer_nested_key
65
65
  w = Oj::StringWriter.new(:indent => 0)
66
66
  w.push_object()
67
67
  w.push_key('a1')
@@ -74,9 +74,11 @@ class OjWriter < ::Test::Unit::TestCase
74
74
  w.pop()
75
75
  w.push_key('a3')
76
76
  w.push_object()
77
+ w.push_key('a4')
78
+ w.push_value(37)
77
79
  w.pop()
78
80
  w.pop()
79
- assert_equal('{"a1":{},"a2":{"b":{}},"a3":{}}', w.to_s)
81
+ assert_equal('{"a1":{},"a2":{"b":{}},"a3":{"a4":37}}', w.to_s)
80
82
  end
81
83
 
82
84
  def test_string_writer_value_array
@@ -268,4 +270,25 @@ class OjWriter < ::Test::Unit::TestCase
268
270
  assert_equal('{"a1":{},"a2":{"b":[7,true,"string"]},"a3":{}}', content)
269
271
  end
270
272
 
273
+ def test_stream_writer_nested_key_object
274
+ output = StringIO.open("", "w+")
275
+ w = Oj::StreamWriter.new(output, :indent => 0)
276
+ w.push_object()
277
+ w.push_key('a1')
278
+ w.push_object()
279
+ w.pop()
280
+ w.push_key('a2')
281
+ w.push_object('x')
282
+ w.push_object('b')
283
+ w.pop()
284
+ w.pop()
285
+ w.push_key('a3')
286
+ w.push_object()
287
+ w.push_key('a4')
288
+ w.push_value(37)
289
+ w.pop()
290
+ w.pop()
291
+ assert_equal('{"a1":{},"a2":{"b":{}},"a3":{"a4":37}}', output.string())
292
+ end
293
+
271
294
  end # OjWriter
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.7.0
4
+ version: 2.7.1
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-03-29 00:00:00.000000000 Z
11
+ date: 2014-03-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'The fastest JSON parser and object serializer. '
14
14
  email: peter@ohler.com