oj 2.5.2 → 2.5.3
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 +4 -4
- data/README.md +4 -0
- data/ext/oj/oj.c +18 -6
- data/lib/oj/version.rb +1 -1
- data/test/test_writer.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4165ecef265108d14800378477125c41841e728
|
4
|
+
data.tar.gz: 6ba913e644eba9a2aad1661b325bfab916eb5538
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 822357deaa522c3fcbf1971c6c5f791904d9b083afe8b8bea4c96a7f6bf7b2101bd0114c614e291943a9a8f48571824c49133f94a7dc1279c9e342e8a6d7f1e4
|
7
|
+
data.tar.gz: 5727942d444faa502f69bf3875e1c3c9b3176ea4fa2d6caaa26ed74cab3fea32d49780cf6e83687946d7d43bae91c3969efee2e3add96d77c011d78ed15c8869
|
data/README.md
CHANGED
@@ -20,6 +20,10 @@ Follow [@peterohler on Twitter](http://twitter.com/#!/peterohler) for announceme
|
|
20
20
|
|
21
21
|
[![Build Status](https://secure.travis-ci.org/ohler55/oj.png?branch=master)](http://travis-ci.org/ohler55/oj)
|
22
22
|
|
23
|
+
### Current Release 2.5.3
|
24
|
+
|
25
|
+
- Added support for blocks with StringWriter
|
26
|
+
|
23
27
|
### Current Release 2.5.2
|
24
28
|
|
25
29
|
- Fixed indent problem with StringWriter so it now indents properly
|
data/ext/oj/oj.c
CHANGED
@@ -895,22 +895,28 @@ str_writer_new(int argc, VALUE *argv, VALUE self) {
|
|
895
895
|
*/
|
896
896
|
static VALUE
|
897
897
|
str_writer_push_object(int argc, VALUE *argv, VALUE self) {
|
898
|
+
StrWriter sw = (StrWriter)DATA_PTR(self);
|
899
|
+
|
898
900
|
switch (argc) {
|
899
901
|
case 0:
|
900
|
-
oj_str_writer_push_object(
|
902
|
+
oj_str_writer_push_object(sw, 0);
|
901
903
|
break;
|
902
904
|
case 1:
|
903
905
|
if (Qnil == argv[0]) {
|
904
|
-
oj_str_writer_push_object(
|
906
|
+
oj_str_writer_push_object(sw, 0);
|
905
907
|
} else {
|
906
908
|
rb_check_type(argv[0], T_STRING);
|
907
|
-
oj_str_writer_push_object(
|
909
|
+
oj_str_writer_push_object(sw, StringValuePtr(argv[0]));
|
908
910
|
}
|
909
911
|
break;
|
910
912
|
default:
|
911
913
|
rb_raise(rb_eArgError, "Wrong number of argument to 'push_object'.");
|
912
914
|
break;
|
913
915
|
}
|
916
|
+
if (rb_block_given_p()) {
|
917
|
+
rb_yield(Qnil);
|
918
|
+
oj_str_writer_pop(sw);
|
919
|
+
}
|
914
920
|
return Qnil;
|
915
921
|
}
|
916
922
|
|
@@ -922,22 +928,28 @@ str_writer_push_object(int argc, VALUE *argv, VALUE self) {
|
|
922
928
|
*/
|
923
929
|
static VALUE
|
924
930
|
str_writer_push_array(int argc, VALUE *argv, VALUE self) {
|
931
|
+
StrWriter sw = (StrWriter)DATA_PTR(self);
|
932
|
+
|
925
933
|
switch (argc) {
|
926
934
|
case 0:
|
927
|
-
oj_str_writer_push_array(
|
935
|
+
oj_str_writer_push_array(sw, 0);
|
928
936
|
break;
|
929
937
|
case 1:
|
930
938
|
if (Qnil == argv[0]) {
|
931
|
-
oj_str_writer_push_array(
|
939
|
+
oj_str_writer_push_array(sw, 0);
|
932
940
|
} else {
|
933
941
|
rb_check_type(argv[0], T_STRING);
|
934
|
-
oj_str_writer_push_array(
|
942
|
+
oj_str_writer_push_array(sw, StringValuePtr(argv[0]));
|
935
943
|
}
|
936
944
|
break;
|
937
945
|
default:
|
938
946
|
rb_raise(rb_eArgError, "Wrong number of argument to 'push_object'.");
|
939
947
|
break;
|
940
948
|
}
|
949
|
+
if (rb_block_given_p()) {
|
950
|
+
rb_yield(Qnil);
|
951
|
+
oj_str_writer_pop(sw);
|
952
|
+
}
|
941
953
|
return Qnil;
|
942
954
|
}
|
943
955
|
|
data/lib/oj/version.rb
CHANGED
data/test/test_writer.rb
CHANGED
@@ -90,6 +90,20 @@ class OjWriter < ::Test::Unit::TestCase
|
|
90
90
|
|, w.to_s)
|
91
91
|
end
|
92
92
|
|
93
|
+
def test_string_writer_block
|
94
|
+
w = Oj::StringWriter.new(:indent => 0)
|
95
|
+
w.push_object() {
|
96
|
+
w.push_object("a1") {
|
97
|
+
w.push_value(7, 'a7')
|
98
|
+
}
|
99
|
+
w.push_array("a2") {
|
100
|
+
w.push_value('x')
|
101
|
+
w.push_value(3)
|
102
|
+
}
|
103
|
+
}
|
104
|
+
assert_equal('{"a1":{"a7":7},"a2":["x",3]}', w.to_s)
|
105
|
+
end
|
106
|
+
|
93
107
|
def test_string_writer_json
|
94
108
|
w = Oj::StringWriter.new(:indent => 0)
|
95
109
|
w.push_array()
|
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.5.
|
4
|
+
version: 2.5.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: 2014-01-
|
11
|
+
date: 2014-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'The fastest JSON parser and object serializer. '
|
14
14
|
email: peter@ohler.com
|