Class: Travis::CLI::ApiCommand
Direct Known Subclasses
Accounts, Console, Endpoint, Login, Monitor, Raw, RepoCommand, Sync, Token, Whatsup, Whoami
Instance Attribute Summary collapse
Attributes inherited from Command
#arguments, #config, #force_interactive, #formatter, #input, #output
Instance Method Summary
collapse
#access_token, #access_token=, #accounts, #api_endpoint, #api_endpoint=, #artifact, #broadcasts, #build, #cancel, #explicit_api_endpoint?, #github_auth, #job, #repo, #repos, #restart, #user, #worker, #workers
Methods inherited from Command
abstract, abstract?, #check_ruby, #check_version, #command_name, command_name, #debug, description, #execute, #help, #info, #last_check, #on_signal, #parse, #say, skip, #terminal, #usage, #write_to
Methods included from Parser
#new, #on, #on_initialize
Constructor Details
Returns a new instance of ApiCommand.
33
34
35
36
|
# File 'lib/travis/cli/api_command.rb', line 33
def initialize(*)
@session = Travis::Client.new(:agent_info => "command #{command_name}")
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
62
63
64
|
# File 'lib/travis/cli/api_command.rb', line 62
def authenticate
error "not logged in, please run #{command("login#{endpoint_option}")}" if access_token.nil?
end
|
#detected_endpoint? ⇒ Boolean
58
59
60
|
# File 'lib/travis/cli/api_command.rb', line 58
def detected_endpoint?
api_endpoint == detected_endpoint
end
|
#endpoint_config ⇒ Object
38
39
40
41
|
# File 'lib/travis/cli/api_command.rb', line 38
def endpoint_config
config['endpoints'] ||= {}
config['endpoints'][api_endpoint] ||= {}
end
|
#org? ⇒ Boolean
54
55
56
|
# File 'lib/travis/cli/api_command.rb', line 54
def org?
api_endpoint == Travis::Client::ORG_URI
end
|
#pro? ⇒ Boolean
50
51
52
|
# File 'lib/travis/cli/api_command.rb', line 50
def pro?
api_endpoint == Travis::Client::PRO_URI
end
|
#setup ⇒ Object
43
44
45
46
47
48
|
# File 'lib/travis/cli/api_command.rb', line 43
def setup
self.api_endpoint = default_endpoint if default_endpoint and not explicit_api_endpoint?
self.access_token ||= fetch_token
endpoint_config['access_token'] ||= access_token
authenticate if pro?
end
|
#sync(block = true, dot = '.') ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/travis/cli/api_command.rb', line 66
def sync(block = true, dot = '.')
user.sync
steps = count = 1
while block and user.reload.syncing?
count += 1
sleep(1)
if count % steps == 0
steps = count/10 + 1
output.print dot
end
end
end
|