shelly 0.2.26 → 0.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +5 -0
- data/lib/shelly/app.rb +8 -0
- data/lib/shelly/backup.rb +2 -1
- data/lib/shelly/cli/logs.rb +53 -0
- data/lib/shelly/cli/main.rb +3 -26
- data/lib/shelly/client.rb +12 -2
- data/lib/shelly/version.rb +1 -1
- data/spec/shelly/backup_spec.rb +4 -1
- data/spec/shelly/cli/backup_spec.rb +14 -5
- data/spec/shelly/cli/logs_spec.rb +144 -0
- data/spec/shelly/cli/main_spec.rb +1 -51
- data/spec/shelly/client_spec.rb +6 -12
- metadata +23 -68
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
+
## 0.2.27 / 2013-06-11
|
2
|
+
|
3
|
+
* [feature] user is able to download logs for a given day by `shelly logs get [DATE]`
|
4
|
+
|
1
5
|
## 0.2.26 / 2013-06-10
|
6
|
+
|
2
7
|
* [bug] `shelly backup import` now actually compresses the file (bzip2 is used)
|
3
8
|
* [improvement] `shelly backup import` also accepts path to dump file
|
4
9
|
|
data/lib/shelly/app.rb
CHANGED
@@ -105,6 +105,14 @@ module Shelly
|
|
105
105
|
shelly.application_logs_tail(code_name) { |l| yield(l) }
|
106
106
|
end
|
107
107
|
|
108
|
+
def download_application_logs_attributes(date)
|
109
|
+
shelly.download_application_logs_attributes(code_name, date)
|
110
|
+
end
|
111
|
+
|
112
|
+
def download_application_logs(options, callback)
|
113
|
+
shelly.download_file(code_name, options["filename"], options["url"], callback)
|
114
|
+
end
|
115
|
+
|
108
116
|
def database_backups
|
109
117
|
shelly.database_backups(code_name).map do |attributes|
|
110
118
|
Shelly::Backup.new(attributes.merge("code_name" => code_name))
|
data/lib/shelly/backup.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
require "shelly/cli/command"
|
2
|
+
|
3
|
+
module Shelly
|
4
|
+
module CLI
|
5
|
+
class Logs < Command
|
6
|
+
namespace :logs
|
7
|
+
include Helpers
|
8
|
+
|
9
|
+
before_hook :logged_in?, :only => [:latest, :get]
|
10
|
+
class_option :cloud, :type => :string, :aliases => "-c", :desc => "Specify cloud"
|
11
|
+
|
12
|
+
desc "latest", "Show latest application logs"
|
13
|
+
method_option :limit, :type => :numeric, :aliases => "-n", :desc => "Amount of messages to show"
|
14
|
+
method_option :from, :type => :string, :desc => "Time from which to find the logs"
|
15
|
+
method_option :source, :type => :string, :aliases => "-s", :desc => "Limit logs to a single source, e.g. nginx"
|
16
|
+
method_option :tail, :type => :boolean, :aliases => "-f", :desc => "Show new logs automatically"
|
17
|
+
def latest
|
18
|
+
app = multiple_clouds(options[:cloud], "logs latest")
|
19
|
+
limit = options[:limit].to_i <= 0 ? 100 : options[:limit]
|
20
|
+
query = {:limit => options[:limit], :source => options[:source]}
|
21
|
+
query.merge!(:from => options[:from]) if options[:from]
|
22
|
+
|
23
|
+
logs = app.application_logs(query)
|
24
|
+
print_logs(logs)
|
25
|
+
|
26
|
+
if options[:tail]
|
27
|
+
app.application_logs_tail { |logs| print logs }
|
28
|
+
end
|
29
|
+
rescue Client::APIException => e
|
30
|
+
raise e unless e.status_code == 416
|
31
|
+
say_error "You have requested too many log messages. Try a lower number."
|
32
|
+
end
|
33
|
+
|
34
|
+
map "download" => :get
|
35
|
+
desc "get [DATE]", "Download log file from a specific date"
|
36
|
+
def get(date = "yesterday")
|
37
|
+
app = multiple_clouds(options[:cloud], "logs get #{date}")
|
38
|
+
|
39
|
+
attributes = app.download_application_logs_attributes({:date => date})
|
40
|
+
bar = Shelly::DownloadProgressBar.new(attributes["size"])
|
41
|
+
|
42
|
+
app.download_application_logs(attributes, bar.progress_callback)
|
43
|
+
|
44
|
+
say_new_line
|
45
|
+
say "Log file saved to #{attributes["filename"]}", :green
|
46
|
+
rescue RestClient::ResourceNotFound => e
|
47
|
+
say_error "Log file not found", :with_exit => false
|
48
|
+
rescue Client::ValidationException => e
|
49
|
+
e.each_error { |error| say_error error, :with_exit => false }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/shelly/cli/main.rb
CHANGED
@@ -6,6 +6,7 @@ require "shelly/cli/deploy"
|
|
6
6
|
require "shelly/cli/config"
|
7
7
|
require "shelly/cli/file"
|
8
8
|
require "shelly/cli/organization"
|
9
|
+
require "shelly/cli/logs"
|
9
10
|
|
10
11
|
module Shelly
|
11
12
|
module CLI
|
@@ -16,11 +17,12 @@ module Shelly
|
|
16
17
|
register_subcommand(Config, "config", "config <command>", "Manage application configuration files")
|
17
18
|
register_subcommand(File, "file", "file <command>", "Upload and download files to and from persistent storage")
|
18
19
|
register_subcommand(Organization, "organization", "organization <command>", "View organizations")
|
20
|
+
register_subcommand(Logs, "logs", "logs <command>", "View application logs")
|
19
21
|
|
20
22
|
check_unknown_options!(:except => :rake)
|
21
23
|
|
22
24
|
# FIXME: it should be possible to pass single symbol, instead of one element array
|
23
|
-
before_hook :logged_in?, :only => [:add, :status, :list, :start, :stop, :
|
25
|
+
before_hook :logged_in?, :only => [:add, :status, :list, :start, :stop, :delete, :info, :ip, :logout, :execute, :rake, :setup, :console, :dbconsole]
|
24
26
|
before_hook :inside_git_repository?, :only => [:add, :setup, :check]
|
25
27
|
|
26
28
|
map %w(-v --version) => :version
|
@@ -315,31 +317,6 @@ Wait until cloud is in 'turned off' state and try again.}
|
|
315
317
|
say_error e[:message]
|
316
318
|
end
|
317
319
|
|
318
|
-
desc "logs", "Show latest application logs"
|
319
|
-
method_option :cloud, :type => :string, :aliases => "-c", :desc => "Specify cloud"
|
320
|
-
method_option :limit, :type => :numeric, :aliases => "-n", :desc => "Amount of messages to show"
|
321
|
-
method_option :from, :type => :string, :desc => "Time from which to find the logs"
|
322
|
-
method_option :source, :type => :string, :aliases => "-s", :desc => "Limit logs to a single source, e.g. nginx"
|
323
|
-
method_option :tail, :type => :boolean, :aliases => "-f", :desc => "Show new logs automatically"
|
324
|
-
def logs
|
325
|
-
cloud = options[:cloud]
|
326
|
-
app = multiple_clouds(cloud, "logs")
|
327
|
-
limit = options[:limit].to_i <= 0 ? 100 : options[:limit]
|
328
|
-
query = {:limit => limit, :source => options[:source]}
|
329
|
-
query.merge!(:from => options[:from]) if options[:from]
|
330
|
-
|
331
|
-
logs = app.application_logs(query)
|
332
|
-
print_logs(logs)
|
333
|
-
|
334
|
-
if options[:tail]
|
335
|
-
app.application_logs_tail { |logs| print logs }
|
336
|
-
end
|
337
|
-
|
338
|
-
rescue Client::APIException => e
|
339
|
-
raise e unless e.status_code == 416
|
340
|
-
say_error "You have requested too many log messages. Try a lower number."
|
341
|
-
end
|
342
|
-
|
343
320
|
desc "logout", "Logout from Shelly Cloud"
|
344
321
|
def logout
|
345
322
|
user = Shelly::User.new
|
data/lib/shelly/client.rb
CHANGED
@@ -174,6 +174,16 @@ module Shelly
|
|
174
174
|
RestClient::Request.execute(options)
|
175
175
|
end
|
176
176
|
|
177
|
+
def download_application_logs_attributes(code_name, options)
|
178
|
+
attributes = get("/apps/#{code_name}/application_logs/download#{query(options)}")
|
179
|
+
headers = RestClient::Request.execute({
|
180
|
+
:method => :get,
|
181
|
+
:url => "#{attributes["url"]}/headers"
|
182
|
+
}.merge(http_basic_auth_options)).headers
|
183
|
+
|
184
|
+
attributes.merge("size" => headers[:content_lenght].to_i)
|
185
|
+
end
|
186
|
+
|
177
187
|
def database_backups(code_name)
|
178
188
|
get("/apps/#{code_name}/database_backups")
|
179
189
|
end
|
@@ -227,7 +237,7 @@ module Shelly
|
|
227
237
|
request(path, :delete, params)
|
228
238
|
end
|
229
239
|
|
230
|
-
def
|
240
|
+
def download_file(cloud, filename, url, progress_callback = nil)
|
231
241
|
File.open(filename, "wb") do |out|
|
232
242
|
process_response = lambda do |response|
|
233
243
|
response.read_body do |chunk|
|
@@ -237,7 +247,7 @@ module Shelly
|
|
237
247
|
end
|
238
248
|
|
239
249
|
options = {
|
240
|
-
:url =>
|
250
|
+
:url => url,
|
241
251
|
:method => :get,
|
242
252
|
:block_response => process_response,
|
243
253
|
:headers => {:accept => "application/x-gzip"}
|
data/lib/shelly/version.rb
CHANGED
data/spec/shelly/backup_spec.rb
CHANGED
@@ -5,6 +5,7 @@ describe Shelly::Backup do
|
|
5
5
|
before do
|
6
6
|
@client = mock
|
7
7
|
Shelly::Client.stub(:new).and_return(@client)
|
8
|
+
@client.stub(:download_backup_url).and_return("https://backups.example.com")
|
8
9
|
end
|
9
10
|
|
10
11
|
it "should assign attributes" do
|
@@ -20,7 +21,9 @@ describe Shelly::Backup do
|
|
20
21
|
describe "#download" do
|
21
22
|
it "should download given backup via API file with filename to which backup will be downloaded" do
|
22
23
|
callback = lambda {}
|
23
|
-
@client.should_receive(:
|
24
|
+
@client.should_receive(:download_backup_url).with("foo", "backup.tar.gz")
|
25
|
+
@client.should_receive(:download_file).with("foo", "backup.tar.gz",
|
26
|
+
"https://backups.example.com", callback)
|
24
27
|
backup = Shelly::Backup.new(attributes)
|
25
28
|
backup.download(callback)
|
26
29
|
end
|
@@ -68,10 +68,12 @@ describe Shelly::CLI::Backup do
|
|
68
68
|
|
69
69
|
describe "#get" do
|
70
70
|
before do
|
71
|
-
@client.stub(:
|
71
|
+
@client.stub(:download_file)
|
72
72
|
@bar = mock(:progress_callback => @callback)
|
73
73
|
Shelly::DownloadProgressBar.stub(:new).and_return(@bar)
|
74
74
|
@client.stub(:database_backup).and_return({"filename" => "better.tar.gz", "size" => 12345})
|
75
|
+
@client.stub(:download_backup_url).with("foo-staging", "better.tar.gz").
|
76
|
+
and_return("https://backups.example.com")
|
75
77
|
$stdout.stub(:puts)
|
76
78
|
end
|
77
79
|
|
@@ -80,33 +82,40 @@ describe Shelly::CLI::Backup do
|
|
80
82
|
end
|
81
83
|
|
82
84
|
it "should have a 'download' alias" do
|
83
|
-
@client.should_receive(:
|
85
|
+
@client.should_receive(:download_file).with("foo-staging", "better.tar.gz",
|
86
|
+
"https://backups.example.com",
|
87
|
+
@bar.progress_callback)
|
84
88
|
invoke(@backup, :download, "better.tar.gz")
|
85
89
|
end
|
86
90
|
|
87
91
|
# multiple_clouds is tested in main_spec.rb in describe "#start" block
|
88
92
|
it "should ensure multiple_clouds check" do
|
93
|
+
@client.should_receive(:download_backup_url).with("foo-staging", "better.tar.gz")
|
89
94
|
@client.should_receive(:database_backup).with("foo-staging", "last")
|
90
95
|
@backup.should_receive(:multiple_clouds).and_return(@app)
|
91
96
|
invoke(@backup, :get)
|
92
97
|
end
|
93
98
|
|
94
99
|
it "should fetch backup size and initialize download progress bar" do
|
95
|
-
@client.stub(:database_backup).and_return({"filename" => "
|
100
|
+
@client.stub(:database_backup).and_return({"filename" => "better.tar.gz", "size" => 333})
|
96
101
|
Shelly::DownloadProgressBar.should_receive(:new).with(333).and_return(@bar)
|
97
102
|
|
98
103
|
invoke(@backup, :get)
|
99
104
|
end
|
100
105
|
|
101
106
|
it "should fetch given backup file itself" do
|
102
|
-
@client.should_receive(:
|
107
|
+
@client.should_receive(:download_file).with("foo-staging", "better.tar.gz",
|
108
|
+
"https://backups.example.com",
|
109
|
+
@bar.progress_callback)
|
103
110
|
invoke(@backup, :get, "better.tar.gz")
|
104
111
|
end
|
105
112
|
|
106
113
|
it "should show info where file has been saved" do
|
107
114
|
$stdout.should_receive(:puts)
|
108
115
|
$stdout.should_receive(:puts).with(green "Backup file saved to better.tar.gz")
|
109
|
-
@client.should_receive(:
|
116
|
+
@client.should_receive(:download_file).with("foo-staging", "better.tar.gz",
|
117
|
+
"https://backups.example.com",
|
118
|
+
@bar.progress_callback)
|
110
119
|
invoke(@backup, :get, "last")
|
111
120
|
end
|
112
121
|
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "shelly/cli/logs"
|
3
|
+
require "shelly/download_progress_bar"
|
4
|
+
|
5
|
+
describe Shelly::CLI::Logs do
|
6
|
+
before do
|
7
|
+
@cli_logs = Shelly::CLI::Logs.new
|
8
|
+
Shelly::CLI::Logs.stub(:new).and_return(@cli_logs)
|
9
|
+
@client = mock
|
10
|
+
Shelly::Client.stub(:new).and_return(@client)
|
11
|
+
@client.stub(:token).and_return("abc")
|
12
|
+
FileUtils.mkdir_p("/projects/foo")
|
13
|
+
Dir.chdir("/projects/foo")
|
14
|
+
@app = Shelly::App.new("foo-production")
|
15
|
+
Shelly::App.stub(:new).and_return(@app)
|
16
|
+
File.open("Cloudfile", 'w') { |f| f.write("foo-production:\n") }
|
17
|
+
$stdout.stub(:puts)
|
18
|
+
$stdout.stub(:print)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#latest" do
|
22
|
+
before do
|
23
|
+
@sample_logs = {"entries" => [['app1', 'log1'], ['app1', 'log2']]}
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should ensure user has logged in" do
|
27
|
+
hooks(@cli_logs, :latest).should include(:logged_in?)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should ensure multiple_clouds check" do
|
31
|
+
@client.stub(:application_logs).and_return(@sample_logs)
|
32
|
+
@cli_logs.should_receive(:multiple_clouds).and_return(@app)
|
33
|
+
invoke(@cli_logs, :latest)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should exit if user requested too many log lines" do
|
37
|
+
exception = Shelly::Client::APIException.new({}, 416)
|
38
|
+
@client.stub(:application_logs).and_raise(exception)
|
39
|
+
$stdout.should_receive(:puts).
|
40
|
+
with(red "You have requested too many log messages. Try a lower number.")
|
41
|
+
lambda { invoke(@cli_logs, :latest) }.should raise_error(SystemExit)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should show logs for the cloud" do
|
45
|
+
@client.stub(:application_logs).and_return(@sample_logs)
|
46
|
+
$stdout.should_receive(:puts).with("app1 log1")
|
47
|
+
$stdout.should_receive(:puts).with("app1 log2")
|
48
|
+
invoke(@cli_logs, :latest)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should show requested amount of logs" do
|
52
|
+
@client.should_receive(:application_logs).
|
53
|
+
with("foo-production", {:limit => 2, :source => 'nginx'}).and_return(@sample_logs)
|
54
|
+
@cli_logs.options = {:limit => 2, :source => 'nginx'}
|
55
|
+
invoke(@cli_logs, :latest)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should show logs since 2013-05-07" do
|
59
|
+
@client.should_receive(:application_logs).
|
60
|
+
with("foo-production", {:from => '2013-05-07', :source => 'nginx', :limit => 2}).
|
61
|
+
and_return(@sample_logs)
|
62
|
+
@cli_logs.options = {:from => '2013-05-07', :source => 'nginx', :limit => 2}
|
63
|
+
invoke(@cli_logs, :latest)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#get" do
|
68
|
+
before do
|
69
|
+
@bar = mock(:progress_callback => @callback)
|
70
|
+
Shelly::DownloadProgressBar.stub(:new).and_return(@bar)
|
71
|
+
@client.stub(:download_application_logs_attributes).
|
72
|
+
with("foo-production", {:date => "2013-05-31"}).
|
73
|
+
and_return({"filename" => "foo-production.log.20130531.gz",
|
74
|
+
"url" => "http://example.com/foo-production/20130531",
|
75
|
+
"size" => 12345})
|
76
|
+
$stdout.stub(:puts)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should ensure user has logged in" do
|
80
|
+
hooks(@cli_logs, :get).should include(:logged_in?)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should ensure multiple_clouds check" do
|
84
|
+
@client.stub(:download_file).
|
85
|
+
with("foo-production", "foo-production.log.20130531.gz",
|
86
|
+
"http://example.com/foo-production/20130531", @callback)
|
87
|
+
@cli_logs.should_receive(:multiple_clouds).and_return(@app)
|
88
|
+
invoke(@cli_logs, :get, "2013-05-31")
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should have a 'download' alias" do
|
92
|
+
@client.should_receive(:download_file).
|
93
|
+
with("foo-production", "foo-production.log.20130531.gz",
|
94
|
+
"http://example.com/foo-production/20130531", @callback)
|
95
|
+
invoke(@cli_logs, :download, "2013-05-31")
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
it "should fetch filename, url and size and initialize download progress bar" do
|
100
|
+
@client.should_receive(:download_file).
|
101
|
+
with("foo-production", "foo-production.log.20130531.gz",
|
102
|
+
"http://example.com/foo-production/20130531", @callback)
|
103
|
+
Shelly::DownloadProgressBar.should_receive(:new).with(12345).and_return(@bar)
|
104
|
+
invoke(@cli_logs, :get, "2013-05-31")
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should fetch given log file itself" do
|
108
|
+
@client.should_receive(:download_file).
|
109
|
+
with("foo-production", "foo-production.log.20130531.gz",
|
110
|
+
"http://example.com/foo-production/20130531",
|
111
|
+
@callback)
|
112
|
+
invoke(@cli_logs, :get, "2013-05-31")
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should show info where file has been saved" do
|
116
|
+
$stdout.should_receive(:puts)
|
117
|
+
$stdout.should_receive(:puts).with(green "Log file saved to foo-production.log.20130531.gz")
|
118
|
+
@client.should_receive(:download_file).
|
119
|
+
with("foo-production", "foo-production.log.20130531.gz",
|
120
|
+
"http://example.com/foo-production/20130531",
|
121
|
+
@callback)
|
122
|
+
invoke(@cli_logs, :get, "2013-05-31")
|
123
|
+
end
|
124
|
+
|
125
|
+
context "on log file not found" do
|
126
|
+
it "should display error message" do
|
127
|
+
exception = RestClient::ResourceNotFound.new
|
128
|
+
@client.stub(:download_file).and_raise(exception)
|
129
|
+
$stdout.should_receive(:puts).with(red "Log file not found")
|
130
|
+
invoke(@cli_logs, :get, "2013-05-31")
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context "on invalid date format" do
|
135
|
+
it "should display error message" do
|
136
|
+
exception = Shelly::Client::ValidationException.new({
|
137
|
+
"errors" => [["Date", "format is invalid"]]})
|
138
|
+
@client.stub(:download_file).and_raise(exception)
|
139
|
+
$stdout.should_receive(:puts).with(red "Date format is invalid")
|
140
|
+
invoke(@cli_logs, :get, "2013-05-31")
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -41,7 +41,7 @@ describe Shelly::CLI::Main do
|
|
41
41
|
out.should include("shelly list # List available clouds")
|
42
42
|
out.should include("shelly login [EMAIL] # Log into Shelly Cloud")
|
43
43
|
out.should include("shelly logout # Logout from Shelly Cloud")
|
44
|
-
out.should include("shelly logs
|
44
|
+
out.should include("shelly logs <command> # View application logs")
|
45
45
|
out.should include("shelly open # Open application page in browser")
|
46
46
|
out.should include("shelly organization <command> # View organizations")
|
47
47
|
out.should include("shelly rake TASK # Run rake task")
|
@@ -56,16 +56,6 @@ describe Shelly::CLI::Main do
|
|
56
56
|
out.should include("-h, [--help] # Describe available tasks or one specific task")
|
57
57
|
end
|
58
58
|
|
59
|
-
it "should display options in help for logs" do
|
60
|
-
out = IO.popen("bin/shelly help logs").read.strip
|
61
|
-
out.should include("-c, [--cloud=CLOUD] # Specify cloud")
|
62
|
-
out.should include("-n, [--limit=N] # Amount of messages to show")
|
63
|
-
out.should include("-s, [--source=SOURCE] # Limit logs to a single source, e.g. nginx")
|
64
|
-
out.should include("-f, [--tail] # Show new logs automatically")
|
65
|
-
out.should include("[--from=FROM] # Time from which to find the logs")
|
66
|
-
out.should include("[--debug] # Show debug information")
|
67
|
-
end
|
68
|
-
|
69
59
|
it "should display help when user is not logged in" do
|
70
60
|
out = IO.popen("bin/shelly list --help").read.strip
|
71
61
|
out.should include("Usage:")
|
@@ -1250,46 +1240,6 @@ Wait until cloud is in 'turned off' state and try again.")
|
|
1250
1240
|
end
|
1251
1241
|
end
|
1252
1242
|
|
1253
|
-
describe "#logs" do
|
1254
|
-
before do
|
1255
|
-
setup_project
|
1256
|
-
@sample_logs = {"entries" => [['app1', 'log1'], ['app1', 'log2']]}
|
1257
|
-
end
|
1258
|
-
|
1259
|
-
it "should ensure user has logged in" do
|
1260
|
-
hooks(@main, :logs).should include(:logged_in?)
|
1261
|
-
end
|
1262
|
-
|
1263
|
-
# multiple_clouds is tested in main_spec.rb in describe "#start" block
|
1264
|
-
it "should ensure multiple_clouds check" do
|
1265
|
-
@client.stub(:application_logs).and_return(@sample_logs)
|
1266
|
-
@main.should_receive(:multiple_clouds).and_return(@app)
|
1267
|
-
invoke(@main, :logs)
|
1268
|
-
end
|
1269
|
-
|
1270
|
-
it "should exit if user requested too many log lines" do
|
1271
|
-
exception = Shelly::Client::APIException.new({}, 416)
|
1272
|
-
@client.stub(:application_logs).and_raise(exception)
|
1273
|
-
$stdout.should_receive(:puts).
|
1274
|
-
with(red "You have requested too many log messages. Try a lower number.")
|
1275
|
-
lambda { invoke(@main, :logs) }.should raise_error(SystemExit)
|
1276
|
-
end
|
1277
|
-
|
1278
|
-
it "should show logs for the cloud" do
|
1279
|
-
@client.stub(:application_logs).and_return(@sample_logs)
|
1280
|
-
$stdout.should_receive(:puts).with("app1 log1")
|
1281
|
-
$stdout.should_receive(:puts).with("app1 log2")
|
1282
|
-
invoke(@main, :logs)
|
1283
|
-
end
|
1284
|
-
|
1285
|
-
it "should show requested amount of logs" do
|
1286
|
-
@client.should_receive(:application_logs).
|
1287
|
-
with("foo-production", {:limit => 2, :source => 'nginx'}).and_return(@sample_logs)
|
1288
|
-
@main.options = {:limit => 2, :source => 'nginx'}
|
1289
|
-
invoke(@main, :logs)
|
1290
|
-
end
|
1291
|
-
end
|
1292
|
-
|
1293
1243
|
describe "#rake" do
|
1294
1244
|
before do
|
1295
1245
|
setup_project
|
data/spec/shelly/client_spec.rb
CHANGED
@@ -332,24 +332,18 @@ describe Shelly::Client do
|
|
332
332
|
end
|
333
333
|
end
|
334
334
|
|
335
|
-
describe "#
|
335
|
+
describe "#download_file" do
|
336
336
|
before do
|
337
337
|
@filename = "2011.11.26.04.00.10.foo.postgres.tar.gz"
|
338
|
-
@
|
338
|
+
@url = "https://bob%40example.com:secret@backup.example.com/file.gz"
|
339
339
|
response = Net::HTTPResponse.new('', '', '')
|
340
340
|
# Streaming
|
341
341
|
response.stub(:read_body).and_yield("aaa").and_yield("bbbbb").and_yield("dddf")
|
342
|
-
FakeWeb.register_uri(:get,
|
343
|
-
", :response => response)
|
342
|
+
FakeWeb.register_uri(:get, @url, :response => response)
|
344
343
|
end
|
345
344
|
|
346
|
-
it "should
|
347
|
-
@client.
|
348
|
-
@client.download_backup("foo", @filename)
|
349
|
-
end
|
350
|
-
|
351
|
-
it "should write streamed database backup to file" do
|
352
|
-
@client.download_backup("foo", @filename)
|
345
|
+
it "should write streamed data to file" do
|
346
|
+
@client.download_file("foo", @filename, @url)
|
353
347
|
File.read(@filename).should == %w(aaa bbbbb dddf).join
|
354
348
|
end
|
355
349
|
|
@@ -361,7 +355,7 @@ describe Shelly::Client do
|
|
361
355
|
|
362
356
|
callback = lambda { |size| progress.update(size) }
|
363
357
|
|
364
|
-
@client.
|
358
|
+
@client.download_file("foo", @filename, @url, callback)
|
365
359
|
end
|
366
360
|
end
|
367
361
|
|
metadata
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shelly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.27
|
4
5
|
prerelease:
|
5
|
-
version: 0.2.26
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Shelly Cloud team
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
type: :development
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
18
|
requirements:
|
20
19
|
- - ~>
|
21
20
|
- !ruby/object:Gem::Version
|
22
21
|
version: 2.11.0
|
22
|
+
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
@@ -29,13 +29,13 @@ dependencies:
|
|
29
29
|
version: 2.11.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rake
|
32
|
-
type: :development
|
33
32
|
requirement: !ruby/object:Gem::Requirement
|
34
33
|
none: false
|
35
34
|
requirements:
|
36
35
|
- - ! '>='
|
37
36
|
- !ruby/object:Gem::Version
|
38
37
|
version: '0'
|
38
|
+
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
@@ -45,13 +45,13 @@ dependencies:
|
|
45
45
|
version: '0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: guard
|
48
|
-
type: :development
|
49
48
|
requirement: !ruby/object:Gem::Requirement
|
50
49
|
none: false
|
51
50
|
requirements:
|
52
51
|
- - ! '>='
|
53
52
|
- !ruby/object:Gem::Version
|
54
53
|
version: '0'
|
54
|
+
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
@@ -61,13 +61,13 @@ dependencies:
|
|
61
61
|
version: '0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: guard-rspec
|
64
|
-
type: :development
|
65
64
|
requirement: !ruby/object:Gem::Requirement
|
66
65
|
none: false
|
67
66
|
requirements:
|
68
67
|
- - ! '>='
|
69
68
|
- !ruby/object:Gem::Version
|
70
69
|
version: '0'
|
70
|
+
type: :development
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
@@ -77,45 +77,13 @@ dependencies:
|
|
77
77
|
version: '0'
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: simplecov
|
80
|
-
type: :development
|
81
80
|
requirement: !ruby/object:Gem::Requirement
|
82
81
|
none: false
|
83
82
|
requirements:
|
84
83
|
- - ! '>='
|
85
84
|
- !ruby/object:Gem::Version
|
86
85
|
version: '0'
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: ruby_gntp
|
96
86
|
type: :development
|
97
|
-
requirement: !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
|
-
requirements:
|
100
|
-
- - ! '>='
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '0'
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: rb-fsevent
|
112
|
-
type: :development
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
none: false
|
115
|
-
requirements:
|
116
|
-
- - ! '>='
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
version: '0'
|
119
87
|
prerelease: false
|
120
88
|
version_requirements: !ruby/object:Gem::Requirement
|
121
89
|
none: false
|
@@ -125,13 +93,13 @@ dependencies:
|
|
125
93
|
version: '0'
|
126
94
|
- !ruby/object:Gem::Dependency
|
127
95
|
name: fakefs
|
128
|
-
type: :development
|
129
96
|
requirement: !ruby/object:Gem::Requirement
|
130
97
|
none: false
|
131
98
|
requirements:
|
132
99
|
- - ! '>='
|
133
100
|
- !ruby/object:Gem::Version
|
134
101
|
version: '0'
|
102
|
+
type: :development
|
135
103
|
prerelease: false
|
136
104
|
version_requirements: !ruby/object:Gem::Requirement
|
137
105
|
none: false
|
@@ -141,13 +109,13 @@ dependencies:
|
|
141
109
|
version: '0'
|
142
110
|
- !ruby/object:Gem::Dependency
|
143
111
|
name: fakeweb
|
144
|
-
type: :development
|
145
112
|
requirement: !ruby/object:Gem::Requirement
|
146
113
|
none: false
|
147
114
|
requirements:
|
148
115
|
- - ! '>='
|
149
116
|
- !ruby/object:Gem::Version
|
150
117
|
version: '0'
|
118
|
+
type: :development
|
151
119
|
prerelease: false
|
152
120
|
version_requirements: !ruby/object:Gem::Requirement
|
153
121
|
none: false
|
@@ -157,13 +125,13 @@ dependencies:
|
|
157
125
|
version: '0'
|
158
126
|
- !ruby/object:Gem::Dependency
|
159
127
|
name: wijet-thor
|
160
|
-
type: :runtime
|
161
128
|
requirement: !ruby/object:Gem::Requirement
|
162
129
|
none: false
|
163
130
|
requirements:
|
164
131
|
- - ~>
|
165
132
|
- !ruby/object:Gem::Version
|
166
133
|
version: 0.14.9
|
134
|
+
type: :runtime
|
167
135
|
prerelease: false
|
168
136
|
version_requirements: !ruby/object:Gem::Requirement
|
169
137
|
none: false
|
@@ -173,13 +141,13 @@ dependencies:
|
|
173
141
|
version: 0.14.9
|
174
142
|
- !ruby/object:Gem::Dependency
|
175
143
|
name: rest-client
|
176
|
-
type: :runtime
|
177
144
|
requirement: !ruby/object:Gem::Requirement
|
178
145
|
none: false
|
179
146
|
requirements:
|
180
147
|
- - ! '>='
|
181
148
|
- !ruby/object:Gem::Version
|
182
149
|
version: '0'
|
150
|
+
type: :runtime
|
183
151
|
prerelease: false
|
184
152
|
version_requirements: !ruby/object:Gem::Requirement
|
185
153
|
none: false
|
@@ -189,13 +157,13 @@ dependencies:
|
|
189
157
|
version: '0'
|
190
158
|
- !ruby/object:Gem::Dependency
|
191
159
|
name: json
|
192
|
-
type: :runtime
|
193
160
|
requirement: !ruby/object:Gem::Requirement
|
194
161
|
none: false
|
195
162
|
requirements:
|
196
163
|
- - ! '>='
|
197
164
|
- !ruby/object:Gem::Version
|
198
165
|
version: '0'
|
166
|
+
type: :runtime
|
199
167
|
prerelease: false
|
200
168
|
version_requirements: !ruby/object:Gem::Requirement
|
201
169
|
none: false
|
@@ -205,13 +173,13 @@ dependencies:
|
|
205
173
|
version: '0'
|
206
174
|
- !ruby/object:Gem::Dependency
|
207
175
|
name: progressbar
|
208
|
-
type: :runtime
|
209
176
|
requirement: !ruby/object:Gem::Requirement
|
210
177
|
none: false
|
211
178
|
requirements:
|
212
179
|
- - ! '>='
|
213
180
|
- !ruby/object:Gem::Version
|
214
181
|
version: '0'
|
182
|
+
type: :runtime
|
215
183
|
prerelease: false
|
216
184
|
version_requirements: !ruby/object:Gem::Requirement
|
217
185
|
none: false
|
@@ -221,13 +189,13 @@ dependencies:
|
|
221
189
|
version: '0'
|
222
190
|
- !ruby/object:Gem::Dependency
|
223
191
|
name: launchy
|
224
|
-
type: :runtime
|
225
192
|
requirement: !ruby/object:Gem::Requirement
|
226
193
|
none: false
|
227
194
|
requirements:
|
228
195
|
- - ! '>='
|
229
196
|
- !ruby/object:Gem::Version
|
230
197
|
version: '0'
|
198
|
+
type: :runtime
|
231
199
|
prerelease: false
|
232
200
|
version_requirements: !ruby/object:Gem::Requirement
|
233
201
|
none: false
|
@@ -262,6 +230,7 @@ files:
|
|
262
230
|
- lib/shelly/cli/config.rb
|
263
231
|
- lib/shelly/cli/deploy.rb
|
264
232
|
- lib/shelly/cli/file.rb
|
233
|
+
- lib/shelly/cli/logs.rb
|
265
234
|
- lib/shelly/cli/main.rb
|
266
235
|
- lib/shelly/cli/organization.rb
|
267
236
|
- lib/shelly/cli/runner.rb
|
@@ -290,6 +259,7 @@ files:
|
|
290
259
|
- spec/shelly/cli/config_spec.rb
|
291
260
|
- spec/shelly/cli/deploy_spec.rb
|
292
261
|
- spec/shelly/cli/file_spec.rb
|
262
|
+
- spec/shelly/cli/logs_spec.rb
|
293
263
|
- spec/shelly/cli/main_spec.rb
|
294
264
|
- spec/shelly/cli/organization_spec.rb
|
295
265
|
- spec/shelly/cli/runner_spec.rb
|
@@ -315,37 +285,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
315
285
|
- - ! '>='
|
316
286
|
- !ruby/object:Gem::Version
|
317
287
|
version: '0'
|
288
|
+
segments:
|
289
|
+
- 0
|
290
|
+
hash: -1915414309864831534
|
318
291
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
319
292
|
none: false
|
320
293
|
requirements:
|
321
294
|
- - ! '>='
|
322
295
|
- !ruby/object:Gem::Version
|
323
296
|
version: '0'
|
297
|
+
segments:
|
298
|
+
- 0
|
299
|
+
hash: -1915414309864831534
|
324
300
|
requirements: []
|
325
301
|
rubyforge_project: shelly
|
326
|
-
rubygems_version: 1.8.
|
302
|
+
rubygems_version: 1.8.25
|
327
303
|
signing_key:
|
328
304
|
specification_version: 3
|
329
305
|
summary: Shelly Cloud command line tool
|
330
|
-
test_files:
|
331
|
-
- spec/helpers.rb
|
332
|
-
- spec/input_faker.rb
|
333
|
-
- spec/shelly/app_spec.rb
|
334
|
-
- spec/shelly/backup_spec.rb
|
335
|
-
- spec/shelly/cli/backup_spec.rb
|
336
|
-
- spec/shelly/cli/config_spec.rb
|
337
|
-
- spec/shelly/cli/deploy_spec.rb
|
338
|
-
- spec/shelly/cli/file_spec.rb
|
339
|
-
- spec/shelly/cli/main_spec.rb
|
340
|
-
- spec/shelly/cli/organization_spec.rb
|
341
|
-
- spec/shelly/cli/runner_spec.rb
|
342
|
-
- spec/shelly/cli/user_spec.rb
|
343
|
-
- spec/shelly/client_spec.rb
|
344
|
-
- spec/shelly/cloudfile_spec.rb
|
345
|
-
- spec/shelly/download_progress_bar_spec.rb
|
346
|
-
- spec/shelly/model_spec.rb
|
347
|
-
- spec/shelly/organization_spec.rb
|
348
|
-
- spec/shelly/structure_validator_spec.rb
|
349
|
-
- spec/shelly/user_spec.rb
|
350
|
-
- spec/spec_helper.rb
|
351
|
-
- spec/thor/options_spec.rb
|
306
|
+
test_files: []
|