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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 220d1012a368e139d601519ae2bde0835b574a44
4
- data.tar.gz: e792b43ad00c9d8c592221e136b433d2ac1525cf
3
+ metadata.gz: c4165ecef265108d14800378477125c41841e728
4
+ data.tar.gz: 6ba913e644eba9a2aad1661b325bfab916eb5538
5
5
  SHA512:
6
- metadata.gz: 105d031b3ed97c598a828537304adbd344c43aafaf1a79793cdabe51823a6a1d3a1bb7aafce6022ffa732f355141a4061ca6f8bc33dc00b9be584ad5baf51270
7
- data.tar.gz: 3ff635338d57dd897511bbabe746fcde5db77629f8ffd10d4441f1e81e5a24a22ff64f386cd6da0e8410d3c25fc504b4fffb29f57a313339eb9daa6397abcf9a
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
@@ -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((StrWriter)DATA_PTR(self), 0);
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((StrWriter)DATA_PTR(self), 0);
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((StrWriter)DATA_PTR(self), StringValuePtr(argv[0]));
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((StrWriter)DATA_PTR(self), 0);
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((StrWriter)DATA_PTR(self), 0);
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((StrWriter)DATA_PTR(self), StringValuePtr(argv[0]));
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
 
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '2.5.2'
4
+ VERSION = '2.5.3'
5
5
  end
@@ -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.2
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-02 00:00:00.000000000 Z
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