ey-pro-cli 0.0.8 → 0.0.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: 57d3fff7fc4233d4c688c411074765392116a533
4
- data.tar.gz: 04dea870e96a37ee4825cd847d69d4010c0e0185
3
+ metadata.gz: acf342d707f2bef9f0a62d3d9959b7ca0af1971d
4
+ data.tar.gz: 83fb71e8d8242a5c78aa13d27bac3e45bee649c2
5
5
  SHA512:
6
- metadata.gz: 5be7dc55325bcd456f648fba94e4ebcf0e66a8870c20f40e33e376677c96e78c29b7e46be0e75f0179391d893cae3ffe4e892b90ff89cd9203cf2657539267e6
7
- data.tar.gz: 69ff89cb26d29a0bb46d5be937ad5ed8fed42e0bf06c33504eed74f3d9255f4d106289916c00613ebae971dcf6c4c6caf85f530156c080b29ffbe06d961c7a55
6
+ metadata.gz: aba8b7a6881dd68087640013230e50780565bb3bed1abf398037e498449175b05221fc6ab4f14ea540f0c5c87bc33c72cd08602d2204978b25033cc5fbac88d8
7
+ data.tar.gz: 31a1ca488d31b1628d9e6ad1d5e7ce5ce059fccd190bd9627746f9573c7a54f8e6f70d5fd20109f45741a2ad84ce7ba8ea77954a4d0134765f00b3c1f3510ee1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ey-pro-cli (0.0.7)
4
+ ey-pro-cli (0.0.8)
5
5
  addressable (~> 2.2)
6
6
  cistern (~> 0.11, >= 0.11.1)
7
7
  colorize
@@ -11,6 +11,7 @@ PATH
11
11
  faye
12
12
  mime-types
13
13
  sshkey (~> 1.6)
14
+ table_print
14
15
  thor
15
16
 
16
17
  GEM
@@ -77,6 +78,7 @@ GEM
77
78
  rspec-support (3.3.0)
78
79
  slop (3.6.0)
79
80
  sshkey (1.7.0)
81
+ table_print (1.5.4)
80
82
  thor (0.19.1)
81
83
  websocket-driver (0.6.2)
82
84
  websocket-extensions (>= 0.1.0)
@@ -40,4 +40,5 @@ Gem::Specification.new do |s|
40
40
  s.add_dependency "faraday", "~> 0.9"
41
41
  s.add_dependency "faraday_middleware", "~> 0.9"
42
42
  s.add_dependency "mime-types"
43
+ s.add_dependency "table_print"
43
44
  end
@@ -7,6 +7,7 @@ $:.unshift(File.dirname(__FILE__) + '/vendor/core')
7
7
 
8
8
  require 'colorize'
9
9
  require 'thor'
10
+ require 'table_print'
10
11
  require File.expand_path(File.dirname(__FILE__) + '/ey_pro_cli/version')
11
12
  require File.expand_path(File.dirname(__FILE__) + '/vendor/core/ey-core')
12
13
 
@@ -19,6 +20,16 @@ class EyProCli < Thor
19
20
  end
20
21
  end
21
22
 
23
+ desc "accounts", "Retrieve a list of Engine Yard PRO accounts that you have access to"
24
+
25
+ def accounts
26
+ accounts = core_client.users.current.accounts
27
+ width = longest_account_name_length(accounts)
28
+
29
+ table_data = TablePrint::Printer.new(accounts, [{id: {width: 36}}, :name])
30
+ puts table_data.table_print
31
+ end
32
+
22
33
  desc "login", "Retrieve API token from Engine Yard PRO"
23
34
 
24
35
  def login
@@ -113,6 +124,10 @@ class EyProCli < Thor
113
124
 
114
125
  private
115
126
 
127
+ def longest_account_name_length(accounts)
128
+ accounts.map(&:name).group_by(&:size).max.last.length
129
+ end
130
+
116
131
  def check_for_updates
117
132
  gem = core_client.gems.get("ey-pro-cli")
118
133
  unless gem
