From cb4e5fca00fef6afc3f5de1c59a00c2abcce0a69 Mon Sep 17 00:00:00 2001 From: Juanje Ojeda Date: Mon, 25 Jul 2011 06:00:40 +0200 Subject: [PATCH 1/2] fix: removed the nested commit object at the single commit --- lib/ruby-github.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ruby-github.rb b/lib/ruby-github.rb index 90bb1ef..2f7cb45 100644 --- a/lib/ruby-github.rb +++ b/lib/ruby-github.rb @@ -28,7 +28,8 @@ def self.repository(user,repository) # Fetches a single commit for a repository. def self.commit(user,repository,commit) url = BASE_URL + "/#{user}/#{repository}/commit/#{commit}" - GitHub::Commit.new(JSON.parse(open(url).read).merge(:user => user, :repository => repository)) + commit = JSON.parse(open(url).read)["commit"] + GitHub::Commit.new(commit.merge(:user => user, :repository => repository)) end end From 291a0564b21b1c47c6c4e5bfb7098db3595b0191 Mon Sep 17 00:00:00 2001 From: Juanje Ojeda Date: Mon, 25 Jul 2011 06:04:01 +0200 Subject: [PATCH 2/2] Added API v2 support --- lib/ruby-github.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ruby-github.rb b/lib/ruby-github.rb index 2f7cb45..2ef29ef 100644 --- a/lib/ruby-github.rb +++ b/lib/ruby-github.rb @@ -5,17 +5,17 @@ module GitHub class API - BASE_URL = "http://github.com/api/v1/json" + BASE_URL = "http://github.com/api/v2/json" # Fetches information about the specified user name. def self.user(user) - url = BASE_URL + "/#{user}" + url = BASE_URL + "/user/show/#{user}" GitHub::User.new(JSON.parse(open(url).read)["user"]) end # Fetches the commits for a given repository. def self.commits(user,repository,branch="master") - url = BASE_URL + "/#{user}/#{repository}/commits/#{branch}" + url = BASE_URL + "/commits/list/#{user}/#{repository}/#{branch}" JSON.parse(open(url).read)["commits"].collect{ |c| GitHub::Commit.new(c.merge(:user => user, :repository => repository)) } @@ -27,7 +27,7 @@ def self.repository(user,repository) # Fetches a single commit for a repository. def self.commit(user,repository,commit) - url = BASE_URL + "/#{user}/#{repository}/commit/#{commit}" + url = BASE_URL + "/commits/show/#{user}/#{repository}/#{commit}" commit = JSON.parse(open(url).read)["commit"] GitHub::Commit.new(commit.merge(:user => user, :repository => repository)) end