Class: SemamoreOctoClient

Inherits:
Object
  • Object
show all
Defined in:
lib/semamore_octo_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(token, options: { auto_paginate: true }) ⇒ SemamoreOctoClient

Returns a new instance of SemamoreOctoClient.



4
5
6
# File 'lib/semamore_octo_client.rb', line 4

def initialize(token, options: { auto_paginate: true })
  @client = Octokit::Client.new(options.merge(access_token: token))
end

Instance Method Details

#current_pr(repo, branch) ⇒ Object



13
14
15
16
# File 'lib/semamore_octo_client.rb', line 13

def current_pr(repo, branch)
  p 'Selecting current PR...'
  open_prs(repo).select {|pr| pr[:head][:ref] == branch}.first
end

#current_pr_files(repo, branch) ⇒ Object



8
9
10
11
# File 'lib/semamore_octo_client.rb', line 8

def current_pr_files(repo, branch)
  p 'Fetching current PR changed files...'
  client.pull_request_files(repo, current_pr(repo, branch)[:number])
end

#open_prs(repo) ⇒ Object



18
19
20
21
# File 'lib/semamore_octo_client.rb', line 18

def open_prs(repo)
  p 'Fetching open PRs...'
  client.pull_requests(repo, :state => "open")
end