shelly 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/shelly/cli/endpoint.rb +2 -2
- data/lib/shelly/cli/logs.rb +3 -2
- data/lib/shelly/cli/main.rb +7 -1
- data/lib/shelly/client.rb +11 -4
- data/lib/shelly/version.rb +1 -1
- data/spec/shelly/cli/logs_spec.rb +3 -2
- data/spec/shelly/cli/main_spec.rb +11 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3108d5cd82ebb8ac69e5fd386eb9411449723c8
|
4
|
+
data.tar.gz: 16d0a5f75fc68e4126726035ffd456f29806add9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25ab6d5221843cef3dae2a38b1d6f3864c8a4c5b2af71d1b0bc0afc4708347faab21dacb51e4b9d7bedd9fad7eccb81e9477cc3d72f751f8cd39afdc30268b8c
|
7
|
+
data.tar.gz: c4fb2607b1c07cb6c0d7e67211a006c5d3e6a922cfba831ff6bf7c21230ab9630ef2ccbaf5a12773152570f06e85552f52a6cf7bd85cfb622a4bc6f7c42159b0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 0.5.1 / 2015-02-01
|
2
|
+
|
3
|
+
* [improvement] shelly logout --key option
|
4
|
+
* [bugfix] Show proper error message when log file does not exist
|
5
|
+
* [bugfix] Catch 404s when updating and deleting endpoints. API resource
|
6
|
+
certificate changed to endpoint
|
7
|
+
|
1
8
|
## 0.5.0 / 2015-01-02
|
2
9
|
|
3
10
|
* [bugfix] Catch Conflict 409 when creating or updating endpoints
|
data/lib/shelly/cli/endpoint.rb
CHANGED
@@ -143,7 +143,7 @@ module Shelly
|
|
143
143
|
rescue Client::ConflictException => e
|
144
144
|
say_error e['message']
|
145
145
|
rescue Client::NotFoundException => e
|
146
|
-
raise unless e.resource == :
|
146
|
+
raise unless e.resource == :endpoint
|
147
147
|
say_error "Endpoint not found"
|
148
148
|
end
|
149
149
|
|
@@ -160,7 +160,7 @@ module Shelly
|
|
160
160
|
say "Endpoint was deleted"
|
161
161
|
end
|
162
162
|
rescue Client::NotFoundException => e
|
163
|
-
raise unless e.resource == :
|
163
|
+
raise unless e.resource == :endpoint
|
164
164
|
say_error "Endpoint not found"
|
165
165
|
end
|
166
166
|
|
data/lib/shelly/cli/logs.rb
CHANGED
@@ -43,8 +43,9 @@ module Shelly
|
|
43
43
|
|
44
44
|
say_new_line
|
45
45
|
say "Log file saved to #{attributes["filename"]}", :green
|
46
|
-
rescue
|
47
|
-
|
46
|
+
rescue Client::NotFoundException => e
|
47
|
+
bar.clear
|
48
|
+
say_error "Log file for #{date} not found", :with_exit => false
|
48
49
|
rescue Client::ValidationException => e
|
49
50
|
e.each_error { |error| say_error error, :with_exit => false }
|
50
51
|
end
|
data/lib/shelly/cli/main.rb
CHANGED
@@ -283,9 +283,15 @@ Wait until cloud is in 'turned off' state and try again.}
|
|
283
283
|
end
|
284
284
|
|
285
285
|
desc "logout", "Logout from Shelly Cloud"
|
286
|
+
method_option :key, :alias => :k, :desc => "Path to specific SSH key",
|
287
|
+
:default => nil
|
286
288
|
def logout
|
287
289
|
user = Shelly::User.new
|
288
|
-
|
290
|
+
key = Shelly::SshKey.new(options[:key]) if options[:key]
|
291
|
+
if (key || user.ssh_keys).destroy
|
292
|
+
say "Your public SSH key has been removed from Shelly Cloud"
|
293
|
+
end
|
294
|
+
|
289
295
|
say "You have been successfully logged out" if user.logout
|
290
296
|
end
|
291
297
|
|
data/lib/shelly/client.rb
CHANGED
@@ -53,8 +53,10 @@ module Shelly
|
|
53
53
|
def download_file(cloud, filename, url, progress_callback = nil)
|
54
54
|
File.open(filename, "wb") do |out|
|
55
55
|
process_response = lambda do |response|
|
56
|
+
raise_error_for_400_to_599(response.code.to_i)
|
56
57
|
|
57
58
|
total_size = response.to_hash['file-size'].first.to_i if response.to_hash['file-size']
|
59
|
+
|
58
60
|
response.read_body do |chunk|
|
59
61
|
out.write(chunk)
|
60
62
|
|
@@ -110,8 +112,14 @@ module Shelly
|
|
110
112
|
def process_response(response)
|
111
113
|
body = JSON.parse(response.body) rescue JSON::ParserError && {}
|
112
114
|
code = response.code
|
115
|
+
raise_error_for_400_to_599(code, body, response)
|
116
|
+
response.return!
|
117
|
+
body
|
118
|
+
end
|
119
|
+
|
120
|
+
def raise_error_for_400_to_599(code, body = nil, response = nil)
|
113
121
|
if (400..599).include?(code)
|
114
|
-
exception_class = case
|
122
|
+
exception_class = case code
|
115
123
|
when 401; UnauthorizedException
|
116
124
|
when 403; ForbiddenException
|
117
125
|
when 404; NotFoundException
|
@@ -122,10 +130,9 @@ module Shelly
|
|
122
130
|
when 504; GatewayTimeoutException
|
123
131
|
else; APIException
|
124
132
|
end
|
125
|
-
|
133
|
+
request_id = response.headers[:x_request_id] if response.respond_to?(:headers)
|
134
|
+
raise exception_class.new(body, code, request_id)
|
126
135
|
end
|
127
|
-
response.return!
|
128
|
-
body
|
129
136
|
end
|
130
137
|
end
|
131
138
|
end
|
data/lib/shelly/version.rb
CHANGED
@@ -124,9 +124,10 @@ describe Shelly::CLI::Logs do
|
|
124
124
|
|
125
125
|
context "on log file not found" do
|
126
126
|
it "should display error message" do
|
127
|
-
exception =
|
127
|
+
exception = Shelly::Client::NotFoundException.new
|
128
128
|
@client.stub(:download_file).and_raise(exception)
|
129
|
-
|
129
|
+
@bar.should_receive(:clear)
|
130
|
+
$stdout.should_receive(:puts).with(red "Log file for 2013-05-31 not found")
|
130
131
|
invoke(@cli_logs, :get, "2013-05-31")
|
131
132
|
end
|
132
133
|
end
|
@@ -1508,6 +1508,17 @@ Wait until cloud is in 'turned off' state and try again.")
|
|
1508
1508
|
user.ssh_keys.should_receive(:destroy)
|
1509
1509
|
invoke(@main, :logout)
|
1510
1510
|
end
|
1511
|
+
|
1512
|
+
context "option key" do
|
1513
|
+
it "should be removed" do
|
1514
|
+
sshkey = mock
|
1515
|
+
Shelly::SshKey.should_receive(:new).with('path/sshkey.pub').and_return(sshkey)
|
1516
|
+
$stdout.should_receive(:puts).with("Your public SSH key has been removed from Shelly Cloud")
|
1517
|
+
sshkey.should_receive(:destroy).and_return(true)
|
1518
|
+
@main.options = {:key => "path/sshkey.pub"}
|
1519
|
+
invoke(@main, :logout)
|
1520
|
+
end
|
1521
|
+
end
|
1511
1522
|
end
|
1512
1523
|
|
1513
1524
|
describe "#rake" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shelly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shelly Cloud team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01
|
11
|
+
date: 2015-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -359,7 +359,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
359
359
|
version: '0'
|
360
360
|
requirements: []
|
361
361
|
rubyforge_project: shelly
|
362
|
-
rubygems_version: 2.4.
|
362
|
+
rubygems_version: 2.4.3
|
363
363
|
signing_key:
|
364
364
|
specification_version: 4
|
365
365
|
summary: Shelly Cloud command line tool
|