Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Simple API v2 support #3

Open
wants to merge 2 commits into from

1 participant

@juanje

Added just the minimal changes to have it working with the API v2.

@juanje juanje closed this
@juanje juanje reopened this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/ruby-github.rb
View
11 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,8 +27,9 @@ 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))
+ 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
end
Something went wrong with that request. Please try again.