magellan-cli 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48fddb6b7104d258581e1abf2a1ca583359ea419
4
- data.tar.gz: bd234a5b1aee93ee7a4d7ea48091c9c3e290134e
3
+ metadata.gz: 4b5b5f0a5bc12049990a5c842393ce408aff9a34
4
+ data.tar.gz: f4ce5c56d45a6b7fb2b17cc2620e512312a6d0ed
5
5
  SHA512:
6
- metadata.gz: e5df9b5e615d38bf2cd8620eb983b46d78fa9e77502b71b6d6dc79397dd4a47a5cfdd9963e440b3eaee37aaf6ad4779002df8eb96320112d4438623f5565e516
7
- data.tar.gz: 53ae945253f86ffd27e8258945f1b7ac8bb6c832fc6b0db89df97bc95d7dd0dfe21d175828321f3c63f8853fb95f67daf8e22eeaf735e6079a546fee2803036e
6
+ metadata.gz: 3f98e6f3f10adb66443ea4ebeaadd4ed16e45b4f875ad1dc23364bd3ed2ae6936c696cca338411ce1cc00f1ede15d7658e63d81dae79a625ac4e4484f251e90d
7
+ data.tar.gz: ac3fc0570bb6e17f6c5d5efe7ae0ae09a060ba302c7b92f74b8ba8f7a769072490ec633cf0a94af332aa05c171e6589df982326645896c7ce65577b3d105c774
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- magellan-cli (0.5.8)
4
+ magellan-cli (0.5.9)
5
5
  activesupport (~> 4.1.4)
6
6
  groovenauts-thor
7
7
  httpclient (~> 2.5)
@@ -81,7 +81,9 @@ module Magellan
81
81
  puts ""
82
82
  end
83
83
 
84
- Magellan::Cli::Http.new.login!(email, password)
84
+ result = Magellan::Cli::Http.new.login!(email, password)
85
+ select_single_resources
86
+ result
85
87
  end
86
88
 
87
89
  desc "info", I18n.t(:info, scope: [:command, :cmd])
@@ -100,6 +102,23 @@ module Magellan
100
102
  log_info YAML.dump(d)
101
103
  end
102
104
 
105
+ no_commands do
106
+
107
+ def select_single_resources
108
+ %w[Organization Project ClientVersion Stage Worker Image].each do |class_name|
109
+ klass = Magellan::Cli::Resources.const_get(class_name)
110
+ cmd = klass.new
111
+ res = cmd.send(:query_list)
112
+ if res.length == 1
113
+ value = res.first[klass.caption_attr]
114
+ cmd.select(value)
115
+ else
116
+ break
117
+ end
118
+ end
119
+ end
120
+
121
+ end
103
122
  end
104
123
  end
105
124
  end
@@ -83,7 +83,10 @@ en:
83
83
  cmd:
84
84
  select: "Select the %{resource_name} by VERSION"
85
85
  create: "Create a new %{resource_name} with VERSION"
86
+ update: "Update the ATTRIBUTES(filename or JSON) of the selected %{resource_name}"
86
87
  delete: "Delete the %{resource_name} specified by VERSION"
88
+ cmd_create:
89
+ domain: "Domain name for HTTP access without OAuth"
87
90
  stage:
88
91
  cmd:
89
92
  create: "Create a new %{resource_name} with Name and Type"
@@ -81,7 +81,10 @@ ja:
81
81
  cmd:
82
82
  select: "VERSIONを指定して%{resource_name}を選択します"
83
83
  create: "VERSIONを指定して%{resource_name}を登録します"
84
+ update: "選択した%{resource_name}の属性を指定したATTRIBUTESで更新します。ATTRIBUTESにはYAMLのファイル名かJSON文字列を指定可能です"
84
85
  delete: "VERSIONを指定して%{resource_name}を削除します"
86
+ cmd_create:
87
+ domain: "OAuth認証を行わずHTTPアクセスする際のアクセス先となるドメイン名"
85
88
  stage:
86
89
  cmd:
87
90
  create: "NAMEとTYPEを指定して%{resource_name}を登録します"
@@ -173,16 +173,20 @@ module Magellan
173
173
 
174
174
  def deselect
175
175
  update_selections! do |s|
176
- s.delete(self.class.parameter_name)
176
+ self.class.deselect(s)
177
177
  end
178
- deselect_dependants
179
178
  end
180
179
 
181
- def deselect_dependants
182
- update_selections! do |s|
183
- classes = Resources.dependants_on(self.class)
180
+ class << self
181
+ def deselect(selections)
182
+ selections.delete(parameter_name)
183
+ deselect_dependants(selections)
184
+ end
185
+
186
+ def deselect_dependants(selections)
187
+ classes = Resources.dependants_on(self)
184
188
  classes.each do |klass|
