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.
32
33
34
35
|
# File 'lib/travis/cli/api_command.rb', line 32
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
60
61
62
|
# File 'lib/travis/cli/api_command.rb', line 60
def authenticate
error "not logged in, please run #{command("login#{endpoint_option}")}" if access_token.nil?
end
|
#detected_endpoint? ⇒ Boolean
56
57
58
|
# File 'lib/travis/cli/api_command.rb', line 56
def detected_endpoint?
api_endpoint == detected_endpoint
end
|
#endpoint_config ⇒ Object
37
38
39
40
|
# File 'lib/travis/cli/api_command.rb', line 37
def endpoint_config
config['endpoints'] ||= {}
config['endpoints'][api_endpoint] ||= {}
end
|
#org? ⇒ Boolean
52
53
54
|
# File 'lib/travis/cli/api_command.rb', line 52
def org?
api_endpoint == Travis::Client::ORG_URI
end
|
#pro? ⇒ Boolean
48
49
50
|
# File 'lib/travis/cli/api_command.rb', line 48
def pro?
api_endpoint == Travis::Client::PRO_URI
end
|
#setup ⇒ Object
42
43
44
45
46
|
# File 'lib/travis/cli/api_command.rb', line 42
def setup
self.access_token ||= fetch_token
endpoint_config['access_token'] ||= access_token
authenticate if pro?
end
|
#sync(block = true, dot = '.') ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/travis/cli/api_command.rb', line 64
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
|