Permalink
Browse files

Swapped Yajl/JSON for MultiJson , fixes #1

  • Loading branch information...
1 parent 31e1be5 commit d72dfaeba8904fa46ca41d157851a9dd4d3d6dd4 @Sija committed Sep 25, 2012
View
5 Gemfile.lock
@@ -1,8 +1,9 @@
PATH
remote: .
specs:
- garb (0.9.4)
- activesupport (>= 2.2.0)
+ garb (0.9.5)
+ activesupport (>= 2.2)
+ multi_json (>= 1.3)
GEM
remote: http://rubygems.org/
View
3 garb.gemspec
@@ -16,5 +16,6 @@ Gem::Specification.new do |gem|
gem.require_paths = ['lib']
gem.version = Garb::VERSION
- gem.add_dependency 'activesupport', '>= 2.2.0'
+ gem.add_dependency 'activesupport', '>= 2.2'
+ gem.add_dependency 'multi_json', '>= 1.3'
end
View
6 lib/garb.rb
@@ -6,11 +6,7 @@
require 'cgi'
require 'ostruct'
-begin
- require 'yajl/json_gem' # JSON.parse
-rescue LoadError
- require 'json'
-end
+require 'multi_json'
module Garb
autoload :VERSION, 'garb/version'
View
2 lib/garb/management/feed.rb
@@ -10,7 +10,7 @@ def initialize(session, path)
end
def parsed_response
- @parsed_response ||= JSON.parse(response.body)
+ @parsed_response ||= MultiJson.load(response.body)
end
def entries
View
2 lib/garb/report_response.rb
@@ -44,7 +44,7 @@ def rows
def data
unless @data
- @data = JSON.parse @response_body
+ @data = MultiJson.load @response_body
@data = @data.inject({}) do |data, pair|
key, value = pair
data[key.underscore.to_sym] = value
View
2 lib/garb/request/data.rb
@@ -32,7 +32,7 @@ def send_request
Garb.log "Garb::Response -> #{response.inspect}"
unless response.kind_of?(Net::HTTPSuccess) || (response.respond_to?(:status) && response.status == 200)
- body, parsed = response.body, JSON.parse(body) rescue nil
+ body, parsed = response.body, MultiJson.load(body) rescue nil
if parsed and error = parsed['error']
klass = case error['code']
when 400 then BadRequestError
View
2 test/unit/garb/management/account_test.rb
@@ -19,7 +19,7 @@ class AccountTest < MiniTest::Unit::TestCase
context "an Account" do
setup do
- entry = JSON.parse(read_fixture("account_management.json"))['items'].first
+ entry = MultiJson.load(read_fixture("account_management.json"))['items'].first
@account = Account.new(entry, Session)
end
View
4 test/unit/garb/management/feed_test.rb
@@ -11,11 +11,11 @@ class FeedTest < MiniTest::Unit::TestCase
end
should "have a parsed response" do
- JSON.stubs(:parse)
+ MultiJson.stubs(:load)
@feed.stubs(:response).returns(stub(:body => 'response body'))
@feed.parsed_response
- assert_received(JSON, :parse) {|e| e.with('response body')}
+ assert_received(MultiJson, :load) {|e| e.with('response body')}
end
should "have entries from the parsed response" do
View
2 test/unit/garb/management/goal_test.rb
@@ -37,7 +37,7 @@ class GoalTest < MiniTest::Unit::TestCase
context "a Goal" do
setup do
- entry = JSON.parse(read_fixture("goal_management.json"))["items"].first
+ entry = MultiJson.load(read_fixture("goal_management.json"))["items"].first
@goal = Goal.new(entry, Session)
end
View
2 test/unit/garb/management/profile_test.rb
@@ -31,7 +31,7 @@ class ProfileTest < MiniTest::Unit::TestCase
context "A Profile" do
setup do
- entry = JSON.parse(read_fixture("ga_profile_management.json"))["items"].first
+ entry = MultiJson.load(read_fixture("ga_profile_management.json"))["items"].first
@profile = Profile.new(entry, Session)
end
View
2 test/unit/garb/management/segment_test.rb
@@ -27,7 +27,7 @@ class SegmentTest < MiniTest::Unit::TestCase
"dxp:definition" => "ga:visitorType==Returning Visitor"
}
}
- entry = JSON.parse(read_fixture("ga_segment_management.json"))["items"].first
+ entry = MultiJson.load(read_fixture("ga_segment_management.json"))["items"].first
@segment = Segment.new(entry, Session)
end
View
2 test/unit/garb/management/web_property_test.rb
@@ -28,7 +28,7 @@ class WebPropertyTest < MiniTest::Unit::TestCase
context "a WebProperty" do
setup do
- entry = JSON.parse(read_fixture("ga_webproperty_management.json"))["items"].first
+ entry = MultiJson.load(read_fixture("ga_webproperty_management.json"))["items"].first
@web_property = WebProperty.new(entry, Session)
end
View
2 test/unit/garb/model_test.rb
@@ -41,7 +41,7 @@ class ModelTest < MiniTest::Unit::TestCase
context "with a profile" do
setup do
- entry = JSON.parse(read_fixture("ga_profile_management.json"))["items"].first
+ entry = MultiJson.load(read_fixture("ga_profile_management.json"))["items"].first
@profile = Garb::Management::Profile.new(entry, Session)
end
View
2 test/unit/garb/report_response_test.rb
@@ -38,7 +38,7 @@ class ReportResponseTest < MiniTest::Unit::TestCase
should "return an empty array if there are no results" do
response = ReportResponse.new("result json")
- JSON.stubs(:parse).with("result json").returns({'rows' => []})
+ MultiJson.stubs(:load).with("result json").returns({'rows' => []})
assert_equal [], response.results.to_a
end

0 comments on commit d72dfae

Please sign in to comment.