Class: Travis::CLI::ApiCommand
Instance Attribute Summary collapse
Attributes inherited from Command
#arguments, #config, #force_interactive, #terminal
Instance Method Summary
collapse
#access_token, #access_token=, #api_endpoint, #api_endpoint=, #explicit_api_endpoint?, #github_auth, #repo, #repos, #user
Methods inherited from Command
abstract, abstract?, command_name, #command_name, #execute, #help, #input, #input=, #output, #output=, #parse, #say, skip, #usage, #write_to
Methods included from Parser
#new, #on, #on_initialize
Constructor Details
Returns a new instance of ApiCommand.
15
16
17
18
|
# File 'lib/travis/cli/api_command.rb', line 15
def initialize(*)
@session = Travis::Client.new
super
end
|
Instance Attribute Details
#session ⇒ Object
Returns the value of attribute session.
7
8
9
|
# File 'lib/travis/cli/api_command.rb', line 7
def session
@session
end
|
Instance Method Details
#authenticate ⇒ Object
43
44
45
|
# File 'lib/travis/cli/api_command.rb', line 43
def authenticate
error "not logged in, please run #{command("login#{endpoint_option}")}" if access_token.nil?
end
|
#detected_endpoint? ⇒ Boolean
39
40
41
|
# File 'lib/travis/cli/api_command.rb', line 39
def detected_endpoint?
api_endpoint == detected_endpoint
end
|
#endpoint_config ⇒ Object
20
21
22
23
|
# File 'lib/travis/cli/api_command.rb', line 20
def endpoint_config
config['endpoints'] ||= {}
config['endpoints'][api_endpoint] ||= {}
end
|
#org? ⇒ Boolean
35
36
37
|
# File 'lib/travis/cli/api_command.rb', line 35
def org?
api_endpoint == Travis::Client::ORG_URI
end
|
#pro? ⇒ Boolean
31
32
33
|
# File 'lib/travis/cli/api_command.rb', line 31
def pro?
api_endpoint == Travis::Client::PRO_URI
end
|
#setup ⇒ Object
25
26
27
28
29
|
# File 'lib/travis/cli/api_command.rb', line 25
def setup
self.access_token ||= fetch_token
endpoint_config['access_token'] ||= access_token
authenticate if pro?
end
|