Commit 6c9c347a authored by Fabio Pelosin's avatar Fabio Pelosin

[statistics] Switch to GitHub v3 api

parent 75de2a58
require 'net/http' require 'net/https'
require 'uri'
require 'yaml' require 'yaml'
module Pod module Pod
...@@ -81,9 +82,14 @@ module Pod ...@@ -81,9 +82,14 @@ module Pod
gh_url, username, reponame = *(url.match(/[:\/]([\w\-]+)\/([\w\-]+)\.git/).to_a) gh_url, username, reponame = *(url.match(/[:\/]([\w\-]+)\/([\w\-]+)\.git/).to_a)
return unless gh_url return unless gh_url
response = Net::HTTP.get('github.com', "/api/v2/json/repos/show/#{username}/#{reponame}") uri = URI.parse("https://api.github.com/repos/#{username}/#{reponame}")
watchers = response.match(/\"watchers\"\W*:\W*([0-9]+)/).to_a[1] http = Net::HTTP.new(uri.host, uri.port)
forks = response.match(/\"forks\"\W*:\W*([0-9]+)/).to_a[1] http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request).body
watchers = response.match(/"watchers"\W*:\W*([0-9]+)/).to_a[1]
forks = response.match(/"forks"\W*:\W*([0-9]+)/).to_a[1]
return unless watchers && forks return unless watchers && forks
cache[set.name] ||= {} cache[set.name] ||= {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment