Class: DeployLog::Github::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/deploy_log/github/api.rb

Instance Method Summary collapse

Constructor Details

#initialize(repo) ⇒ Api

Returns a new instance of Api.



10
11
12
13
14
15
# File 'lib/deploy_log/github/api.rb', line 10

def initialize(repo)
  @client = Octokit::Client.new(login: ENV['GITHUB_USER'], password: ENV['GITHUB_TOKEN'])
  @client.auto_paginate = true

  @repo = repo
end

Instance Method Details

#commits_for(id) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/deploy_log/github/api.rb', line 39

def commits_for(id)
  begin
    @client.pull_request_commits(@repo, id)
  rescue Octokit::NotFound => e
    Notify.error e.message
  end
end

#pull_request(id) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/deploy_log/github/api.rb', line 31

def pull_request(id)
  begin
    @client.pull_request(@repo, id)
  rescue Octokit::NotFound => e
    Notify.error e.message
  end
end

#pull_requests(options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/deploy_log/github/api.rb', line 17

def pull_requests(options = {})
  default_opts = {
    state: :closed,
    per_page: 500,
    sort: 'long-running'
  }

  begin
    @client.pull_requests(@repo, default_opts.merge(options))
  rescue Octokit::NotFound => e
    Notify.error e.message
  end
end