brianmario-yajl-ruby 0.5.9 → 0.5.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/VERSION.yml +1 -1
- data/ext/yajl_ext.c +2 -5
- data/lib/yajl.rb +1 -1
- data/spec/json_gem_compatibility/compatibility_spec.rb +14 -0
- data/yajl-ruby.gemspec +2 -2
- metadata +2 -2
data/CHANGELOG.md
CHANGED
data/VERSION.yml
CHANGED
data/ext/yajl_ext.c
CHANGED
@@ -136,10 +136,6 @@ void yajl_encode_part(void * wrapper, VALUE obj, VALUE io) {
|
|
136
136
|
case T_STRING:
|
137
137
|
status = yajl_gen_string(w->encoder, (const unsigned char *)RSTRING_PTR(obj), (unsigned int)RSTRING_LEN(obj));
|
138
138
|
break;
|
139
|
-
case T_SYMBOL:
|
140
|
-
str = rb_funcall(obj, intern_to_s, 0);
|
141
|
-
status = yajl_gen_string(w->encoder, (const unsigned char *)RSTRING_PTR(str), (unsigned int)RSTRING_LEN(str));
|
142
|
-
break;
|
143
139
|
default:
|
144
140
|
if (rb_respond_to(obj, intern_to_json)) {
|
145
141
|
str = rb_funcall(obj, intern_to_json, 0);
|
@@ -584,7 +580,8 @@ static VALUE rb_yajl_json_ext_object_to_json(int argc, VALUE * argv, VALUE self)
|
|
584
580
|
if (rb_encoder == Qnil) {
|
585
581
|
rb_encoder = rb_yajl_encoder_new(0, NULL, cEncoder);
|
586
582
|
}
|
587
|
-
|
583
|
+
VALUE str = rb_funcall(self, intern_to_s, 0);
|
584
|
+
return rb_yajl_encoder_encode(1, &str, rb_encoder);
|
588
585
|
}
|
589
586
|
|
590
587
|
/*
|
data/lib/yajl.rb
CHANGED
@@ -53,6 +53,20 @@ describe "JSON Gem compatability API" do
|
|
53
53
|
JSON.default_options[:symbolize_keys] = default # ensure the rest of the test cases expect the default
|
54
54
|
end
|
55
55
|
|
56
|
+
it "should encode arbitrary classes via their default to_json method" do
|
57
|
+
d = Dummy.new
|
58
|
+
d.to_json.should == "\"#{d.to_s}\""
|
59
|
+
|
60
|
+
t = Time.now
|
61
|
+
t.to_json.should == "\"#{t.to_s}\""
|
62
|
+
|
63
|
+
da = Date.today
|
64
|
+
da.to_json.should == "\"#{da.to_s}\""
|
65
|
+
|
66
|
+
dt = DateTime.new
|
67
|
+
dt.to_json.should == "\"#{dt.to_s}\""
|
68
|
+
end
|
69
|
+
|
56
70
|
context "ported tests for Unicode" do
|
57
71
|
it "should be able to encode and parse unicode" do
|
58
72
|
pending if RUBY_VERSION.include?('1.9') # FIXME: Some string encoding problem with 1.9
|
data/yajl-ruby.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{yajl-ruby}
|
5
|
-
s.version = "0.5.
|
5
|
+
s.version = "0.5.10"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Brian Lopez", "Lloyd Hilaiel"]
|
9
|
-
s.date = %q{2009-07-
|
9
|
+
s.date = %q{2009-07-13}
|
10
10
|
s.email = %q{seniorlopez@gmail.com}
|
11
11
|
s.extensions = ["ext/extconf.rb"]
|
12
12
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brianmario-yajl-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Lopez
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-07-
|
13
|
+
date: 2009-07-13 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|