Class: GitHub

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

Defined Under Namespace

Classes: Hash

Class Method Summary collapse

Class Method Details

.commit(user, repository, commit) ⇒ Object

Fetches a single commit for a repository.



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

def self.commit(user,repository,commit)
  self.grab(user,repository,nil,commit).commit
end

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

Fetches the commits for a given repository.



23
24
25
# File 'lib/ruby-github.rb', line 23

def self.commits(user,repository,branch="master")
  self.grab(user,repository,branch).commits
end

.grab(user, repo = nil, branch = nil, commit = nil) ⇒ Object

:nodoc:



6
7
8
9
10
11
12
13
14
15
# File 'lib/ruby-github.rb', line 6

def self.grab(user, repo=nil, branch=nil, commit=nil) #:nodoc:
  url = "http://github.com/api/v1/json/#{user}"
  
  if repo
    url += "/#{repo}"
    url += commit ? "/commit/#{commit}" : "/commits/#{branch}"
  end
  
  GitHub::Hash.new(JSON.parse(open(url).read),user,repo)
end

.user(user) ⇒ Object

Fetches information about the specified user name.



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

def self.user(user)
  self.grab(user).user
end