class Pronto::GithubPull
Provides strategies for finding corresponding PR on GitHub
Public Class Methods
new(client, slug)
click to toggle source
# File lib/pronto/github_pull.rb, line 4 def initialize(client, slug) @client = client @slug = slug end
Public Instance Methods
pull_by_branch(branch)
click to toggle source
# File lib/pronto/github_pull.rb, line 22 def pull_by_branch(branch) result = pull_requests.find { |pr| pr[:head][:ref] == branch } unless result raise Pronto::Error, "Pull request for branch #{branch} " \ "was not found in #{@slug}." end result end
pull_by_commit(sha)
click to toggle source
# File lib/pronto/github_pull.rb, line 31 def pull_by_commit(sha) result = pull_requests.find do |pr| pr[:head][:sha] == sha end unless result message = "Pull request with head #{sha} " \ "was not found in #{@slug}." raise Pronto::Error, message end result end
pull_by_id(pull_id)
click to toggle source
# File lib/pronto/github_pull.rb, line 13 def pull_by_id(pull_id) result = pull_requests.find { |pr| pr[:number].to_i == pull_id } unless result message = "Pull request ##{pull_id} was not found in #{@slug}." raise Pronto::Error, message end result end
pull_requests()
click to toggle source
# File lib/pronto/github_pull.rb, line 9 def pull_requests @pull_requests ||= @client.pull_requests(@slug) end