Class: GitHub::API

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-github.rb

Constant Summary collapse

BASE_URL =
"http://github.com/api/v1/json"

Class Method Summary collapse

Class Method Details

.commit(user, repository, commit) ⇒ Object

Fetches a single commit for a repository.



26
27
28
29
# File 'lib/ruby-github.rb', line 26

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))
end

.commits(user, repository, branch = "master") ⇒ Object

Fetches the commits for a given repository.



18
19
20
21
22
23
# File 'lib/ruby-github.rb', line 18

def self.commits(user,repository,branch="master")
  url = BASE_URL + "/#{user}/#{repository}/commits/#{branch}"
  JSON.parse(open(url).read)["commits"].collect{ |c| 
    GitHub::Commit.new(c.merge(:user => user, :repository => repository))
  }
end

.user(user) ⇒ Object

Fetches information about the specified user name.



12
13
14
15
# File 'lib/ruby-github.rb', line 12

def self.user(user)
  url = BASE_URL + "/#{user}"
  GitHub::User.new(JSON.parse(open(url).read)["user"])
end