Class: WhatsupGithub::EnterpriseClient

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

Overview

Create a singleton object for EnterpriseClient. Authorize with a GitHub Enterprise token from $WHATSUP_ENTERPRISE_ACCESS_TOKEN if available Otherwise, use credentials from ~/.netrc

Constant Summary collapse

@@hostname =
''

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Client

#org_members

Constructor Details

#initializeEnterpriseClient

Returns a new instance of EnterpriseClient.



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/whatsup_github/enterprise_client.rb', line 23

def initialize
  Octokit.configure do |c|
    c.api_endpoint = "https://#{@@hostname}/api/v3/"
  end
  @client =
    if WHATSUP_ENTERPRISE_ACCESS_TOKEN
      Octokit::Client.new(access_token: WHATSUP_ENTERPRISE_ACCESS_TOKEN)
    elsif File.exist? "#{ENV['HOME']}/.netrc"
      Octokit::Client.new(netrc: true)
    end
end

Class Method Details

.host=(hostname) ⇒ Object



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

def self.host=(hostname)
  abort "ERROR: Set value for 'enterprise' in the whatsup_github configuration" if hostname.nil?
  @@hostname = hostname
end

Instance Method Details

#pull_request(repo, number) ⇒ Object



39
40
41
# File 'lib/whatsup_github/enterprise_client.rb', line 39

def pull_request(repo, number)
  @client.pull_request(repo.delete_prefix('enterprise:'), number)
end

#search_issues(query) ⇒ Object



35
36
37
# File 'lib/whatsup_github/enterprise_client.rb', line 35

def search_issues(query)
  @client.search_issues(query.gsub('enterprise:', ''))
end