Class: Travis::CLI::ApiCommand
Instance Attribute Summary collapse
Attributes inherited from Command
#arguments, #config, #force_interactive, #formatter, #input, #output
Instance Method Summary
collapse
#access_token, #access_token=, #api_endpoint, #api_endpoint=, #artifact, #build, #explicit_api_endpoint?, #github_auth, #job, #repo, #repos, #restart, #user, #worker, #workers
Methods inherited from Command
abstract, abstract?, command_name, #command_name, #debug, #execute, #help, #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
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
61
62
63
|
# File 'lib/travis/cli/api_command.rb', line 61
def authenticate
error "not logged in, please run #{command("login#{endpoint_option}")}" if access_token.nil?
end
|
#detected_endpoint? ⇒ Boolean
57
58
59
|
# File 'lib/travis/cli/api_command.rb', line 57
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
53
54
55
|
# File 'lib/travis/cli/api_command.rb', line 53
def org?
api_endpoint == Travis::Client::ORG_URI
end
|
#pro? ⇒ Boolean
49
50
51
|
# File 'lib/travis/cli/api_command.rb', line 49
def pro?
api_endpoint == Travis::Client::PRO_URI
end
|
#setup ⇒ Object
43
44
45
46
47
|
# File 'lib/travis/cli/api_command.rb', line 43
def setup
self.access_token ||= fetch_token
endpoint_config['access_token'] ||= access_token
authenticate if pro?
end
|
#sync(block = true, dot = '.') ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/travis/cli/api_command.rb', line 65
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
|