shelly 0.2.3 → 0.2.4
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 +6 -0
- data/lib/shelly/cli/main.rb +9 -0
- data/lib/shelly/client.rb +10 -3
- data/lib/shelly/version.rb +1 -1
- data/spec/shelly/app_spec.rb +14 -0
- data/spec/shelly/cli/main_spec.rb +16 -2
- data/spec/shelly/client_spec.rb +17 -2
- metadata +5 -5
data/CHANGELOG.md
CHANGED
data/lib/shelly/app.rb
CHANGED
@@ -251,6 +251,12 @@ module Shelly
|
|
251
251
|
option?("whenever")
|
252
252
|
end
|
253
253
|
|
254
|
+
# Public: Sidekiq enabled?
|
255
|
+
# Returns true if sidekiq is present
|
256
|
+
def sidekiq?
|
257
|
+
option?("sidekiq")
|
258
|
+
end
|
259
|
+
|
254
260
|
# Public: Return databases to backup for given Cloud in Cloudfile
|
255
261
|
# Returns Array of databases, except redis db
|
256
262
|
def backup_databases
|
data/lib/shelly/cli/main.rb
CHANGED
@@ -301,6 +301,8 @@ Wait until cloud is in 'turned off' state and try again.}
|
|
301
301
|
else
|
302
302
|
say "Missing git remote"
|
303
303
|
end
|
304
|
+
rescue Client::ConflictException => e
|
305
|
+
say_error e[:message]
|
304
306
|
end
|
305
307
|
|
306
308
|
desc "logs", "Show latest application logs"
|
@@ -455,6 +457,13 @@ Wait until cloud is in 'turned off' state and try again.}
|
|
455
457
|
"Gem 'whenever' is missing in the Gemfile for '#{app}' cloud",
|
456
458
|
:show_fulfilled => verbose)
|
457
459
|
end
|
460
|
+
|
461
|
+
if app.sidekiq?
|
462
|
+
print_check(structure.gem?("sidekiq"),
|
463
|
+
"Gem 'sidekiq' is present for '#{app}' cloud",
|
464
|
+
"Gem 'sidekiq' is missing in the Gemfile for '#{app}' cloud",
|
465
|
+
:show_fulfilled => verbose)
|
466
|
+
end
|
458
467
|
end
|
459
468
|
end
|
460
469
|
|
data/lib/shelly/client.rb
CHANGED
@@ -188,6 +188,10 @@ module Shelly
|
|
188
188
|
post("/apps/#{code_name}/database_backups", :kind => kind)
|
189
189
|
end
|
190
190
|
|
191
|
+
def download_backup_url(code_name, filename)
|
192
|
+
get("/apps/#{code_name}/database_backups/#{filename}/download_url")["url"]
|
193
|
+
end
|
194
|
+
|
191
195
|
def members(name)
|
192
196
|
get("/organizations/#{name}/memberships")
|
193
197
|
end
|
@@ -226,9 +230,12 @@ module Shelly
|
|
226
230
|
end
|
227
231
|
end
|
228
232
|
|
229
|
-
options =
|
230
|
-
|
231
|
-
:
|
233
|
+
options = {
|
234
|
+
:url => download_backup_url(cloud, filename),
|
235
|
+
:method => :get,
|
236
|
+
:block_response => process_response,
|
237
|
+
:headers => {:accept => "application/x-gzip"}
|
238
|
+
}.merge(http_basic_auth_options)
|
232
239
|
|
233
240
|
RestClient::Request.execute(options)
|
234
241
|
end
|
data/lib/shelly/version.rb
CHANGED
data/spec/shelly/app_spec.rb
CHANGED
@@ -430,6 +430,20 @@ describe Shelly::App do
|
|
430
430
|
end
|
431
431
|
end
|
432
432
|
|
433
|
+
describe "#sidekiq?" do
|
434
|
+
it "should return true if present" do
|
435
|
+
content = {"servers" => {"app1" => {"sidekiq" => true}}}
|
436
|
+
@app.stub(:content).and_return(content)
|
437
|
+
@app.sidekiq?.should be_true
|
438
|
+
end
|
439
|
+
|
440
|
+
it "should return false if not present" do
|
441
|
+
content = {"servers" => {"app1" => {"size" => "small"}}}
|
442
|
+
@app.stub(:content).and_return(content)
|
443
|
+
@app.sidekiq?.should be_false
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
433
447
|
describe "#application_logs_tail" do
|
434
448
|
it "should execute given block for logs fetched from API" do
|
435
449
|
@client.should_receive(:application_logs_tail).with("foo-staging").and_yield("GET / 127.0.0.1")
|
@@ -1423,7 +1423,7 @@ Wait until cloud is in 'turned off' state and try again.")
|
|
1423
1423
|
before do
|
1424
1424
|
Shelly::App.stub(:inside_git_repository?).and_return(true)
|
1425
1425
|
Bundler::Definition.stub_chain(:build, :specs, :map) \
|
1426
|
-
.and_return(["thin", "pg", "delayed_job", "whenever"])
|
1426
|
+
.and_return(["thin", "pg", "delayed_job", "whenever", "sidekiq"])
|
1427
1427
|
Shelly::StructureValidator.any_instance.stub(:repo_paths) \
|
1428
1428
|
.and_return(["config.ru", "Gemfile", "Gemfile.lock"])
|
1429
1429
|
end
|
@@ -1495,7 +1495,8 @@ Wait until cloud is in 'turned off' state and try again.")
|
|
1495
1495
|
context "cloudfile" do
|
1496
1496
|
before do
|
1497
1497
|
cloud = mock(:code_name => "foo-staging", :cloud_databases => ["postgresql"],
|
1498
|
-
:whenever? => true, :delayed_job? => true, :
|
1498
|
+
:whenever? => true, :delayed_job? => true, :sidekiq? => true,
|
1499
|
+
:to_s => "foo-staging")
|
1499
1500
|
cloudfile = mock(:clouds => [cloud])
|
1500
1501
|
|
1501
1502
|
Shelly::Cloudfile.stub(:new).and_return(cloudfile)
|
@@ -1527,6 +1528,19 @@ Wait until cloud is in 'turned off' state and try again.")
|
|
1527
1528
|
end
|
1528
1529
|
end
|
1529
1530
|
|
1531
|
+
context "sidekiq is enabled" do
|
1532
|
+
it "should show that necessary gem doesn't exist" do
|
1533
|
+
Bundler::Definition.stub_chain(:build, :specs, :map).and_return([])
|
1534
|
+
$stdout.should_receive(:puts).with(" #{red("✗")} Gem 'sidekiq' is missing in the Gemfile for 'foo-staging' cloud")
|
1535
|
+
invoke(@main, :check)
|
1536
|
+
end
|
1537
|
+
|
1538
|
+
it "should show that necessary gem exists" do
|
1539
|
+
$stdout.should_receive(:puts).with(" #{green("✓")} Gem 'sidekiq' is present for 'foo-staging' cloud")
|
1540
|
+
invoke(@main, :check)
|
1541
|
+
end
|
1542
|
+
end
|
1543
|
+
|
1530
1544
|
context "postgresql is enabled" do
|
1531
1545
|
it "should show that necessary gem doesn't exist" do
|
1532
1546
|
Bundler::Definition.stub_chain(:build, :specs, :map).and_return([])
|
data/spec/shelly/client_spec.rb
CHANGED
@@ -321,14 +321,29 @@ describe Shelly::Client do
|
|
321
321
|
end
|
322
322
|
end
|
323
323
|
|
324
|
+
describe "#download_backup_url" do
|
325
|
+
it "should return download backup url" do
|
326
|
+
filename = "2011.11.26.04.00.10.foo.postgres.tar.gz"
|
327
|
+
url = api_url("apps/foo/database_backups/#{filename}/download_url")
|
328
|
+
FakeWeb.register_uri(:get, url, :body => {"url" => "https://backup.example.com/file.gz"}.to_json)
|
329
|
+
@client.download_backup_url("foo", filename).should == "https://backup.example.com/file.gz"
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
324
333
|
describe "#download_backup" do
|
325
334
|
before do
|
326
335
|
@filename = "2011.11.26.04.00.10.foo.postgres.tar.gz"
|
327
|
-
|
336
|
+
@client.stub(:download_backup_url => "https://backup.example.com/file.gz")
|
328
337
|
response = Net::HTTPResponse.new('', '', '')
|
329
338
|
# Streaming
|
330
339
|
response.stub(:read_body).and_yield("aaa").and_yield("bbbbb").and_yield("dddf")
|
331
|
-
FakeWeb.register_uri(:get,
|
340
|
+
FakeWeb.register_uri(:get, "https://bob%40example.com:secret@backup.example.com/file.gz
|
341
|
+
", :response => response)
|
342
|
+
end
|
343
|
+
|
344
|
+
it "should fetch from API backup url" do
|
345
|
+
@client.should_receive(:download_backup_url).with("foo", @filename)
|
346
|
+
@client.download_backup("foo", @filename)
|
332
347
|
end
|
333
348
|
|
334
349
|
it "should write streamed database backup to file" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shelly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
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-02-
|
12
|
+
date: 2013-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -317,7 +317,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
317
317
|
version: '0'
|
318
318
|
segments:
|
319
319
|
- 0
|
320
|
-
hash:
|
320
|
+
hash: 2571553387249649782
|
321
321
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
322
322
|
none: false
|
323
323
|
requirements:
|
@@ -326,10 +326,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
326
326
|
version: '0'
|
327
327
|
segments:
|
328
328
|
- 0
|
329
|
-
hash:
|
329
|
+
hash: 2571553387249649782
|
330
330
|
requirements: []
|
331
331
|
rubyforge_project: shelly
|
332
|
-
rubygems_version: 1.8.
|
332
|
+
rubygems_version: 1.8.24
|
333
333
|
signing_key:
|
334
334
|
specification_version: 3
|
335
335
|
summary: Shelly Cloud command line tool
|