Class: WhatsupGithub::Client

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/whatsup_github/client.rb

Overview

Create a singleton object for Client. Authorize with a GitHub token from $WHATSUP_GITHUB_ACCESS_TOKEN if available Otherwise, use credentials from ~/.netrc Otherwise, continue as a Guest

Direct Known Subclasses

EnterpriseClient

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



17
18
19
20
21
22
23
24
25
26
# File 'lib/whatsup_github/client.rb', line 17

def initialize
  @client =
    if WHATSUP_GITHUB_ACCESS_TOKEN
      Octokit::Client.new(access_token: WHATSUP_GITHUB_ACCESS_TOKEN)
    elsif File.exist? "#{ENV['HOME']}/.netrc"
      Octokit::Client.new(netrc: true)
    else
      Octokit::Client.new
    end
end

Instance Method Details

#org_members(org) ⇒ Object



36
37
38
# File 'lib/whatsup_github/client.rb', line 36

def org_members(org)
  @client.org_members(org)
end

#pull_request(repo, number) ⇒ Object



32
33
34
# File 'lib/whatsup_github/client.rb', line 32

def pull_request(repo, number)
  @client.pull_request(repo, number)
end

#search_issues(query) ⇒ Object



28
29
30
# File 'lib/whatsup_github/client.rb', line 28

def search_issues(query)
  @client.search_issues(query)
end