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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe1da9cca954b338585a16edadec505294704e48
4
- data.tar.gz: d2b9f1d9d4a186b5d9aa622dd9509a1aacdf545f
3
+ metadata.gz: 79938c2515814ea5906a6ddba5c880b3ba7f8f57
4
+ data.tar.gz: 5393d7b3acf1714ccfa95db7dc2b3d947b49c7dc
5
5
  SHA512:
6
- metadata.gz: 5a65ed502c031f9f028d8bdc2b62b0c90c5d40aaf0efb6eb56755251fd967b11c3d9955d0c5473bf4a8b9c252dfd8f0141adc4c0bc09fa0cbb89ba65d99a4200
7
- data.tar.gz: 5ee2ea5cc16bd2ef862a9eb2a25303c09bcaa125ba6fcbac2a8ac50859551ee1d13dd87bd57923865c3951c97c824f18b9c3111d9b923cc568eb848016e98389
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(:value)
4
+ include Dry::Equalizer(:exception)
5
5
  include RightBiased::Left
6
6
 
7
7
  # @param [StandardError]
8
8
  def initialize(exception)
9
- @value = exception
9
+ @exception = exception
10
10
  end
11
11
 
12
- attr_reader :value
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 value
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(value).tap do |result|
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(value))
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(value)
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
- value === other.value
76
+ exception === other.exception
78
77
  else
79
78
  super
80
79
  end
data/lib/fear/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fear
2
- VERSION = '0.4.2'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
@@ -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.2
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-21 00:00:00.000000000 Z
11
+ date: 2016-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-equalizer