185
- s.delete(klass.parameter_name)
189
+ klass.deselect(selections)
186
190
  end
187
191
  end
188
192
  end
@@ -19,13 +19,12 @@ module Magellan
19
19
  def create(version)
20
20
  project = load_selection!(Project)
21
21
  stage = load_selection!(Stage)
22
- params = {
23
- parameter_name => {
24
- "project_id" => project["id"],
25
- "stage_title_id" => stage["id"],
26
- "version" => version,
27
- }
22
+ attrs = {
23
+ "project_id" => project["id"],
24
+ "stage_title_id" => stage["id"],
25
+ "version" => version,
28
26
  }
27
+ params = { parameter_name => attrs }
29
28
  post_json("/admin/#{resource_key}/new.json", params)
30
29
  # TODO implement select method
31
30
  # select(version)
@@ -38,7 +37,6 @@ module Magellan
38
37
  super("/admin/#{resource_key}/#{r['id']}/delete")
39
38
  log_success("OK")
40
39
  end
41
-
42
40
  end
43
41
 
44
42
  end
@@ -54,13 +54,10 @@ module Magellan
54
54
  update_first_result(VERSION_PARAMETER_NAME, "phase=1", "/admin/stage~version.json", q, %w[id])
55
55
  end
56
56
 
57
- desc "deselect", I18n.t(:deselect, scope: [:resources, :common, :cmd], res_name: resource_name)
58
- def deselect
59
- update_selections! do |s|
60
- s.delete(parameter_name)
61
- s.delete(VERSION_PARAMETER_NAME)
62
- end
63
- deselect_dependants
57
+ def self.deselect(selections)
58
+ selections.delete(parameter_name)
59
+ selections.delete(VERSION_PARAMETER_NAME)
60
+ deselect_dependants(selections)
64
61
  end
65
62
 
66
63
  desc "planning", I18n.t(:planning, scope: [:resources, :stage, :cmd])
@@ -1,5 +1,5 @@
1
1
  module Magellan
2
2
  module Cli
3
- VERSION = "0.5.8"
3
+ VERSION = "0.5.9"
4
4
  end
5
5
  end
@@ -9,6 +9,7 @@ describe Magellan::Cli::Command do
9
9
  describe :intaractive do
10
10
  before do
11
11
  $stdout = StringIO.new
12
+ allow(command).to receive(:select_single_resources)
12
13
  allow(Magellan::Cli::Http).to receive_message_chain(:new, :login!).and_return("OK")
13
14
  end
14
15
  it "nothing options" do
@@ -20,13 +21,15 @@ describe Magellan::Cli::Command do
20
21
 
21
22
  it "only email" do
22
23
  allow($stdin).to receive(:noecho).and_return(string).twice
23
- expect(command.invoke(:login, [], {email: string})).to eq "OK"
24
+ command.options = Thor::CoreExt::HashWithIndifferentAccess.new email: string
25
+ expect(command.login).to eq "OK"
24
26
  expect($stdout.string).to eq "password: \n"
25
27
  end
26
28
 
27
29
  it "only password" do
28
30
  allow($stdin).to receive(:gets).and_return(string).once
29
- expect(command.invoke(:login, [], {password: string})).to eq "OK"
31
+ command.options = Thor::CoreExt::HashWithIndifferentAccess.new password: string
32
+ expect(command.login).to eq "OK"
30
33
  expect($stdout.string).to eq "email: "
31
34
  end
32
35
  end
@@ -32,6 +32,7 @@ describe Magellan::Cli::Resources::ClientVersion do
32
32
  cmd.create("1.1.0")
33
33
  end
34
34
  end
35
+
35
36
  describe :error do
36
37
  context "stage not selected" do
37
38
  before do
@@ -0,0 +1,68 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe "deselect" do
5
+ let(:work_yaml){ File.expand_path("../../../../tmp/magellan-cli.yml", __FILE__) }
6
+ let(:src_yaml){ File.expand_path("../magellan-cli_test.yml", __FILE__) }
7
+ around do |example|
8
+ FileUtils.cp(src_yaml, work_yaml)
9
+ ENV["MAGELLAN_CLI_CONFIG_FILE"], backup = work_yaml, ENV["MAGELLAN_CLI_CONFIG_FILE"]
10
+ begin
11
+ example.run
12
+ ensure
13
+ ENV["MAGELLAN_CLI_CONFIG_FILE"] = backup
14
+ end
15
+ end
16
+
17
+ stage_children = [
18
+ Magellan::Cli::Resources::Team,
19
+ Magellan::Cli::Resources::Worker,
20
+ Magellan::Cli::Resources::Image,
21
+ ].freeze
22
+
23
+ stage_deletions = [
24
+ Magellan::Cli::Resources::Stage.parameter_name,
25
+ Magellan::Cli::Resources::Stage::VERSION_PARAMETER_NAME,
26
+ ] + stage_children.map(&:parameter_name)
27
+
28
+ project_deletions = stage_deletions + [
29
+ Magellan::Cli::Resources::Project,
30
+ Magellan::Cli::Resources::ClientVersion
31
+ ].map(&:parameter_name)
32
+
33
+ organization_deletions = project_deletions + [
34
+ Magellan::Cli::Resources::Organization,
35
+ ].map(&:parameter_name)
36
+
37
+ {
38
+ Magellan::Cli::Resources::Stage => stage_deletions,
39
+ Magellan::Cli::Resources::Project => project_deletions,
40
+ Magellan::Cli::Resources::Organization => organization_deletions,
41
+ }.each do |klass, deletions|
42
+ describe klass do
43
+ it do
44
+ selections = YAML.load_file(src_yaml)
45
+ subject.deselect
46
+ deletions.each do |key|
47
+ selections.delete(key)
48
+ end
49
+ expect(YAML.load_file(work_yaml)).to eq selections
50
+ end
51
+ end
52
+ end
53
+
54
+ (
55
+ stage_children +
56
+ [Magellan::Cli::Resources::ClientVersion]
57
+ ).each do |klass|
58
+ describe klass do
59
+ it do
60
+ selections = YAML.load_file(src_yaml)
61
+ subject.deselect
62
+ selections.delete(subject.parameter_name)
63
+ expect(YAML.load_file(work_yaml)).to eq selections
64
+ end
65
+ end
66
+ end
67
+
68
+ end
@@ -0,0 +1,25 @@
1
+ ---
2
+ last_update_searched_at: '2015-02-05 11:29:45 +0900'
3
+ login:
4
+ email: test1@groovenauts.jp
5
+ token: SyPdUbwSdEZQ-gNbf6L7
6
+ magellan_auth_organization:
7
+ id: 3
8
+ name: test2
9
+ project:
10
+ id: 3
11
+ name: Project1
12
+ client_version:
13
+ id: 4
14
+ version: Stage2
15
+ stage_title:
16
+ id: 3
17
+ name: Stage1
18
+ stage_version:
19
+ id: 8
20
+ functions_worker:
21
+ id: 3
22
+ name: worker1
23
+ container_image:
24
+ id: 9
25
+ name: groovenauts/magellan-rails-example-0.4.4
@@ -0,0 +1 @@
1
+ magellan-cli.yml
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.5.8
4
+ version: 0.5.9
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-09 00:00:00.000000000 Z
11
+ date: 2015-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -255,12 +255,15 @@ files:
255
255
  - spec/magellan/cli/messaging/http_spec.rb
256
256
  - spec/magellan/cli/messaging/mqtt_spec.rb
257
257
  - spec/magellan/cli/resources/client_version_spec.rb
258
+ - spec/magellan/cli/resources/deselect_spec.rb
259
+ - spec/magellan/cli/resources/magellan-cli_test.yml
258
260
  - spec/magellan/cli/resources/organization_spec.rb
259
261
  - spec/magellan/cli/resources/project_spec.rb
260
262
  - spec/magellan/cli/resources/team_spec.rb
261
263
  - spec/magellan/cli/script_spec.rb
262
264
  - spec/magellan/cli_spec.rb
263
265
  - spec/spec_helper.rb
266
+ - spec/tmp/.gitignore
264
267
  homepage: ''
265
268
  licenses:
266
269
  - MIT
@@ -298,9 +301,12 @@ test_files:
298
301
  - spec/magellan/cli/messaging/http_spec.rb
299
302
  - spec/magellan/cli/messaging/mqtt_spec.rb
300
303
  - spec/magellan/cli/resources/client_version_spec.rb
304
+ - spec/magellan/cli/resources/deselect_spec.rb
305
+ - spec/magellan/cli/resources/magellan-cli_test.yml
301
306
  - spec/magellan/cli/resources/organization_spec.rb
302
307
  - spec/magellan/cli/resources/project_spec.rb
303
308
  - spec/magellan/cli/resources/team_spec.rb
304
309
  - spec/magellan/cli/script_spec.rb
305
310
  - spec/magellan/cli_spec.rb
306
311
  - spec/spec_helper.rb
312
+ - spec/tmp/.gitignore