yajl-ruby 0.5.10 → 0.5.11

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of yajl-ruby might be problematic. Click here for more details.

@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.11 (July 14th, 2009)
4
+ * fixing a bug Aman found with to_json on non-primitive Ruby objects and double-quoting in the JSON compat API
5
+
3
6
  ## 0.5.10 (July 13th, 2009)
4
7
  * Bugfix for the JSON gem compatibility API's default Object#to_json helper
5
8
 
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 10
2
+ :patch: 11
3
3
  :major: 0
4
4
  :minor: 5
@@ -562,28 +562,6 @@ static VALUE rb_yajl_encoder_set_progress_cb(VALUE self, VALUE callback) {
562
562
 
563
563
  // JSON Gem compatibility
564
564
 
565
- /*
566
- * Document-class: Object
567
- */
568
- /*
569
- * Document-method: to_json
570
- *
571
- * call-seq: to_json(encoder=Yajl::Encoder.new)
572
- *
573
- * +encoder+ is an existing Yajl::Encoder used to encode JSON
574
- *
575
- * Encodes an instance of Object to JSON
576
- */
577
- static VALUE rb_yajl_json_ext_object_to_json(int argc, VALUE * argv, VALUE self) {
578
- VALUE rb_encoder;
579
- rb_scan_args(argc, argv, "01", &rb_encoder);
580
- if (rb_encoder == Qnil) {
581
- rb_encoder = rb_yajl_encoder_new(0, NULL, cEncoder);
582
- }
583
- VALUE str = rb_funcall(self, intern_to_s, 0);
584
- return rb_yajl_encoder_encode(1, &str, rb_encoder);
585
- }
586
-
587
565
  /*
588
566
  * Document-class: Hash
589
567
  */
@@ -763,7 +741,6 @@ static VALUE rb_yajl_json_ext_nil_to_json(int argc, VALUE * argv, VALUE self) {
763
741
  * Enables the JSON gem compatibility API
764
742
  */
765
743
  static VALUE rb_yajl_encoder_enable_json_gem_ext(VALUE klass) {
766
- rb_define_method(rb_cObject, "to_json", rb_yajl_json_ext_object_to_json, -1);
767
744
  rb_define_method(rb_cHash, "to_json", rb_yajl_json_ext_hash_to_json, -1);
768
745
  rb_define_method(rb_cArray, "to_json", rb_yajl_json_ext_array_to_json, -1);
769
746
  rb_define_method(rb_cFixnum, "to_json", rb_yajl_json_ext_fixnum_to_json, -1);
@@ -71,7 +71,6 @@ static VALUE rb_yajl_encoder_set_progress_cb(VALUE self, VALUE callback);
71
71
  static void yajl_encoder_wrapper_free(void * wrapper);
72
72
  static void yajl_encoder_wrapper_mark(void * wrapper);
73
73
 
74
- static VALUE rb_yajl_json_ext_object_to_json(int argc, VALUE * argv, VALUE self);
75
74
  static VALUE rb_yajl_json_ext_hash_to_json(int argc, VALUE * argv, VALUE self);
76
75
  static VALUE rb_yajl_json_ext_array_to_json(int argc, VALUE * argv, VALUE self);
77
76
  static VALUE rb_yajl_json_ext_fixnum_to_json(int argc, VALUE * argv, VALUE self);
@@ -13,7 +13,7 @@ require 'yajl_ext'
13
13
  #
14
14
  # Ruby bindings to the excellent Yajl (Yet Another JSON Parser) ANSI C library.
15
15
  module Yajl
16
- VERSION = "0.5.10"
16
+ VERSION = "0.5.11"
17
17
 
18
18
  class Parser
19
19
  # A helper method for parse-and-forget use-cases
@@ -5,6 +5,13 @@ require 'yajl' unless defined?(Yajl::Parser)
5
5
  # extension that can be included when this file is.
6
6
  Yajl::Encoder.enable_json_gem_compatability
7
7
 
8
+ # Our fallback to_json definition
9
+ class Object
10
+ def to_json(*args, &block)
11
+ to_s
12
+ end
13
+ end
14
+
8
15
  module JSON
9
16
  def self.generate(obj, opts={})
10
17
  begin
@@ -19,7 +19,7 @@ describe "JSON Gem compatability API" do
19
19
  end
20
20
 
21
21
  it "should mixin #to_json on base objects after compatability has been enabled" do
22
- Yajl::Encoder.enable_json_gem_compatability
22
+ require 'yajl/json_gem'
23
23
  d = Dummy.new
24
24
 
25
25
  d.respond_to?(:to_json).should be_true
@@ -34,8 +34,6 @@ describe "JSON Gem compatability API" do
34
34
  end
35
35
 
36
36
  it "should require yajl/json_gem to enable the compatability API" do
37
- require 'yajl/json_gem'
38
-
39
37
  defined?(JSON).should be_true
40
38
 
41
39
  JSON.respond_to?(:parse).should be_true
@@ -55,16 +53,16 @@ describe "JSON Gem compatability API" do
55
53
 
56
54
  it "should encode arbitrary classes via their default to_json method" do
57
55
  d = Dummy.new
58
- d.to_json.should == "\"#{d.to_s}\""
56
+ d.to_json.should == "#{d.to_s}"
59
57
 
60
58
  t = Time.now
61
- t.to_json.should == "\"#{t.to_s}\""
59
+ t.to_json.should == "#{t.to_s}"
62
60
 
63
61
  da = Date.today
64
- da.to_json.should == "\"#{da.to_s}\""
62
+ da.to_json.should == "#{da.to_s}"
65
63
 
66
64
  dt = DateTime.new
67
- dt.to_json.should == "\"#{dt.to_s}\""
65
+ dt.to_json.should == "#{dt.to_s}"
68
66
  end
69
67
 
70
68
  context "ported tests for Unicode" do
@@ -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.10"
5
+ s.version = "0.5.11"
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-13}
9
+ s.date = %q{2009-07-14}
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: yajl-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.10
4
+ version: 0.5.11
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 00:00:00 -07:00
13
+ date: 2009-07-14 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16