@@ -1,3 +1,3 @@
1
1
  module EyProCliVersion
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe EyProCli do
4
+ describe "accounts" do
5
+ context "with a token" do
6
+ before(:each) do
7
+ create_core_credentials
8
+ @accounts = create_accounts(subject.core_client, quantity: 2)
9
+ end
10
+
11
+ it "returns a list of accounts" do
12
+ output = capture(:stdout) { subject.accounts }
13
+
14
+ expect(output).to match(/#{@accounts.first.id}/)
15
+ expect(output).to match(/#{@accounts.first.name}/)
16
+ expect(output).to match(/#{@accounts.last.id}/)
17
+ expect(output).to match(/#{@accounts.last.name}/)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -2,54 +2,49 @@ require 'spec_helper'
2
2
 
3
3
  describe EyProCli do
4
4
  describe "deploy" do
5
- before(:each) do
6
- @tempfile.write <<-EOF
7
- ---
8
- '#{subject.core_url}': #{SecureRandom.hex(20)}'
9
- EOF
10
- @tempfile.rewind
11
- subject.class.core_file = @tempfile
12
- end
5
+ context "with a token" do
6
+ before(:each) { create_core_credentials }
13
7
 
14
- let(:options) { {} }
8
+ let(:options) { {} }
15
9
 
16
- context "with a running environment" do
17
- before(:each) do
18
- account, environment, application = boot_environment(subject.core_client)
10
+ context "with a running environment" do
11
+ before(:each) do
12
+ account, environment, application = boot_environment(subject.core_client)
19
13
 
20
- options.merge!(
21
- :account => account.name,
22
- :app => application.name,
23
- :environment => environment.name,
24
- )
25
- end
14
+ options.merge!(
15
+ :account => account.name,
16
+ :app => application.name,
17
+ :environment => environment.name,
18
+ )
19
+ end
26
20
 
27
- it "successfully deploys" do
28
- subject.options = options
21
+ it "successfully deploys" do
22
+ subject.options = options
29
23
 
30
- expect(capture(:stdout) { subject.deploy }).to match(/deploy successful/i)
31
- end
24
+ expect(capture(:stdout) { subject.deploy }).to match(/deploy successful/i)
25
+ end
32
26
 
33
- context "--stream" do
34
- before(:each) { options.merge!(stream: true) }
27
+ context "--stream" do
28
+ before(:each) { options.merge!(stream: true) }
35
29
 
36
- it "streams" do
37
- subject.options = options
38
- expect(capture(:stdout) { subject.deploy }).to match(/subscription failed/i) # proves that the flag works, even if the mock doesn't
30
+ it "streams" do
31
+ subject.options = options
32
+ expect(capture(:stdout) { subject.deploy }).to match(/subscription failed/i) # proves that the flag works, even if the mock doesn't
33
+ end
39
34
  end
40
- end
41
35
 
42
- context "--no-update-check" do
43
- before(:each) { subject.options = options }
36
+ context "--no-update-check" do
37
+ before(:each) { subject.options = options }
44
38
 
45
- it "has the updater message without the flag" do
46
- expect(capture(:stdout) { subject.deploy }).to match(/gem outdated, consider updating/i)
47
- end
39
+ it "has the updater message without the flag" do
40
+ expect(capture(:stdout) { subject.deploy }).to match(/gem outdated, consider updating/i)
41
+ end
48
42
 
49
- it "does not have the message with the flag" do
50
- options.merge!("no-update-check" => true)
43
+ it "does not have the message with the flag" do
44
+ options.merge!("no-update-check" => true)
51
45
 
52
- expect(capture(:stdout) { subject.deploy }).not_to match(/gem outdated, consider updating/i)
46
+ expect(capture(:stdout) { subject.deploy }).not_to match(/gem outdated, consider updating/i)
47
+ end
53
48
  end
54
49
  end
55
50
  end
@@ -3,32 +3,19 @@ require 'spec_helper'
3
3
  describe EyProCli do
4
4
  describe "login" do
5
5
  context "with a valid user and password" do
6
- before(:each) { subject.class.core_file = @tempfile }
7
-
8
6
  it "writes the token" do
9
- allow(subject).to receive(:ask) { FFaker::Internet.email }
10
-
11
- output = capture(:stdout) { subject.login }
12
- expect(output).to match(/writing token/i)
13
-
14
- expect(read_yaml(@tempfile)).to have_key("https://api.engineyard.com/")
7
+ create_core_credentials
15
8
  end
16
9
 
17
10
  it "updates the token if it does not match" do
18
- allow(subject).to receive(:ask) { FFaker::Internet.email }
19
-
20
- output = capture(:stdout) { subject.login }
21
- expect(output).to match(/writing token/i)
11
+ create_core_credentials
22
12
 
23
13
  output = capture(:stdout) { subject.login }
24
14
  expect(output).to match(/token does not match/i)
25
15
  end
26
16
 
27
17
  it "does not update the token if it already exists" do
28
- allow(subject).to receive(:ask) { FFaker::Internet.email }
29
-
30
- output = capture(:stdout) { subject.login }
31
- expect(output).to match(/writing token/i)
18
+ create_core_credentials
32
19
 
33
20
  yaml = read_yaml(@tempfile)
34
21
  expect(yaml).to have_key("https://api.engineyard.com/")
@@ -2,14 +2,16 @@ require 'spec_helper'
2
2
 
3
3
  describe EyProCli do
4
4
  describe "logout" do
5
- context "with a token" do
6
- before(:each) do
7
- subject.class.core_file = @tempfile
8
-
9
- allow(subject).to receive(:ask) { FFaker::Internet.email }
5
+ context "without a token" do
6
+ before(:each) { subject.class.core_file = @tempfile }
10
7
 
11
- expect(capture(:stdout) { subject.login }).to match(/writing token/i)
8
+ it "handles a missing token" do
9
+ expect(capture(:stdout) { subject.logout }).to match(/no api token found/i)
12
10
  end
11
+ end
12
+
13
+ context "with a token" do
14
+ before(:each) { create_core_credentials }
13
15
 
14
16
  it "removes the token" do
15
17
  expect(capture(:stdout) { subject.logout }).to match(/successfully removed api token/i)
@@ -1,6 +1,6 @@
1
1
  module CoreHelper
2
2
  def boot_environment(core_client)
3
- account = core_client.accounts.create(name: SecureRandom.hex(4))
3
+ account = create_accounts(core_client).first
4
4
  environment = account.environments.create(name: SecureRandom.hex(4))
5
5
  application = account.applications.create(name: SecureRandom.hex(4))
6
6
  provider = create_provider(account)
@@ -12,6 +12,12 @@ module CoreHelper
12
12
  [account, environment, application]
13
13
  end
14
14
 
15
+ def create_accounts(core_client, quantity: 1)
16
+ quantity.times.map do |iteration|
17
+ core_client.accounts.create(name: SecureRandom.hex(4))
18
+ end
19
+ end
20
+
15
21
  def create_provider(account)
16
22
  attributes = {type: :aws, provisioned_id: SecureRandom.hex(8)}
17
23
  attributes[:credentials] ||= {
@@ -25,6 +31,16 @@ module CoreHelper
25
31
 
26
32
  account.providers.create!(attributes).resource!
27
33
  end
34
+
35
+ def create_core_credentials
36
+ subject.class.core_file = @tempfile
37
+
38
+ allow(subject).to receive(:ask) { FFaker::Internet.email }
39
+
40
+ output = capture(:stdout) { subject.login }
41
+
42
+ expect(read_yaml(@tempfile)).to have_key("https://api.engineyard.com/")
43
+ end
28
44
  end
29
45
 
30
46
  RSpec.configure do |config|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ey-pro-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Engine Yard Cloud Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-28 00:00:00.000000000 Z
11
+ date: 2015-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -240,6 +240,20 @@ dependencies:
240
240
  - - ">="
241
241
  - !ruby/object:Gem::Version
242
242
  version: '0'
243
+ - !ruby/object:Gem::Dependency
244
+ name: table_print
245
+ requirement: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - ">="
248
+ - !ruby/object:Gem::Version
249
+ version: '0'
250
+ type: :runtime
251
+ prerelease: false
252
+ version_requirements: !ruby/object:Gem::Requirement
253
+ requirements:
254
+ - - ">="
255
+ - !ruby/object:Gem::Version
256
+ version: '0'
243
257
  description: This gem allows you to deploy your rails application to Engine Yard Pro
244
258
  directly from the command line.
245
259
  email: cloud@engineyard.com
@@ -598,6 +612,7 @@ files:
598
612
  - lib/vendor/core/ey-core/subscribable.rb
599
613
  - lib/vendor/core/ey-core/token_authentication.rb
600
614
  - lib/vendor/core/ey-core/version.rb
615
+ - spec/accounts_spec.rb
601
616
  - spec/deploy_spec.rb
602
617
  - spec/login_spec.rb
603
618
  - spec/logout_spec.rb
@@ -628,6 +643,7 @@ signing_key:
628
643
  specification_version: 4
629
644
  summary: Command-line deployment for Engine Yard pro
630
645
  test_files:
646
+ - spec/accounts_spec.rb
631
647
  - spec/deploy_spec.rb
632
648
  - spec/login_spec.rb
633
649
  - spec/logout_spec.rb