From 1f7ab6a1204170a62d9c2cf77903579e2f25ed0e Mon Sep 17 00:00:00 2001 From: Chris Caselas Date: Fri, 14 Jun 2013 13:24:45 -0700 Subject: [PATCH 1/3] Replace multi_json gem with stdlib JSON. As of June 2013, multi_json will no longer be maintained. --- Gemfile | 1 - README.md | 3 ++- httparty.gemspec | 1 - lib/httparty.rb | 2 +- lib/httparty/parser.rb | 7 +------ spec/httparty/parser_spec.rb | 10 ++-------- 6 files changed, 6 insertions(+), 18 deletions(-) diff --git a/Gemfile b/Gemfile index f05b78c5..576d1128 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,6 @@ gem 'cucumber', '~> 0.7' gem 'fakeweb', '~> 1.2' gem 'rspec', '~> 1.3' gem 'mongrel', '1.2.0.pre2' -gem 'multi_json', '~> 1.3' group :development do gem 'guard' diff --git a/README.md b/README.md index 3a0fb71d..6b774042 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,8 @@ gem install httparty ## Requirements -* multi_json and multi_xml +* Ruby 1.9 or higher +* multi_xml * You like to party! ## Examples diff --git a/httparty.gemspec b/httparty.gemspec index 03297174..d518e89d 100644 --- a/httparty.gemspec +++ b/httparty.gemspec @@ -12,7 +12,6 @@ Gem::Specification.new do |s| s.summary = %q{Makes http fun! Also, makes consuming restful web services dead easy.} s.description = %q{Makes http fun! Also, makes consuming restful web services dead easy.} - s.add_dependency 'multi_json', "~> 1.0" s.add_dependency 'multi_xml', ">= 0.5.2" s.post_install_message = "When you HTTParty, you must party hard!" diff --git a/lib/httparty.rb b/lib/httparty.rb index 5bc5af9e..4f2bd006 100644 --- a/lib/httparty.rb +++ b/lib/httparty.rb @@ -4,7 +4,7 @@ require 'uri' require 'zlib' require 'multi_xml' -require 'multi_json' +require 'json' require 'httparty/module_inheritable_attributes' require 'httparty/cookie_hash' diff --git a/lib/httparty/parser.rb b/lib/httparty/parser.rb index 42c218ed..76a103a2 100644 --- a/lib/httparty/parser.rb +++ b/lib/httparty/parser.rb @@ -110,12 +110,7 @@ def xml end def json - # https://github.com/sferik/rails/commit/5e62670131dfa1718eaf21ff8dd3371395a5f1cc - if MultiJson.respond_to?(:adapter) - MultiJson.load(body) - else - MultiJson.decode(body) - end + JSON.load(body, nil) end def html diff --git a/spec/httparty/parser_spec.rb b/spec/httparty/parser_spec.rb index 4d6813d4..23f5770c 100644 --- a/spec/httparty/parser_spec.rb +++ b/spec/httparty/parser_spec.rb @@ -144,14 +144,8 @@ def self.name; 'AtomParser'; end subject.send(:xml) end - it "parses json with MultiJson" do - MultiJson.should_receive(:load).with('body') - subject.send(:json) - end - - it "uses MultiJson.decode if MultiJson does not respond to adapter" do - MultiJson.should_receive(:respond_to?).with(:adapter).and_return(false) - MultiJson.should_receive(:decode).with('body') + it "parses json with JSON" do + JSON.should_receive(:load).with('body', nil) subject.send(:json) end From aed9e0d21eecb25a4e9fb50df5c72ecc7f3ebb84 Mon Sep 17 00:00:00 2001 From: Chris Caselas Date: Fri, 14 Jun 2013 13:32:32 -0700 Subject: [PATCH 2/3] Require ruby 1.9.3 or higher. --- README.md | 2 +- httparty.gemspec | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6b774042..60099a19 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ gem install httparty ## Requirements -* Ruby 1.9 or higher +* Ruby 1.9.3 or higher * multi_xml * You like to party! diff --git a/httparty.gemspec b/httparty.gemspec index d518e89d..e488af37 100644 --- a/httparty.gemspec +++ b/httparty.gemspec @@ -12,6 +12,8 @@ Gem::Specification.new do |s| s.summary = %q{Makes http fun! Also, makes consuming restful web services dead easy.} s.description = %q{Makes http fun! Also, makes consuming restful web services dead easy.} + s.required_ruby_version = '>= 1.9.3' + s.add_dependency 'multi_xml', ">= 0.5.2" s.post_install_message = "When you HTTParty, you must party hard!" From 1cbb101feaffcc1f11c77a71009558c6086ebb4b Mon Sep 17 00:00:00 2001 From: Chris Caselas Date: Fri, 14 Jun 2013 13:43:23 -0700 Subject: [PATCH 3/3] Latest json gem is a dependency. --- httparty.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/httparty.gemspec b/httparty.gemspec index e488af37..6379c476 100644 --- a/httparty.gemspec +++ b/httparty.gemspec @@ -14,6 +14,7 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 1.9.3' + s.add_dependency 'json', "~> 1.8" s.add_dependency 'multi_xml', ">= 0.5.2" s.post_install_message = "When you HTTParty, you must party hard!"