This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Updating Gems and the Parser

  • Loading branch information...
miksago committed May 4, 2010
1 parent 9170428 commit de4fb84f2b1a693d64140f438deb6075428fe2e9
Showing with 19 additions and 18 deletions.
  1. +6 −5 Rakefile
  2. +1 −1 lib/chargify.rb
  3. +10 −10 lib/chargify/client.rb
  4. +2 −2 test/helper.rb
View
@@ -11,12 +11,13 @@ begin
gem.homepage = "http://github.com/pengwynn/chargify"
gem.authors = ["Wynn Netherland","Nash Kabbara"]
- gem.add_dependency('hashie', '~> 0.1.3')
- gem.add_dependency('httparty', '~> 0.4.5')
+ gem.add_dependency('hashie', '>= 0.2.0')
+ gem.add_dependency('httparty', '>= 0.5.2')
+ gem.add_dependency('json_pure', '>= 1.4.2')
- gem.add_development_dependency('thoughtbot-shoulda', '>= 2.10.1')
- gem.add_development_dependency('jnunemaker-matchy', '0.4.0')
- gem.add_development_dependency('mocha', '0.9.4')
+ gem.add_development_dependency('shoulda', '>= 2.10.1')
+ gem.add_development_dependency('jnunemaker-matchy', '>= 0.4.0')
+ gem.add_development_dependency('mocha', '>= 0.9.4')
gem.add_development_dependency('fakeweb', '>= 1.2.5')
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
View
@@ -1,6 +1,6 @@
require 'hashie'
require 'httparty'
-require "json"
+require 'json/pure'
directory = File.expand_path(File.dirname(__FILE__))
View
@@ -1,21 +1,21 @@
module Chargify
- class UnexpectedResponseError < RuntimeError;end
-
- def self.custom_parser
- proc do |data|
+ class UnexpectedResponseError < RuntimeError
+ end
+
+ class Parser < HTTParty::Parser
+ def parse
begin
- Crack::JSON.parse(data)
+ Crack::JSON.parse(body)
rescue => e
- error_msg = "Crack could not parse JSON. It said: #{e.message}. Chargify's raw response: #{data}"
- raise UnexpectedResponseError, error_msg
+ raise UnexpectedResponseError, "Crack could not parse JSON. It said: #{e.message}. Chargify's raw response: #{body}"
end
end
end
-
+
class Client
include HTTParty
- format :json
- parser Chargify::custom_parser
+
+ parser Chargify::Parser
headers 'Content-Type' => 'application/json'
attr_reader :api_key, :subdomain
View
@@ -2,9 +2,9 @@
require 'pathname'
require 'rubygems'
-gem 'thoughtbot-shoulda', '>= 2.10.1'
+gem 'shoulda', '>= 2.10.1'
gem 'jnunemaker-matchy', '0.4.0'
-gem 'mocha', '0.9.4'
+gem 'mocha', '>= 0.9.4'
gem 'fakeweb', '>= 1.2.5'
require 'shoulda'

0 comments on commit de4fb84

Please sign in to comment.