litmus_paper 0.6.3 → 0.7.0
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.
@@ -0,0 +1,22 @@
|
|
1
|
+
module LitmusPaper
|
2
|
+
module Dependency
|
3
|
+
class Script
|
4
|
+
def initialize(command, options = {})
|
5
|
+
@command = command
|
6
|
+
@timeout = options.fetch(:timeout, 5)
|
7
|
+
end
|
8
|
+
|
9
|
+
def available?
|
10
|
+
Timeout.timeout(@timeout) do
|
11
|
+
system @command
|
12
|
+
end
|
13
|
+
rescue Timeout::Error
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
"Dependency::Script(#{@command})"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/litmus_paper/version.rb
CHANGED
data/lib/litmus_paper.rb
CHANGED
@@ -25,6 +25,7 @@ require 'litmus_paper/configuration'
|
|
25
25
|
require 'litmus_paper/configuration_file'
|
26
26
|
require 'litmus_paper/dependency/haproxy_backends'
|
27
27
|
require 'litmus_paper/dependency/http'
|
28
|
+
require 'litmus_paper/dependency/script'
|
28
29
|
require 'litmus_paper/dependency/tcp'
|
29
30
|
require 'litmus_paper/health'
|
30
31
|
require 'litmus_paper/forced_health'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LitmusPaper::Dependency::Script do
|
4
|
+
describe "#available?" do
|
5
|
+
it "is true when the script returns 0" do
|
6
|
+
check = LitmusPaper::Dependency::Script.new("true")
|
7
|
+
check.should be_available
|
8
|
+
end
|
9
|
+
|
10
|
+
it "is false when the script returns 1" do
|
11
|
+
check = LitmusPaper::Dependency::Script.new("false")
|
12
|
+
check.should_not be_available
|
13
|
+
end
|
14
|
+
|
15
|
+
it "is false when the script exceeds the timeout" do
|
16
|
+
check = LitmusPaper::Dependency::Script.new("sleep 10", :timeout => 1)
|
17
|
+
check.should_not be_available
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "to_s" do
|
22
|
+
it "returns the command" do
|
23
|
+
check = LitmusPaper::Dependency::Script.new("sleep 10")
|
24
|
+
check.to_s.should == "Dependency::Script(sleep 10)"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: litmus_paper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 7
|
9
|
+
- 0
|
10
|
+
version: 0.7.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Braintreeps
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-11-
|
18
|
+
date: 2012-11-19 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- lib/litmus_paper/configuration_file.rb
|
166
166
|
- lib/litmus_paper/dependency/haproxy_backends.rb
|
167
167
|
- lib/litmus_paper/dependency/http.rb
|
168
|
+
- lib/litmus_paper/dependency/script.rb
|
168
169
|
- lib/litmus_paper/dependency/tcp.rb
|
169
170
|
- lib/litmus_paper/forced_health.rb
|
170
171
|
- lib/litmus_paper/health.rb
|
@@ -182,6 +183,7 @@ files:
|
|
182
183
|
- spec/litmus_paper/configuration_file_spec.rb
|
183
184
|
- spec/litmus_paper/dependency/haproxy_backends_spec.rb
|
184
185
|
- spec/litmus_paper/dependency/http_spec.rb
|
186
|
+
- spec/litmus_paper/dependency/script_spec.rb
|
185
187
|
- spec/litmus_paper/dependency/tcp_spec.rb
|
186
188
|
- spec/litmus_paper/health_spec.rb
|
187
189
|
- spec/litmus_paper/metric/available_memory_spec.rb
|
@@ -247,6 +249,7 @@ test_files:
|
|
247
249
|
- spec/litmus_paper/configuration_file_spec.rb
|
248
250
|
- spec/litmus_paper/dependency/haproxy_backends_spec.rb
|
249
251
|
- spec/litmus_paper/dependency/http_spec.rb
|
252
|
+
- spec/litmus_paper/dependency/script_spec.rb
|
250
253
|
- spec/litmus_paper/dependency/tcp_spec.rb
|
251
254
|
- spec/litmus_paper/health_spec.rb
|
252
255
|
- spec/litmus_paper/metric/available_memory_spec.rb
|