Class: GithubCLI::API

Inherits:
Object
  • Object
show all
Defined in:
lib/github_cli/api.rb

Overview

The API class is the main entry point for creating GithubCLI APIs.

Defined Under Namespace

Classes: All

Constant Summary collapse

ENDPOINT =
''
@@api =
nil

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject (readonly)

Returns the value of attribute config.



13
14
15
# File 'lib/github_cli/api.rb', line 13

def config
  @config
end

Class Method Details

.configure_apiObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/github_cli/api.rb', line 21

def configure_api
  @@api = Github.new
  @@api.oauth_token = GithubCLI.config['auth.token']
  @@api.basic_auth  = GithubCLI.config['auth.basic']
  @@api.endpoint    = GithubCLI.config['core.endpoint'] || @@api.endpoint
  if ENV['TEST_HOST']
    @@api.endpoint = 'http://' + ENV['TEST_HOST']
  end
  @@api
end

.github_apiObject



15
16
17
18
19
# File 'lib/github_cli/api.rb', line 15

def github_api
  @@api ||= begin
    @@api = configure_api
  end
end

.output(format = :table, &block) ⇒ Object



32
33
34
35
36
# File 'lib/github_cli/api.rb', line 32

def output(format=:table, &block)
  response =  block.call
  formatter = Formatter.new response, :format => format
  formatter.render_output
end