Class: Pronto::GithubPull
- Inherits:
-
Object
- Object
- Pronto::GithubPull
- Defined in:
- lib/pronto/github_pull.rb
Overview
Provides strategies for finding corresponding PR on GitHub
Instance Method Summary collapse
-
#initialize(client, slug) ⇒ GithubPull
constructor
A new instance of GithubPull.
- #pull_by_branch(branch) ⇒ Object
- #pull_by_commit(sha) ⇒ Object
- #pull_by_id(pull_id) ⇒ Object
- #pull_requests ⇒ Object
Constructor Details
#initialize(client, slug) ⇒ GithubPull
Returns a new instance of GithubPull.
4 5 6 7 |
# File 'lib/pronto/github_pull.rb', line 4 def initialize(client, slug) @client = client @slug = slug end |
Instance Method Details
#pull_by_branch(branch) ⇒ Object
22 23 24 25 26 27 28 29 |
# 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) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# 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 = "Pull request with head #{sha} " \ "was not found in #{@slug}." raise Pronto::Error, end result end |
#pull_by_id(pull_id) ⇒ Object
13 14 15 16 17 18 19 20 |
# 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 = "Pull request ##{pull_id} was not found in #{@slug}." raise Pronto::Error, end result end |
#pull_requests ⇒ Object
9 10 11 |
# File 'lib/pronto/github_pull.rb', line 9 def pull_requests @pull_requests ||= @client.pull_requests(@slug) end |