magellan-cli 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/magellan/cli/http.rb +13 -6
- data/lib/magellan/cli/messaging/base.rb +1 -1
- data/lib/magellan/cli/resources/base.rb +2 -2
- data/lib/magellan/cli/version.rb +1 -1
- data/spec/magellan/cli/resources/project_spec.rb +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2ba540ea2529d783f14d3628225f37692e04f3c
|
4
|
+
data.tar.gz: 26ca454236298f588565961a29c716cc11848222
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74efcf40e995664628987dc865a6ecc3be7d834100ae7be1ffcb98af2d37538e0ab035f9a06e867338792ffd3b63d4b27a95d8de665560dcf36b17b6a39675c9
|
7
|
+
data.tar.gz: bf52789d27406ab0ae831e59a96997c24ffac4a09dedc401f09443c9fad88904efa1c80aafc7c62caf1900943e5c753e6cea03eac19dd8a0b4c2cfe80bc0cc49
|
data/Gemfile.lock
CHANGED
data/lib/magellan/cli/http.rb
CHANGED
@@ -64,6 +64,13 @@ module Magellan
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
def debug_lf
|
68
|
+
r = yield if block_given?
|
69
|
+
@httpclient.debug_dev << "\n" if @httpclient.debug_dev
|
70
|
+
r
|
71
|
+
end
|
72
|
+
|
73
|
+
|
67
74
|
def login_form_url
|
68
75
|
@login_form_url ||= base_url + "/users/sign_in.html"
|
69
76
|
end
|
@@ -90,7 +97,7 @@ module Magellan
|
|
90
97
|
},
|
91
98
|
"authenticity_token" => @auth_token
|
92
99
|
}.to_json
|
93
|
-
res2 = Ssl.retry_on_ssl_error("login"){ @httpclient.post(login_url, params, JSON_HEADER) }
|
100
|
+
res2 = Ssl.retry_on_ssl_error("login"){ debug_lf{ @httpclient.post(login_url, params, JSON_HEADER) } }
|
94
101
|
|
95
102
|
case res2.status
|
96
103
|
when 200...300 then logined = true
|
@@ -109,7 +116,7 @@ module Magellan
|
|
109
116
|
def api_login_by_token!(email, token)
|
110
117
|
url = "#{base_url}/admin/magellan~auth~organization.json"
|
111
118
|
params = {"email" => email, "token" => token}
|
112
|
-
res = httpclient.get(url, params)
|
119
|
+
res = debug_lf{ httpclient.get(url, params) }
|
113
120
|
|
114
121
|
logined =
|
115
122
|
case res.status
|
@@ -135,7 +142,7 @@ module Magellan
|
|
135
142
|
end
|
136
143
|
|
137
144
|
def get_auth_token
|
138
|
-
res = Ssl.retry_on_ssl_error("login_form"){ @httpclient.get(login_form_url) }
|
145
|
+
res = Ssl.retry_on_ssl_error("login_form"){ debug_lf{ @httpclient.get(login_form_url) } }
|
139
146
|
doc = Nokogiri::HTML.parse(res.body, login_form_url, res.body_encoding.to_s)
|
140
147
|
node = doc.xpath('//input[@name="authenticity_token"]').first
|
141
148
|
unless node
|
@@ -175,7 +182,7 @@ module Magellan
|
|
175
182
|
else
|
176
183
|
obj = JSON.parse(res.body) rescue nil
|
177
184
|
if obj and obj.is_a?(Hash) and obj["message"]
|
178
|
-
fatal(obj["message"])
|
185
|
+
cmd.fatal(obj["message"])
|
179
186
|
end
|
180
187
|
end
|
181
188
|
end
|
@@ -195,7 +202,7 @@ module Magellan
|
|
195
202
|
$stderr, bak = StringIO.new, $stderr
|
196
203
|
res = nil
|
197
204
|
begin
|
198
|
-
res = httpclient.get(url)
|
205
|
+
res = debug_lf{ httpclient.get(url) }
|
199
206
|
ensure
|
200
207
|
$stderr = bak
|
201
208
|
end
|
@@ -248,7 +255,7 @@ module Magellan
|
|
248
255
|
|
249
256
|
def process_res(http_method, rel_path, *args)
|
250
257
|
url = "#{base_url}#{rel_path}"
|
251
|
-
res = httpclient.send(http_method, url, *args)
|
258
|
+
res = debug_lf{ httpclient.send(http_method, url, *args) }
|
252
259
|
check_response(res)
|
253
260
|
end
|
254
261
|
|
@@ -39,7 +39,7 @@ module Magellan
|
|
39
39
|
client_version: client_version,
|
40
40
|
mqtt_host: ENV["MAGELLAN_MQTT_SERVER_HOST"] || DEFAULT_MAGELLAN_MQTT_SERVER_HOST,
|
41
41
|
mqtt_port: ENV["MAGELLAN_MQTT_SERVER_PORT"] || DEFAULT_MAGELLAN_MQTT_SERVER_PORT,
|
42
|
-
verbose:
|
42
|
+
verbose: verbose?,
|
43
43
|
}
|
44
44
|
uri = ENV["MAGELLAN_HTTP_SERVER_URL"] || DEFAULT_MAGELLAN_HTTP_SERVER_URL
|
45
45
|
log_verbose("HTTP URL : #{uri.inspect}")
|
@@ -77,7 +77,8 @@ module Magellan
|
|
77
77
|
fields[i] = obj[:name]
|
78
78
|
res = obj[:resource] || ((k = Resources.const_get(obj[:class])) ? k.resource_key : nil)
|
79
79
|
res2 = get_json("/admin/#{res}.json", {"compact" => true})
|
80
|
-
|
80
|
+
attr_name = (k ? k.caption_attr : nil) || "caption"
|
81
|
+
associations[f] = res2.each_with_object({}){|r,d| d[ r["id"].to_i ] = r[attr_name] }
|
81
82
|
end
|
82
83
|
return associations
|
83
84
|
end
|
@@ -114,7 +115,6 @@ module Magellan
|
|
114
115
|
fields = original_fields.dup
|
115
116
|
fields.unshift(" ")
|
116
117
|
associations = association_map(fields)
|
117
|
-
|
118
118
|
t.head = fields
|
119
119
|
t.rows = []
|
120
120
|
selected_id = (load_selections[ parameter_name ] || {})["id"]
|
data/lib/magellan/cli/version.rb
CHANGED
@@ -22,6 +22,26 @@ describe Magellan::Cli::Resources::Project do
|
|
22
22
|
expect($stdout).to receive(:puts)
|
23
23
|
cmd.list
|
24
24
|
end
|
25
|
+
|
26
|
+
let(:org_res_body){ [{"id":8,"name":"test1","email":"","creator_id":4,"created_at":"2015-02-18T14:27:16.000Z","updated_at":"2015-02-18T14:27:16.000Z","max_project_count":1,"max_team_count":100}] }
|
27
|
+
let(:org_res){ double(:org_res, status: 200, body: org_res_body.to_json) }
|
28
|
+
let(:list_res_body){ [{"id":9,"organization_id":8,"default_nebula_id":2,"name":"Project1","icon_url":nil,"consumer_key":"test1.Project1","consumer_secret":"a5etckpurpy0od3keo25iw77mtllo2fb","created_at":"2015-02-18T14:27:21.000Z","updated_at":"2015-02-18T14:27:21.000Z","max_stage_count":2}] }
|
29
|
+
let(:list_res){ double(:res, status: 200, body: list_res_body.to_json) }
|
30
|
+
it do
|
31
|
+
buf = StringIO.new
|
32
|
+
$stdout, backup = buf, $stdout
|
33
|
+
begin
|
34
|
+
expect(httpclient).to receive(:get).with(%{#{base_url}/admin/project.json}).and_return(list_res)
|
35
|
+
expect(httpclient).to receive(:get).with(%{#{base_url}/admin/magellan~auth~organization.json}).and_return(org_res)
|
36
|
+
cmd.list
|
37
|
+
buf.rewind
|
38
|
+
output = buf.read
|
39
|
+
expect(output).to_not match /not found/
|
40
|
+
expect(output).to match /test1/
|
41
|
+
ensure
|
42
|
+
$stdout = backup
|
43
|
+
end
|
44
|
+
end
|
25
45
|
end
|
26
46
|
|
27
47
|
describe :show do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magellan-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akm2000
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|