lib/share_checker/providers/tweetracker.rb in share_checker-0.1.1 vs lib/share_checker/providers/tweetracker.rb in share_checker-0.1.2
- old
+ new
@@ -1,7 +1,5 @@
-require 'crack/json'
-
module ShareChecker
module Providers
class Tweetracker < Provider
# Response sample
@@ -12,20 +10,11 @@
# "users":26,
# "query":"http://www.mcdonaldseurokids2012.com.ua/challenges/1/works/140"
# }
#
def parse(response)
- count = 0
-
- begin
- obj = Crack::JSON.parse(response)
- count = (obj["users"] ? obj["users"].to_i : 0)
- rescue Exception => e
- puts "Error parse json: #{response}, #{e.message}"
- count = 0
- end
-
- return count
+ doc = parse_json(response)
+ doc.nil? ? 0 : doc["users"].to_i
end
def url
"http://tracktweets.aimbulance.com/api/v1/groups/#{group_id}/urls/count.json?query="
end