ffi-yajl 1.3.0 → 1.3.1

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: a8b85bcd696b335e58ae66d7d6152d8c82712d64
4
- data.tar.gz: 97199ad459ab9d164231563dc91fe26d4923c22f
3
+ metadata.gz: 010f67d48fdc7e489a8ca807819f76d4f678c7d7
4
+ data.tar.gz: dc3398cacd981441353db287b91fccdbf24266f3
5
5
  SHA512:
6
- metadata.gz: 32dca551da8cd71f0674033e1816d65eb3b245291dd4b63d5431248ae43f6ba4e407019030cbd46f20a81cd632315c9e03c4056d6891ef66aed6f5699ad2e64a
7
- data.tar.gz: c4e9a16d122714c1446e82993ac4b979aaf4ad0373b1110581ac5fb683c767908ae90dace4aafb1d89456c858945e62004bae3975c92d8de5e6695c169b6b077
6
+ metadata.gz: 06c1b64a2568cb90acada91dc9c3194b50d0fc8a671db94d1101943d77cd3fe1eed0918a02297455958b0708d456374b9affb84f4dd8c7b49a48ab25186a95f0
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: ruby
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