tugboat 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,13 @@
1
+ ## 0.0.7 (unreleased)
2
+
3
+ IMPROVEMENTS:
4
+ - [Pete](https://github.com/petems) made it clearer to the user
5
+ if they don't have any droplets or images. [GH-48], [GH-49]
6
+
7
+ BUG FIXES:
8
+
9
+ - Fix the initial check for authorization after `authorize` [GH-41]
10
+
1
11
  ## 0.0.6 (June 25, 2013)
2
12
 
3
13
  FEATURES:
@@ -13,6 +13,7 @@ module Tugboat
13
13
 
14
14
  # Write the config file.
15
15
  env['config'].create_config_file(client_key, api_key, ssh_key_path, ssh_user, ssh_port)
16
+ env['config'].reload!
16
17
 
17
18
  @app.call(env)
18
19
  end
@@ -5,15 +5,22 @@ module Tugboat
5
5
  def call(env)
6
6
  ocean = env["ocean"]
7
7
 
8
- ocean.droplets.list.droplets.each do |droplet|
8
+ droplet_list = ocean.droplets.list.droplets
9
9
 
10
- if droplet.status == "active"
11
- status_color = GREEN
12
- else
13
- status_color = RED
14
- end
10
+ if droplet_list.empty?
11
+ say "You don't appear to have any droplets.", :red
12
+ say "Try creating one with #{GREEN}\`tugboat create\`"
13
+ else
14
+ droplet_list.each do |droplet|
15
+
16
+ if droplet.status == "active"
17
+ status_color = GREEN
18
+ else
19
+ status_color = RED
20
+ end
15
21
 
16
- say "#{droplet.name} (ip: #{droplet.ip_address}, status: #{status_color}#{droplet.status}#{CLEAR}, region: #{droplet.region_id}, id: #{droplet.id})"
22
+ say "#{droplet.name} (ip: #{droplet.ip_address}, status: #{status_color}#{droplet.status}#{CLEAR}, region: #{droplet.region_id}, id: #{droplet.id})"
23
+ end
17
24
  end
18
25
 
19
26
  @app.call(env)
@@ -9,8 +9,13 @@ module Tugboat
9
9
  end
10
10
 
11
11
  say "My Images:"
12
- my_images.images.each do |image|
13
- say "#{image.name} (id: #{image.id}, distro: #{image.distribution})"
12
+ my_images_list = my_images.images
13
+ if my_images_list.empty?
14
+ say "No images found"
15
+ else
16
+ my_images_list.each do |image|
17
+ say "#{image.name} (id: #{image.id}, distro: #{image.distribution})"
18
+ end
14
19
  end
15
20
 
16
21
  if env["user_show_global_images"]
@@ -1,3 +1,3 @@
1
1
  module Tugboat
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -4,7 +4,7 @@ describe Tugboat::CLI do
4
4
  include_context "spec"
5
5
 
6
6
  describe "droplets" do
7
- it "shows a list" do
7
+ it "shows a list when droplets exist" do
8
8
  stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
9
9
  to_return(:status => 200, :body => fixture("show_droplets"))
10
10
 
@@ -18,6 +18,20 @@ foo (ip: 33.33.33.10, status: \e[32mactive\e[0m, region: 1, id: 100823)
18
18
 
19
19
  expect(a_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
20
20
  end
21
+
22
+ it "returns an error when no droplets exist" do
23
+ stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
24
+ to_return(:status => 200, :body => fixture("show_droplets_empty"))
25
+
26
+ @cli.droplets
27
+
28
+ expect($stdout.string).to eq <<-eos
29
+ You don't appear to have any droplets.
30
+ Try creating one with \e[32m`tugboat create`
31
+ eos
32
+
33
+ expect(a_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
34
+ end
21
35
  end
22
36
 
23
37
  end
@@ -19,6 +19,44 @@ NLP Final (id: 478, distro: Ubuntu)
19
19
  expect(a_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}&filter=my_images")).to have_been_made
20
20
  end
21
21
 
22
+ it "acknowledges when my images are empty" do
23
+ stub_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}&filter=my_images").
24
+ to_return(:status => 200, :body => fixture("show_images_empty"))
25
+
26
+ @cli.images
27
+
28
+ expect($stdout.string).to eq <<-eos
29
+ My Images:
30
+ No images found
31
+ eos
32
+
33
+ expect(a_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}&filter=my_images")).to have_been_made
34
+ end
35
+
36
+ it "acknowledges when my images are empty and also shows a global list" do
37
+ stub_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}&filter=my_images").
38
+ to_return(:status => 200, :body => fixture("show_images_empty"))
39
+
40
+ stub_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}&filter=global").
41
+ to_return(:status => 200, :body => fixture("show_images_global"))
42
+
43
+ @cli.options = @cli.options.merge(:global => true)
44
+ @cli.images
45
+
46
+ expect($stdout.string).to eq <<-eos
47
+ My Images:
48
+ No images found
49
+
50
+ Global Images:
51
+ NYTD Backup 1-18-2012 (id: 466, distro: Ubuntu)
52
+ NLP Final (id: 478, distro: Ubuntu)
53
+ Global Final (id: 479, distro: Ubuntu)
54
+ eos
55
+
56
+ expect(a_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}&filter=my_images")).to have_been_made
57
+ expect(a_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}&filter=global")).to have_been_made
58
+ end
59
+
22
60
  it "shows a global list" do
23
61
  stub_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}&filter=my_images").
24
62
  to_return(:status => 200, :body => fixture("show_images"))
@@ -0,0 +1,4 @@
1
+ {
2
+ "status":"OK",
3
+ "droplets":[]
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "status":"OK",
3
+ "images":[]
4
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tugboat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-25 00:00:00.000000000 Z
12
+ date: 2013-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -227,8 +227,10 @@ files:
227
227
  - spec/fixtures/show_droplet.json
228
228
  - spec/fixtures/show_droplet_inactive.json
229
229
  - spec/fixtures/show_droplets.json
230
+ - spec/fixtures/show_droplets_empty.json
230
231
  - spec/fixtures/show_droplets_inactive.json
231
232
  - spec/fixtures/show_images.json
233
+ - spec/fixtures/show_images_empty.json
232
234
  - spec/fixtures/show_images_global.json
233
235
  - spec/fixtures/show_keys.json
234
236
  - spec/fixtures/show_regions.json
@@ -294,8 +296,10 @@ test_files:
294
296
  - spec/fixtures/show_droplet.json
295
297
  - spec/fixtures/show_droplet_inactive.json
296
298
  - spec/fixtures/show_droplets.json
299
+ - spec/fixtures/show_droplets_empty.json
297
300
  - spec/fixtures/show_droplets_inactive.json
298
301
  - spec/fixtures/show_images.json
302
+ - spec/fixtures/show_images_empty.json
299
303
  - spec/fixtures/show_images_global.json
300
304
  - spec/fixtures/show_keys.json
301
305
  - spec/fixtures/show_regions.json