redness 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redness/red.rb +8 -1
- data/lib/redness/version.rb +1 -1
- data/spec/redness/red_spec.rb +26 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4c9bff0bf476a0549dc3d83b9b46b399e6fe511
|
4
|
+
data.tar.gz: 217db2555acf708704f24c774cf580fe046da454
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbf8e0434cb489adce9914bef551528fb734a9a808c97cc8ecc29a2d7574e4fc230b3871f40d53ab27cd30878cfb11663423db468cf9dbc71c27af59fce3251a
|
7
|
+
data.tar.gz: 4918ea9cbae280334c6cc62d3681a4d3bc99af8f11a251b276c3989ad22ae76f15abda2d2d84bbc95664b47619dfd20194e59a8f4605dd72c8c3a8ddefdc3c9d
|
data/lib/redness/red.rb
CHANGED
@@ -3,6 +3,13 @@ require 'timeout'
|
|
3
3
|
class Red
|
4
4
|
class RedisUnavailable < StandardError; end
|
5
5
|
|
6
|
+
REDIS_ERRORS = [
|
7
|
+
RedisUnavailable,
|
8
|
+
Redis::CannotConnectError,
|
9
|
+
Redis::ConnectionError,
|
10
|
+
Redis::TimeoutError
|
11
|
+
]
|
12
|
+
|
6
13
|
class << self
|
7
14
|
attr_accessor :redis
|
8
15
|
end
|
@@ -21,7 +28,7 @@ class Red
|
|
21
28
|
|
22
29
|
def execute_with_uncertainty(fail_return = [])
|
23
30
|
yield
|
24
|
-
rescue
|
31
|
+
rescue *REDIS_ERRORS
|
25
32
|
fail_return
|
26
33
|
end
|
27
34
|
|
data/lib/redness/version.rb
CHANGED
data/spec/redness/red_spec.rb
CHANGED
@@ -2,16 +2,36 @@ require_relative '../spec_integration_helper'
|
|
2
2
|
|
3
3
|
describe Red do
|
4
4
|
describe "#execute_with_uncertainty" do
|
5
|
-
|
6
|
-
|
5
|
+
context "when the block raises Red::RedisUnavailable" do
|
6
|
+
it "returns the given value" do
|
7
|
+
Red.new.execute_with_uncertainty(:boom) do
|
8
|
+
raise Red::RedisUnavailable
|
9
|
+
end.should == :boom
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when the block raises Redis::CannotConnectError" do
|
14
|
+
it "returns the given value" do
|
15
|
+
Red.new.execute_with_uncertainty(:boom) do
|
16
|
+
raise Redis::CannotConnectError
|
17
|
+
end.should == :boom
|
18
|
+
end
|
7
19
|
end
|
8
20
|
|
9
|
-
|
10
|
-
|
21
|
+
context "when the block raises a Redis::ConnectionError" do
|
22
|
+
it "returns the given value" do
|
23
|
+
Red.new.execute_with_uncertainty(:boom) do
|
24
|
+
raise Redis::ConnectionError
|
25
|
+
end.should == :boom
|
26
|
+
end
|
11
27
|
end
|
12
28
|
|
13
|
-
|
14
|
-
|
29
|
+
context "when the block raises Redis::TimeoutError" do
|
30
|
+
it "returns the given value" do
|
31
|
+
Red.new.execute_with_uncertainty(:boom) do
|
32
|
+
raise Redis::TimeoutError
|
33
|
+
end.should == :boom
|
34
|
+
end
|
15
35
|
end
|
16
36
|
end
|
17
37
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Baldur Gudbjornsson
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date:
|
17
|
+
date: 2016-02-26 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: json
|