shelly 0.1.36 → 0.1.37.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/shelly/app.rb +4 -0
- data/lib/shelly/cli/main.rb +2 -6
- data/lib/shelly/client.rb +11 -0
- data/lib/shelly/helpers.rb +1 -1
- data/lib/shelly/version.rb +1 -1
- data/spec/shelly/app_spec.rb +9 -0
- data/spec/shelly/cli/main_spec.rb +2 -2
- data/spec/shelly/client_spec.rb +21 -0
- metadata +5 -8
data/lib/shelly/app.rb
CHANGED
@@ -80,6 +80,10 @@ module Shelly
|
|
80
80
|
shelly.application_logs(code_name, options)
|
81
81
|
end
|
82
82
|
|
83
|
+
def application_logs_tail
|
84
|
+
shelly.application_logs_tail(code_name) { |l| yield(l) }
|
85
|
+
end
|
86
|
+
|
83
87
|
def database_backups
|
84
88
|
shelly.database_backups(code_name).map do |attributes|
|
85
89
|
Shelly::Backup.new(attributes.merge("code_name" => code_name))
|
data/lib/shelly/cli/main.rb
CHANGED
@@ -305,13 +305,9 @@ We have been notified about it. We will be adding new resources shortly}
|
|
305
305
|
print_logs(logs)
|
306
306
|
|
307
307
|
if options[:tail]
|
308
|
-
|
309
|
-
logs = app.application_logs(:from => logs['range']['last'],
|
310
|
-
:source => options[:source])
|
311
|
-
print_logs(logs)
|
312
|
-
sleep 0.5
|
313
|
-
end
|
308
|
+
app.application_logs_tail { |logs| print logs }
|
314
309
|
end
|
310
|
+
|
315
311
|
rescue Client::APIException => e
|
316
312
|
raise e unless e.status_code == 416
|
317
313
|
say_error "You have requested too many log messages. Try a lower number."
|
data/lib/shelly/client.rb
CHANGED
@@ -161,6 +161,17 @@ module Shelly
|
|
161
161
|
get("/apps/#{cloud}/application_logs#{query(options)}")
|
162
162
|
end
|
163
163
|
|
164
|
+
def application_logs_tail(cloud)
|
165
|
+
url = get("/apps/#{cloud}/application_logs/tail")["url"]
|
166
|
+
options = {
|
167
|
+
:url => url,
|
168
|
+
:method => :get,
|
169
|
+
:timeout => 60 * 60 * 24,
|
170
|
+
:block_response => Proc.new { |r| r.read_body { |c| yield(c) } }
|
171
|
+
}.merge(http_basic_auth_options)
|
172
|
+
RestClient::Request.execute(options)
|
173
|
+
end
|
174
|
+
|
164
175
|
def database_backups(code_name)
|
165
176
|
get("/apps/#{code_name}/database_backups")
|
166
177
|
end
|
data/lib/shelly/helpers.rb
CHANGED
data/lib/shelly/version.rb
CHANGED
data/spec/shelly/app_spec.rb
CHANGED
@@ -438,4 +438,13 @@ describe Shelly::App do
|
|
438
438
|
@app.whenever?.should be_false
|
439
439
|
end
|
440
440
|
end
|
441
|
+
|
442
|
+
describe "#application_logs_tail" do
|
443
|
+
it "should execute given block for logs fetched from API" do
|
444
|
+
@client.should_receive(:application_logs_tail).with("foo-staging").and_yield("GET / 127.0.0.1")
|
445
|
+
out = ""
|
446
|
+
@app.application_logs_tail { |logs| out << logs }
|
447
|
+
out.should == "GET / 127.0.0.1"
|
448
|
+
end
|
449
|
+
end
|
441
450
|
end
|
@@ -1193,8 +1193,8 @@ We have been notified about it. We will be adding new resources shortly")
|
|
1193
1193
|
|
1194
1194
|
it "should show logs for the cloud" do
|
1195
1195
|
@client.stub(:application_logs).and_return(@sample_logs)
|
1196
|
-
$stdout.should_receive(:puts).with("
|
1197
|
-
$stdout.should_receive(:puts).with("
|
1196
|
+
$stdout.should_receive(:puts).with("app1 log1")
|
1197
|
+
$stdout.should_receive(:puts).with("app1 log2")
|
1198
1198
|
invoke(@main, :logs)
|
1199
1199
|
end
|
1200
1200
|
|
data/spec/shelly/client_spec.rb
CHANGED
@@ -348,6 +348,27 @@ describe Shelly::Client do
|
|
348
348
|
end
|
349
349
|
end
|
350
350
|
|
351
|
+
describe "#application_logs_tail" do
|
352
|
+
before do
|
353
|
+
FakeWeb.register_uri(:get, api_url("apps/fooo/application_logs/tail"),
|
354
|
+
:body => {"url" => "http://logs.example.com/fooo"}.to_json)
|
355
|
+
end
|
356
|
+
|
357
|
+
it "should fetch tail url" do
|
358
|
+
FakeWeb.register_uri(:get, "http://bob%40example.com:secret@logs.example.com/fooo",
|
359
|
+
:body => {}.to_json)
|
360
|
+
@client.application_logs_tail("fooo") { }
|
361
|
+
end
|
362
|
+
|
363
|
+
it "should execute block for received data" do
|
364
|
+
FakeWeb.register_uri(:get, "http://bob%40example.com:secret@logs.example.com/fooo",
|
365
|
+
:body => "GET / 127.0.0.1")
|
366
|
+
out = ""
|
367
|
+
@client.application_logs_tail("fooo") { |logs| out << logs }
|
368
|
+
out.should == "GET / 127.0.0.1"
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
351
372
|
describe "#request_parameters" do
|
352
373
|
it "should return hash of resquest parameters" do
|
353
374
|
expected = {
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shelly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.37.pre
|
5
|
+
prerelease: 7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Shelly Cloud team
|
@@ -349,16 +349,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
349
349
|
version: '0'
|
350
350
|
segments:
|
351
351
|
- 0
|
352
|
-
hash:
|
352
|
+
hash: 4092670443477864760
|
353
353
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
354
354
|
none: false
|
355
355
|
requirements:
|
356
|
-
- - ! '
|
356
|
+
- - ! '>'
|
357
357
|
- !ruby/object:Gem::Version
|
358
|
-
version:
|
359
|
-
segments:
|
360
|
-
- 0
|
361
|
-
hash: -1906837567373860011
|
358
|
+
version: 1.3.1
|
362
359
|
requirements: []
|
363
360
|
rubyforge_project: shelly
|
364
361
|
rubygems_version: 1.8.24
|