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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78b174d432e532e7ce493e825ab04fb81732d0e8
4
- data.tar.gz: 97199ad459ab9d164231563dc91fe26d4923c22f
3
+ metadata.gz: b53bc9d9531949a27cb05b5877baa594e691362f
4
+ data.tar.gz: dc3398cacd981441353db287b91fccdbf24266f3
5
5
  SHA512:
6
- metadata.gz: 417f7f79a50826cd7315ba893bfe01c3e16fc615a368af5c37b471de854ba036013deea0eb382fd3dcd50c81b2d32e322bcc9549c479c5b9c93daabd3cfb2802
7
- data.tar.gz: c4e9a16d122714c1446e82993ac4b979aaf4ad0373b1110581ac5fb683c767908ae90dace4aafb1d89456c858945e62004bae3975c92d8de5e6695c169b6b077
6
+ metadata.gz: 46f5f8029d0ef32c8c904f38093e422bfb7fd61078245c20f58997498d09df24a5ee212dda38cf745f97c3757709c0a229d41fa0eb6bc4e4787a18ff4cd1703f
7
+ data.tar.gz: 5528506311181bc998ce071935157f74c027313fb43af831fae27253016f271c5ea8b66315959f885132dc7b1d45c5b7a1c4080b9ac9e729977df90b0b7deebe
data/Rakefile CHANGED
@@ -22,7 +22,8 @@ end
22
22
  unix_gemspec = eval(File.read("ffi-yajl.gemspec"))
23
23
 
24
24
  task :clean do
25
- sh "rm -rf pkg/* lib/ffi_yajl/ext/*"
25
+ sh "rm -f Gemfile.lock"
26
+ sh "rm -rf pkg/* tmp/* .bundle lib/ffi_yajl/ext/*"
26
27
  end
27
28
 
28
29
  desc "install the gem locally"
@@ -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);
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module FFI_Yajl
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.1"
3
3
  end
@@ -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.0
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-23 00:00:00.000000000 Z
11
+ date: 2014-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake