lib/share_counter.rb in share_counter-0.3.3 vs lib/share_counter.rb in share_counter-0.3.4

- old
+ new

@@ -4,10 +4,12 @@ module ShareCounter def self.twitter url html = make_request "http://urls.api.twitter.com/1/urls/count.json", url: url return JSON.parse(html)['count'] + rescue Exception + 0 end def self.facebook url html = make_request "https://api.facebook.com/method/links.getStats", urls: url, format: "json" return JSON.parse(html, symbolize_names: true)[0] @@ -71,10 +73,9 @@ response = RestClient.get url, { params: params, timeout: 5 , ssl: { verify_ssl: false } } result = params.keys.include?(:callback) \ ? response.gsub(/\A\/\*\*\/\s+/, "").gsub(/^(.*);+\n*$/, "\\1").gsub(/^#{params[:callback]}\((.*)\)$/, "\\1") \ : response rescue => e - puts "Failed #{attempts} attempt(s) - #{e}" attempts += 1 if attempts <= 3 sleep 2 retry else