Class: GitHub::Commit

Inherits:
Base
  • Object
show all
Defined in:
lib/git_hub/commit.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

aliases_for, base_uri, #get, get, post, #post, request, #set_attributes, set_resource, #to_s

Constructor Details

#initialize(opts) ⇒ Commit

Returns a new instance of Commit.



14
15
16
17
18
19
# File 'lib/git_hub/commit.rb', line 14

def initialize(opts)
  super
  raise "Unable to initialize #{self.class} without id(sha)" unless sha
  @committed = Time.parse(@committed) unless @committed.is_a?(Time)
  @authored = Time.parse(@authored) unless @authored.is_a?(Time)
end

Instance Attribute Details

#addedObject

Returns the value of attribute added.



6
7
8
# File 'lib/git_hub/commit.rb', line 6

def added
  @added
end

#authorObject

Returns the value of attribute author.



6
7
8
# File 'lib/git_hub/commit.rb', line 6

def author
  @author
end

#authoredObject

Returns the value of attribute authored.



6
7
8
# File 'lib/git_hub/commit.rb', line 6

def authored
  @authored
end

#committedObject

Returns the value of attribute committed.



6
7
8
# File 'lib/git_hub/commit.rb', line 6

def committed
  @committed
end

#committerObject

Returns the value of attribute committer.



6
7
8
# File 'lib/git_hub/commit.rb', line 6

def committer
  @committer
end

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/git_hub/commit.rb', line 6

def id
  @id
end

#messageObject

Returns the value of attribute message.



6
7
8
# File 'lib/git_hub/commit.rb', line 6

def message
  @message
end

#modifiedObject

Returns the value of attribute modified.



6
7
8
# File 'lib/git_hub/commit.rb', line 6

def modified
  @modified
end

#parentsObject

Returns the value of attribute parents.



6
7
8
# File 'lib/git_hub/commit.rb', line 6

def parents
  @parents
end

#removedObject

Returns the value of attribute removed.



6
7
8
# File 'lib/git_hub/commit.rb', line 6

def removed
  @removed
end

#repoObject

Returns the value of attribute repo.



6
7
8
# File 'lib/git_hub/commit.rb', line 6

def repo
  @repo
end

#treeObject

Returns the value of attribute tree.



6
7
8
# File 'lib/git_hub/commit.rb', line 6

def tree
  @tree
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/git_hub/commit.rb', line 6

def url
  @url
end

#userObject

Returns the value of attribute user.



6
7
8
# File 'lib/git_hub/commit.rb', line 6

def user
  @user
end

Class Method Details

.find(*args) ⇒ Object Also known as: show

Find commits, accepts Hash with keys:

:user/:owner/:username

Github user name

:repo/:repository/:project

Repo name

:branch

Only commits for specific branch - default ‘master’

:path

Only commits for specific path

:sha/:id

Only one commit with specific id (sha)



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/git_hub/commit.rb', line 28

def find( *args )
  user, repo, branch, sha, path = extract args, :user, :repo, :branch, :sha, :path 
  repo_given = branch && user && repo
  path = if sha && repo_given
    "/show/#{user}/#{repo}/#{sha}"
  elsif path && repo_given
    "/list/#{user}/#{repo}/#{branch}/#{path}"
  elsif repo_given 
    "/list/#{user}/#{repo}/#{branch}"
  else
    raise "Unable to find #{self.class}(s) for #{opts}"
  end
  instantiate get(path), :user=>user, :repo=>repo
end