ubalo 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/ubalo +7 -7
- data/lib/ubalo.rb +19 -13
- metadata +10 -10
data/bin/ubalo
CHANGED
@@ -417,11 +417,11 @@ command :login do |c|
|
|
417
417
|
login = hl.ask(" login: "){|q| q.echo = true}
|
418
418
|
password = hl.ask(" password: "){|q| q.echo = false}
|
419
419
|
|
420
|
-
response = ubalo.
|
421
|
-
ubalo.
|
420
|
+
response = ubalo.get_authorization(login, password)
|
421
|
+
ubalo.authorization = response.fetch('authorization')
|
422
422
|
username = response.fetch('username')
|
423
423
|
|
424
|
-
Ubalo.write_config(ubalo.base_url => {'
|
424
|
+
Ubalo.write_config(ubalo.base_url => {'authorization' => ubalo.authorization, 'username' => username})
|
425
425
|
puts "Success! Ready to use as #{username}."
|
426
426
|
end
|
427
427
|
end
|
@@ -464,15 +464,15 @@ pre do |global,command,options,args|
|
|
464
464
|
config = Ubalo.config
|
465
465
|
connect_url = global['connect-url'] || config['connect-url'] || "https://ubalo.com/api"
|
466
466
|
|
467
|
-
# When logging in, don't use the
|
467
|
+
# When logging in, don't use the authorization:
|
468
468
|
unless command && command.name == :login
|
469
469
|
if host_config = config[connect_url]
|
470
470
|
@local_username = host_config['username']
|
471
|
-
|
471
|
+
authorization = host_config['authorization']
|
472
472
|
end
|
473
473
|
end
|
474
474
|
|
475
|
-
unless
|
475
|
+
unless authorization or (command && command.name == :login)
|
476
476
|
raise UbaloMessage, "No credentials found. Please run 'ubalo login'."
|
477
477
|
end
|
478
478
|
|
@@ -482,7 +482,7 @@ pre do |global,command,options,args|
|
|
482
482
|
@local_config = YAML.load_file(full_path)
|
483
483
|
end
|
484
484
|
|
485
|
-
@ubalo ||= Ubalo.login(
|
485
|
+
@ubalo ||= Ubalo.login(authorization, connect_url)
|
486
486
|
|
487
487
|
true
|
488
488
|
end
|
data/lib/ubalo.rb
CHANGED
@@ -66,14 +66,14 @@ class Ubalo
|
|
66
66
|
end
|
67
67
|
|
68
68
|
attr_reader :base_url
|
69
|
-
attr_accessor :
|
69
|
+
attr_accessor :authorization
|
70
70
|
|
71
|
-
def self.login
|
72
|
-
new(
|
71
|
+
def self.login authorization, base_url
|
72
|
+
new(authorization, base_url)
|
73
73
|
end
|
74
74
|
|
75
|
-
def initialize
|
76
|
-
@
|
75
|
+
def initialize authorization, base_url
|
76
|
+
@authorization = authorization
|
77
77
|
@base_url = base_url
|
78
78
|
end
|
79
79
|
|
@@ -83,10 +83,7 @@ class Ubalo
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def url_get url, params={}
|
86
|
-
|
87
|
-
params.merge!({:auth_token => token})
|
88
|
-
end
|
89
|
-
response = RestClient.get url, :params => params
|
86
|
+
response = RestClient.get url, add_authorization(:params => params)
|
90
87
|
parse(response)
|
91
88
|
end
|
92
89
|
|
@@ -96,7 +93,7 @@ class Ubalo
|
|
96
93
|
end
|
97
94
|
|
98
95
|
def url_post(url, params={})
|
99
|
-
response = RestClient.post url, {
|
96
|
+
response = RestClient.post url, params, add_authorization({})
|
100
97
|
parse(response)
|
101
98
|
end
|
102
99
|
|
@@ -120,7 +117,7 @@ class Ubalo
|
|
120
117
|
def wait_task(label, silent=false)
|
121
118
|
60.times do
|
122
119
|
h = check_task(label)
|
123
|
-
if
|
120
|
+
if h['state'] == 'exited'
|
124
121
|
unless silent
|
125
122
|
$stderr.puts " done."
|
126
123
|
end
|
@@ -209,8 +206,8 @@ class Ubalo
|
|
209
206
|
end
|
210
207
|
end
|
211
208
|
|
212
|
-
def
|
213
|
-
post(:
|
209
|
+
def get_authorization login, password
|
210
|
+
post(:get_authorization, :user => {:login => login, :password => password})
|
214
211
|
end
|
215
212
|
|
216
213
|
def available_templates
|
@@ -246,6 +243,15 @@ class Ubalo
|
|
246
243
|
end
|
247
244
|
|
248
245
|
private
|
246
|
+
|
247
|
+
def add_authorization(headers)
|
248
|
+
if authorization
|
249
|
+
headers.merge(:authorization => authorization)
|
250
|
+
else
|
251
|
+
headers
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
249
255
|
def parse(result)
|
250
256
|
JSON.load(result)
|
251
257
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ubalo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-16 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gli
|
16
|
-
requirement: &
|
16
|
+
requirement: &70291514610660 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70291514610660
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: highline
|
27
|
-
requirement: &
|
27
|
+
requirement: &70291514610200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70291514610200
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &70291514609780 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70291514609780
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rest-client
|
49
|
-
requirement: &
|
49
|
+
requirement: &70291514609280 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 1.6.3
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70291514609280
|
58
58
|
description: CLI and API client for Ubalo
|
59
59
|
email: dev@ubalo.com
|
60
60
|
executables:
|