Class: Octopolo::GitHub::Commit

Inherits:
Object
  • Object
show all
Defined in:
lib/octopolo/github/commit.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(commit_data) ⇒ Commit

Public: Instantiate a new Commit wrapper object

commit_data - The GitHub API data about the commit



9
10
11
# File 'lib/octopolo/github/commit.rb', line 9

def initialize commit_data
  self.commit_data = commit_data
end

Instance Attribute Details

#commit_dataObject

Returns the value of attribute commit_data.



4
5
6
# File 'lib/octopolo/github/commit.rb', line 4

def commit_data
  @commit_data
end

Class Method Details

.for_pull_request(pull_request) ⇒ Object

Public: Find commits for a given pull request

pull_request - A PullRequest or other object responding to #repo_name

and #number

Returns an Array of Commit objects



19
20
21
22
23
# File 'lib/octopolo/github/commit.rb', line 19

def self.for_pull_request pull_request
  GitHub.pull_request_commits(pull_request.repo_name, pull_request.number).map do |c|
    Commit.new c
  end
end

Instance Method Details

#authorObject

Public: GitHub User that is the author of the commit

Returns a Hashie::Mash object of the GitHub User



28
29
30
31
32
# File 'lib/octopolo/github/commit.rb', line 28

def author
  GitHub::User.new(commit_data.author.)
rescue NoMethodError
  GitHub::User.new(GitHub::UNKNOWN_USER)
end

#author_nameObject

Public: The name of the author of the commit

Returns a String containing the author’s name



37
38
39
# File 'lib/octopolo/github/commit.rb', line 37

def author_name
  author.author_name
end