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, #pull_request, #search_issues

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