corindon 0.5.0 → 0.6.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
  SHA256:
3
- metadata.gz: 37d5ac638b45a7b98ffa07c588b299147ae04ad8172eb9ac3d84f6b207242df7
4
- data.tar.gz: 867092edd58ca1209d5bdfd3fd27d97f7663e63813c6266937e55b4eaa26bc8f
3
+ metadata.gz: ae37025ed53b2bec8d329d9d640d40425406a0c6b2ba8fcf85ec573e5b0cdd6d
4
+ data.tar.gz: 3d6c2d3acac3f22c5c15b5128a3a7e005a4f1c6ea1508472d29bdcfb5eefc19c
5
5
  SHA512:
6
- metadata.gz: a18f25be1501b07dab913c482f1b84308d392355182f02bc724bfc7dece28227c9aac87c7ecf6fb2bca2934019188968f9b177832303c9e7f8716254409dc0a8
7
- data.tar.gz: ca432ab9e27df7b318052cc755d7b5f65b0b3e1bf42c6a1fae7043d27400b3108e148274ea0c862f64a5db6b3121cac3db449f9fb8cb8335aabeb4a536972151
6
+ metadata.gz: c2d44b60b7a78a391211c194a62b1cabf76664dc2a2f2ab268bc716873468c7e9245f2c6acd18c344596d16b48e3b16ce8f1de028e3a8f30de6adc042f7e8dc9
7
+ data.tar.gz: 704342b6b6afe491f9c21f9de07841356edc8c02e504ac66646d195fc88b34733f65dfa3a25a0b0f6ab40927429a11e2dec640c2cbf6a5861fc0a2926dca0b37
@@ -3,7 +3,7 @@
3
3
  module Corindon
4
4
  module DependencyInjection
5
5
  class Container
6
- using Ext::Something
6
+ using Something::Ext
7
7
 
8
8
  attr_reader :id_generator
9
9
  attr_reader :injector
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Corindon
4
+ module Result
5
+ module Errors
6
+ class BadReturnTypeError < ResultError
7
+ # @return [Object]
8
+ attr_reader :value
9
+
10
+ # @param [Object] value
11
+ def initialize(value)
12
+ super("Expected a Result, got #{value}")
13
+
14
+ @value = value
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Corindon
4
+ module Result
5
+ module Errors
6
+ class ResultError < StandardError
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Corindon
4
+ module Result
5
+ module Ext
6
+ refine Object do
7
+ def rescue_failure(&block)
8
+ block.call
9
+ rescue StandardError => error
10
+ Corindon::Result::Failure.new(error)
11
+ end
12
+
13
+ # rubocop:disable Naming/MethodName
14
+ def Failure(error)
15
+ Corindon::Result::Failure.new(error)
16
+ end
17
+
18
+ def Success(value)
19
+ Corindon::Result::Success.new(value)
20
+ end
21
+ # rubocop:enable Naming/MethodName
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Corindon
4
+ module Result
5
+ class Failure < Result
6
+ # @return [Exception]
7
+ attr_reader :error
8
+
9
+ # @param [Exception] error
10
+ def initialize(error)
11
+ super()
12
+
13
+ @error = error
14
+ end
15
+
16
+ # @return [Boolean]
17
+ def failure?
18
+ true
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Corindon
4
+ module Result
5
+ class Result
6
+ # @return [Boolean]
7
+ def success?
8
+ false
9
+ end
10
+
11
+ # @return [Boolean]
12
+ def failure?
13
+ false
14
+ end
15
+
16
+ # @yieldparam [Object] value
17
+ # @yieldreturn [Result]
18
+ # @return [Result]
19
+ def and_then(&_block)
20
+ self
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Corindon
4
+ module Result
5
+ class Success < Result
6
+ # @return [Object]
7
+ attr_reader :value
8
+
9
+ # @param [Object] value
10
+ def initialize(value)
11
+ super()
12
+
13
+ @value = value
14
+ end
15
+
16
+ # @return [Boolean]
17
+ def success?
18
+ true
19
+ end
20
+
21
+ def and_then(&block)
22
+ retval = block.call(value)
23
+
24
+ if retval.is_a?(Result)
25
+ retval
26
+ else
27
+ Failure.new(Errors::BadReturnTypeError.new(retval))
28
+ end
29
+ rescue StandardError => error
30
+ Failure.new(error)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Corindon
4
- module Ext
5
- module Something
4
+ module Something
5
+ module Ext
6
6
  refine Object do
7
7
  def sth?
8
8
  !nil?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Corindon
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corindon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rémi Piotaix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-07 00:00:00.000000000 Z
11
+ date: 2020-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semantic
@@ -106,7 +106,13 @@ files:
106
106
  - lib/corindon/dependency_injection/token/value_token.rb
107
107
  - lib/corindon/ext/guards.rb
108
108
  - lib/corindon/ext/guards/error.rb
109
- - lib/corindon/ext/something.rb
109
+ - lib/corindon/result/errors/bad_return_type_error.rb
110
+ - lib/corindon/result/errors/result_error.rb
111
+ - lib/corindon/result/ext.rb
112
+ - lib/corindon/result/failure.rb
113
+ - lib/corindon/result/result.rb
114
+ - lib/corindon/result/success.rb
115
+ - lib/corindon/something/ext.rb
110
116
  - lib/corindon/version.rb
111
117
  homepage: https://gitlab.com/piotaixr/corindon
112
118
  licenses: