ffi-yajl 1.3.0-universal-java → 1.3.1-universal-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -1
- data/ext/ffi_yajl/ext/encoder/encoder.c +1 -1
- data/lib/ffi_yajl/ffi/encoder.rb +1 -1
- data/lib/ffi_yajl/version.rb +1 -1
- data/spec/ffi_yajl/encoder_spec.rb +17 -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: b53bc9d9531949a27cb05b5877baa594e691362f
|
4
|
+
data.tar.gz: dc3398cacd981441353db287b91fccdbf24266f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46f5f8029d0ef32c8c904f38093e422bfb7fd61078245c20f58997498d09df24a5ee212dda38cf745f97c3757709c0a229d41fa0eb6bc4e4787a18ff4cd1703f
|
7
|
+
data.tar.gz: 5528506311181bc998ce071935157f74c027313fb43af831fae27253016f271c5ea8b66315959f885132dc7b1d45c5b7a1c4080b9ac9e729977df90b0b7deebe
|
data/Rakefile
CHANGED
@@ -345,7 +345,7 @@ static VALUE rb_cObject_ffi_yajl(VALUE self, VALUE rb_yajl_gen, VALUE state) {
|
|
345
345
|
ID sym_to_json = rb_intern("to_json");
|
346
346
|
VALUE str;
|
347
347
|
|
348
|
-
if ( rb_respond_to(self, sym_to_json) ) {
|
348
|
+
if ( rb_hash_aref(state, rb_str_new2("processing_key")) != Qtrue && rb_respond_to(self, sym_to_json) ) {
|
349
349
|
VALUE json_opts = rb_hash_aref(state, rb_str_new2("json_opts"));
|
350
350
|
struct yajl_gen_t *yajl_gen;
|
351
351
|
Data_Get_Struct(rb_yajl_gen, struct yajl_gen_t, yajl_gen);
|
data/lib/ffi_yajl/ffi/encoder.rb
CHANGED
@@ -236,7 +236,7 @@ end
|
|
236
236
|
# I feel dirty
|
237
237
|
class Object
|
238
238
|
def ffi_yajl(yajl_gen, state)
|
239
|
-
if self.respond_to?(:to_json)
|
239
|
+
if !state[:processing_key] && self.respond_to?(:to_json)
|
240
240
|
json = self.to_json(state[:json_opts])
|
241
241
|
# #yajl_gen_number outputs a string without quotes around it
|
242
242
|
status = FFI_Yajl.yajl_gen_number(yajl_gen, json, json.bytesize)
|
data/lib/ffi_yajl/version.rb
CHANGED
@@ -47,6 +47,23 @@ describe "FFI_Yajl::Encoder" do
|
|
47
47
|
expect(encoder.encode(ruby)).to eq('{"12345678901234567890":2}')
|
48
48
|
end
|
49
49
|
|
50
|
+
it "encodes objects in keys as strings" do
|
51
|
+
o = Object.new
|
52
|
+
ruby = { o => 2 }
|
53
|
+
expect(encoder.encode(ruby)).to eq(%Q{{"#{o.to_s}":2}})
|
54
|
+
end
|
55
|
+
|
56
|
+
it "encodes an object in a key which has a #to_json method as strings" do
|
57
|
+
class Thing
|
58
|
+
def to_json(*a)
|
59
|
+
"{}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
o = Thing.new
|
63
|
+
ruby = { o => 2 }
|
64
|
+
expect(encoder.encode(ruby)).to eq(%Q{{"#{o.to_s}":2}})
|
65
|
+
end
|
66
|
+
|
50
67
|
# XXX: 127 == YAJL_MAX_DEPTH hardcodedness, zero control for us, it isn't even a twiddleable #define
|
51
68
|
it "raises an exception for deeply nested arrays" do
|
52
69
|
root = []
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-yajl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: universal-java
|
6
6
|
authors:
|
7
7
|
- Lamont Granquist
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|