Class: Reviewlette::GithubConnection

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

Constant Summary collapse

GITHUB_CONFIG =
YAML.load_file("#{File.dirname(__FILE__)}/../../config/.github.yml")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGithubConnection

Returns a new instance of GithubConnection.



12
13
14
# File 'lib/reviewlette/github_connection.rb', line 12

def initialize
  gh_connection
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



10
11
12
# File 'lib/reviewlette/github_connection.rb', line 10

def client
  @client
end

#repoObject

Returns the value of attribute repo.



10
11
12
# File 'lib/reviewlette/github_connection.rb', line 10

def repo
  @repo
end

Instance Method Details

#add_assignee(repo, number, title, body, name) ⇒ Object



32
33
34
# File 'lib/reviewlette/github_connection.rb', line 32

def add_assignee(repo, number, title, body, name)
  @client.update_issue(repo, number, title, body, :assignee => name)
end

#comment_on_issue(repo, number, name, trello_card_url) ⇒ Object



36
37
38
# File 'lib/reviewlette/github_connection.rb', line 36

def comment_on_issue(repo, number, name, trello_card_url)
  @client.add_comment(repo, number, "@#{name} is your reviewer :thumbsup: check #{trello_card_url}")
end

#get_branch_name(pr_id, repo) ⇒ Object



20
21
22
# File 'lib/reviewlette/github_connection.rb', line 20

def get_branch_name(pr_id, repo)
  @client.pull_requests(repo)[pr_id].head.ref
end

#gh_connectionObject



16
17
18
# File 'lib/reviewlette/github_connection.rb', line 16

def gh_connection
  @client = Octokit::Client.new(:access_token => GITHUB_CONFIG['token'])
end

#list_issues(repo) ⇒ Object



40
41
42
# File 'lib/reviewlette/github_connection.rb', line 40

def list_issues(repo)
  @client.list_issues(repo)
end

#list_pulls(repo) ⇒ Object



24
25
26
# File 'lib/reviewlette/github_connection.rb', line 24

def list_pulls(repo)
  @client.pull_requests(repo)
end

#pull_merged?(repo, number) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/reviewlette/github_connection.rb', line 28

def pull_merged?(repo, number)
  client.pull_merged?(repo, number)
end