Skip to content

Commit

Permalink
Changing JSON parser to use Crack::JSON. Currently the gem used by Tw…
Browse files Browse the repository at this point in the history
…itter/HTTParty and pilfered from Rails. Only reason is it runs in JRuby whereas standard json gem does not.
  • Loading branch information
coryosborn committed Apr 21, 2009
1 parent 96784f7 commit 3703cd4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Echoe.new('bitly', Bitly::VERSION) do |p|
p.url = "http://github.com/philnash/bitly"
p.author = "Phil Nash"
p.email = "[email protected]"
p.runtime_dependencies = ['json']
p.extra_deps = [['crack', '>= 0.1.1']]
p.development_dependencies = []
end

Expand Down
9 changes: 6 additions & 3 deletions bitly.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ Gem::Specification.new do |s|
s.specification_version = 2

if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<json>, [">= 0"])
s.add_runtime_dependency(%q<crack>, [">= 0.1.1"])
s.add_development_dependency(%q<echoe>, [">= 0"])
else
s.add_dependency(%q<json>, [">= 0"])
s.add_dependency(%q<crack>, [">= 0.1.1"])
s.add_dependency(%q<echoe>, [">= 0"])
end
else
s.add_dependency(%q<json>, [">= 0"])
s.add_dependency(%q<crack>, [">= 0.1.1"])
s.add_dependency(%q<echoe>, [">= 0"])
end
end
4 changes: 4 additions & 0 deletions lib/bitly.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
$:.unshift File.dirname(__FILE__)

require 'rubygems'
gem 'crack'
require 'crack'

require 'bitly/utils'
require 'bitly/client'
require 'bitly/url'
Expand Down
1 change: 0 additions & 1 deletion lib/bitly/client.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'rubygems'
require 'net/http'
require 'uri'
require 'json'

module Bitly
API_URL = 'http://api.bit.ly/'
Expand Down
2 changes: 1 addition & 1 deletion lib/bitly/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create_url(resource="",args={})
end

def get_result(request)
result = JSON.parse(Net::HTTP.get(request))
result = Crack::JSON.parse(Net::HTTP.get(request))
if result['statusCode'] == "OK"
result = result['results']
else
Expand Down

0 comments on commit 3703cd4

Please sign in to comment.