lib/reviewlette/github_connection.rb in reviewlette-0.0.8 vs lib/reviewlette/github_connection.rb in reviewlette-0.0.9
- old
+ new
@@ -1,17 +1,15 @@
require 'yaml'
require 'octokit'
-GITHUB_CONFIG = YAML.load_file("#{File.dirname(__FILE__)}/../../config/github.yml")
-
class GithubConnection
attr_accessor :client, :repo
- def initialize
- @client = Octokit::Client.new(:access_token => GITHUB_CONFIG['token'])
- @repo = GITHUB_CONFIG['repo']
+ def initialize(repo, token)
+ @client = Octokit::Client.new(access_token: token)
+ @repo = repo
end
def list_pulls
@client.pull_requests(@repo)
end
@@ -33,8 +31,12 @@
@client.add_comment(@repo, number, comment)
end
def unassigned_pull_requests
list_pulls.select { |issue| !issue[:assignee] }
+ end
+
+ def repo_exists?
+ @client.repository?(@repo)
end
end