Class: MrBump::GitApi
- Inherits:
-
Object
- Object
- MrBump::GitApi
- Defined in:
- lib/mr_bump/git_api.rb
Overview
This class makes calls to the github API
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(token) ⇒ GitApi
constructor
A new instance of GitApi.
- #merge_pr(repo_url, pr_id) ⇒ Object
- #prs(repo_url) ⇒ Object
- #sorted_prs(repo_url) ⇒ Object
Constructor Details
#initialize(token) ⇒ GitApi
Returns a new instance of GitApi.
11 12 13 |
# File 'lib/mr_bump/git_api.rb', line 11 def initialize(token) @client = Octokit::Client.new(access_token: token) end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
9 10 11 |
# File 'lib/mr_bump/git_api.rb', line 9 def client @client end |
Instance Method Details
#merge_pr(repo_url, pr_id) ⇒ Object
23 24 25 |
# File 'lib/mr_bump/git_api.rb', line 23 def merge_pr(repo_url, pr_id) client.merge_pull_request(repo_url, pr_id) end |
#prs(repo_url) ⇒ Object
15 16 17 |
# File 'lib/mr_bump/git_api.rb', line 15 def prs(repo_url) @prs ||= client.pull_requests(repo_url, state: 'open') end |
#sorted_prs(repo_url) ⇒ Object
19 20 21 |
# File 'lib/mr_bump/git_api.rb', line 19 def sorted_prs(repo_url) prs(repo_url).map { |x| '#' + x[:number].to_s + ' - ' + x[:title].to_s + "\n" }.first(10).join end |