fear 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fear/failure.rb +8 -9
- data/lib/fear/version.rb +1 -1
- data/spec/fear/failure_spec.rb +5 -0
- 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: 79938c2515814ea5906a6ddba5c880b3ba7f8f57
|
4
|
+
data.tar.gz: 5393d7b3acf1714ccfa95db7dc2b3d947b49c7dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18f67b3306834c6d5fdbfc698eab233252855c3d0d0e1425f8eabe0e5489a25171c96584491f23d529b6d134cd829f6f4d6ffb0059d6a1f5a959772afecf90e5
|
7
|
+
data.tar.gz: 404f270b34607bd5ba35d1ced38c9a130a98c8aee0d0dd6d2e5a2118f434d3d00c24489e5b736851fc89fc91ecfff33cef9db31ad889db59443689c9e778746d
|
data/lib/fear/failure.rb
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
module Fear
|
2
2
|
class Failure
|
3
3
|
include Try
|
4
|
-
include Dry::Equalizer(:
|
4
|
+
include Dry::Equalizer(:exception)
|
5
5
|
include RightBiased::Left
|
6
6
|
|
7
7
|
# @param [StandardError]
|
8
8
|
def initialize(exception)
|
9
|
-
@
|
9
|
+
@exception = exception
|
10
10
|
end
|
11
11
|
|
12
|
-
attr_reader :
|
13
|
-
protected :value
|
12
|
+
attr_reader :exception
|
14
13
|
|
15
14
|
# @return [Boolean]
|
16
15
|
def success?
|
@@ -24,7 +23,7 @@ module Fear
|
|
24
23
|
|
25
24
|
# @raise
|
26
25
|
def get
|
27
|
-
fail
|
26
|
+
fail exception
|
28
27
|
end
|
29
28
|
|
30
29
|
# @return [Try] of calling block
|
@@ -48,7 +47,7 @@ module Fear
|
|
48
47
|
# @yieldreturn [Try]
|
49
48
|
# @return [Try]
|
50
49
|
def recover_with
|
51
|
-
yield(
|
50
|
+
yield(exception).tap do |result|
|
52
51
|
Utils.assert_type!(result, Success, Failure)
|
53
52
|
end
|
54
53
|
rescue => error
|
@@ -59,14 +58,14 @@ module Fear
|
|
59
58
|
# @yieldreturn [any]
|
60
59
|
# @return [Try]
|
61
60
|
def recover
|
62
|
-
Success.new(yield(
|
61
|
+
Success.new(yield(exception))
|
63
62
|
rescue => error
|
64
63
|
Failure.new(error)
|
65
64
|
end
|
66
65
|
|
67
66
|
# @return [Left]
|
68
67
|
def to_either
|
69
|
-
Left.new(
|
68
|
+
Left.new(exception)
|
70
69
|
end
|
71
70
|
|
72
71
|
# Used in case statement
|
@@ -74,7 +73,7 @@ module Fear
|
|
74
73
|
# @return [Boolean]
|
75
74
|
def ===(other)
|
76
75
|
if other.is_a?(Failure)
|
77
|
-
|
76
|
+
exception === other.exception
|
78
77
|
else
|
79
78
|
super
|
80
79
|
end
|
data/lib/fear/version.rb
CHANGED
data/spec/fear/failure_spec.rb
CHANGED
@@ -6,6 +6,11 @@ RSpec.describe Fear::Failure do
|
|
6
6
|
let(:left) { failure }
|
7
7
|
end
|
8
8
|
|
9
|
+
describe '#exception' do
|
10
|
+
subject { failure.exception }
|
11
|
+
it { is_expected.to eq(exception) }
|
12
|
+
end
|
13
|
+
|
9
14
|
describe '#success?' do
|
10
15
|
subject { failure }
|
11
16
|
it { is_expected.not_to be_success }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tema Bolshakov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-equalizer
|