magellan-cli 0.2.2 → 0.2.3
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 +18 -13
- data/lib/magellan/cli/login.rb +3 -0
- data/lib/magellan/cli/resources/client_version.rb +1 -1
- data/lib/magellan/cli/resources/cloudsql.rb +1 -1
- data/lib/magellan/cli/resources/organization.rb +1 -1
- data/lib/magellan/cli/resources/project.rb +1 -1
- data/lib/magellan/cli/resources/stage.rb +1 -1
- data/lib/magellan/cli/resources/team.rb +1 -1
- data/lib/magellan/cli/resources/transaction_router.rb +1 -1
- data/lib/magellan/cli/resources/worker_version.rb +1 -1
- data/lib/magellan/cli/version.rb +1 -1
- data/spec/magellan/cli/resources/client_version_spec.rb +1 -1
- data/spec/magellan/cli/resources/organization_spec.rb +1 -1
- data/spec/magellan/cli/resources/project_spec.rb +2 -0
- data/spec/magellan/cli/resources/team_spec.rb +1 -1
- 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: 5c657e803c1316bbcf6ab385531c2399076d4370
|
4
|
+
data.tar.gz: 46fa633ed4fec7b8bb9f55ab446192ff7dbe7a9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1e084d92a653dbbd5e0596752d60c19ae6e2450efb6ab54920ccbfcbea71813818c7a5774b5e0e0cb32bbe6e0530c6f2df715bcfe3fc074de51fba4727f2c6c
|
7
|
+
data.tar.gz: 2e9ecec939e2e7d57718aec804f9a55d6f1aaace363d38b29ee953535d018a84a1c10ba96cbdb3f9c483e65f019520a4eda6e5a648d9a69d0d9efd6b65027416
|
data/Gemfile.lock
CHANGED
data/lib/magellan/cli/http.rb
CHANGED
@@ -13,6 +13,22 @@ module Magellan
|
|
13
13
|
return block_given? ? yield(cli) : success("OK")
|
14
14
|
end
|
15
15
|
|
16
|
+
def check_response(res)
|
17
|
+
case res.status
|
18
|
+
when 200...300 then
|
19
|
+
r = JSON.parse(res.body)
|
20
|
+
verbose(JSON.pretty_generate(r))
|
21
|
+
r
|
22
|
+
else
|
23
|
+
obj = JSON.parse(res.body) rescue nil
|
24
|
+
if obj and obj.is_a?(Hash) and obj["message"]
|
25
|
+
error(obj["message"])
|
26
|
+
else
|
27
|
+
error("HTTP Error: status=#{res.status}: #{res.body}")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
16
32
|
# ログインしてGETします
|
17
33
|
# @param [String] rel_path cli.base_url からの相対パス
|
18
34
|
# @param [Hash] params クエリ文字列
|
@@ -28,7 +44,7 @@ module Magellan
|
|
28
44
|
$stderr, bak = StringIO.new, $stderr
|
29
45
|
begin
|
30
46
|
res = cli.httpclient.get(url)
|
31
|
-
|
47
|
+
check_response(res)
|
32
48
|
ensure
|
33
49
|
$stderr = bak
|
34
50
|
end
|
@@ -93,18 +109,7 @@ module Magellan
|
|
93
109
|
url = "#{cli.base_url}#{rel_path}"
|
94
110
|
verbose("%s %s\n%s" % [http_method, url, args])
|
95
111
|
res = cli.httpclient.send(http_method, url, *args)
|
96
|
-
|
97
|
-
when 200...300 then
|
98
|
-
r = JSON.parse(res.body)
|
99
|
-
verbose(JSON.pretty_generate(r))
|
100
|
-
unless r["success"]
|
101
|
-
error(r["message"])
|
102
|
-
end
|
103
|
-
return r
|
104
|
-
else
|
105
|
-
info("\e[31m[#{res.status}]\e[0m\ #{res.body}")
|
106
|
-
return nil
|
107
|
-
end
|
112
|
+
check_response(res)
|
108
113
|
end
|
109
114
|
|
110
115
|
end
|
data/lib/magellan/cli/login.rb
CHANGED
@@ -100,6 +100,9 @@ module Magellan
|
|
100
100
|
res = Ssl.retry_on_ssl_error("login_form"){ @httpclient.get(login_form_url) }
|
101
101
|
doc = Nokogiri::HTML.parse(res.body, login_form_url, res.body_encoding.to_s)
|
102
102
|
node = doc.xpath('//input[@name="authenticity_token"]').first
|
103
|
+
unless node
|
104
|
+
raise Cli::Error.new("fail to login Magellan")
|
105
|
+
end
|
103
106
|
node.attribute('value').value
|
104
107
|
end
|
105
108
|
|
data/lib/magellan/cli/version.rb
CHANGED
@@ -20,7 +20,7 @@ describe Magellan::Cli::Resources::ClientVersion do
|
|
20
20
|
describe :success do
|
21
21
|
before do
|
22
22
|
expect(cmd).to receive(:load_selections).and_return({"project" => {"id" => 1, "name" => "ProjectA"}, "stage" => {"id" => 1, "name" => "StageA"} })
|
23
|
-
expect(cmd).to receive(:post_json).with("/admin/client_version/new.
|
23
|
+
expect(cmd).to receive(:post_json).with("/admin/client_version/new.json", { "client_version" => { "stage_title_id" => 1, "version" => "1.1.0" } })
|
24
24
|
end
|
25
25
|
it do
|
26
26
|
cmd.create("1.1.0")
|
@@ -17,7 +17,7 @@ describe Magellan::Cli::Resources::Organization do
|
|
17
17
|
|
18
18
|
describe :create do
|
19
19
|
before do
|
20
|
-
expect(cmd).to receive(:post_json).with("/admin/magellan~auth~organization/new.
|
20
|
+
expect(cmd).to receive(:post_json).with("/admin/magellan~auth~organization/new.json", {"magellan_auth_organization" => { "name" => "new1" }})
|
21
21
|
end
|
22
22
|
it do
|
23
23
|
cmd.create("new1")
|
@@ -21,6 +21,7 @@ describe Magellan::Cli::Resources::Project do
|
|
21
21
|
describe :list do
|
22
22
|
it do
|
23
23
|
allow(res).to receive(:body).and_return("[]")
|
24
|
+
allow(res).to receive(:status).and_return(200)
|
24
25
|
expect(httpclient).to receive(:get).with("#{base_url}/admin/project.json").and_return(res)
|
25
26
|
expect($stdout).to receive(:puts)
|
26
27
|
cmd.list
|
@@ -30,6 +31,7 @@ describe Magellan::Cli::Resources::Project do
|
|
30
31
|
describe :show do
|
31
32
|
it do
|
32
33
|
allow(res).to receive(:body).and_return("{}")
|
34
|
+
allow(res).to receive(:status).and_return(200)
|
33
35
|
expect(httpclient).to receive(:get).with("#{base_url}/admin/project/1.json").and_return(res)
|
34
36
|
expect($stdout).to receive(:puts)
|
35
37
|
cmd.show(1)
|
@@ -20,7 +20,7 @@ describe Magellan::Cli::Resources::Team do
|
|
20
20
|
describe :success do
|
21
21
|
before do
|
22
22
|
expect(cmd).to receive(:load_selection).with("magellan_auth_organization").and_return({"id" => 1, "name" => "org1"})
|
23
|
-
expect(cmd).to receive(:post_json).with("/admin/magellan~auth~team/new.
|
23
|
+
expect(cmd).to receive(:post_json).with("/admin/magellan~auth~team/new.json", { "magellan_auth_team" => { "organization_id" => 1, "name" => "team1", "role" => role } })
|
24
24
|
end
|
25
25
|
context "role=readers" do
|
26
26
|
let(:role){ "readers" }
|
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.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akm2000
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|