u-case 4.2.1 → 4.2.2
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.
- checksums.yaml +4 -4
- data/.travis.sh +13 -11
- data/README.md +2 -2
- data/README.pt-BR.md +4 -6
- data/lib/micro/case.rb +5 -1
- data/lib/micro/case/result/wrapper.rb +20 -15
- data/lib/micro/case/version.rb +1 -1
- data/lib/micro/cases/flow.rb +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 472d6a0f07c2e365dcd4157440888be4a140fabd171c1f8bfdf1f30ffd4c109f
|
|
4
|
+
data.tar.gz: 3b255504d5c6c886bcc9aa167ce5ed57930002b92cb730410ec835a17840a15b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 99c0bd68b866a0a999f86dcd54a13587c05319c068635821e7fc0470f80b92608186d2bb7d263549e11f73951cff06e8f15c5f7586600b660abfb356ab3c5eaf
|
|
7
|
+
data.tar.gz: 2d22c278fc9f1f6e2f845d1477295314efa6b5fd627019d4e4f086ed1542d89d2c14c9df5b466babc4b1d0036c7aba8f0ea6a22163e5314dc1a4d7c3a0482465
|
data/.travis.sh
CHANGED
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
ruby_v=$(ruby -v)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
ACTIVERECORD_VERSION='3.2'
|
|
7
|
-
ACTIVERECORD_VERSION='3.2' ENABLE_TRANSITIONS='
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
ACTIVERECORD_VERSION='4.0'
|
|
11
|
-
ACTIVERECORD_VERSION='4.0' ENABLE_TRANSITIONS='
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
ACTIVERECORD_VERSION='4.1'
|
|
15
|
-
ACTIVERECORD_VERSION='4.1' ENABLE_TRANSITIONS='
|
|
5
|
+
if [[ $ruby_v =~ '2.2.' ]] || [[ $ruby_v =~ '2.3.' ]]; then
|
|
6
|
+
ACTIVERECORD_VERSION='3.2' bundle update
|
|
7
|
+
ACTIVERECORD_VERSION='3.2' ENABLE_TRANSITIONS='true' bundle exec rake test
|
|
8
|
+
ACTIVERECORD_VERSION='3.2' ENABLE_TRANSITIONS='false' bundle exec rake test
|
|
9
|
+
|
|
10
|
+
ACTIVERECORD_VERSION='4.0' bundle update
|
|
11
|
+
ACTIVERECORD_VERSION='4.0' ENABLE_TRANSITIONS='true' bundle exec rake test
|
|
12
|
+
ACTIVERECORD_VERSION='4.0' ENABLE_TRANSITIONS='false' bundle exec rake test
|
|
13
|
+
|
|
14
|
+
ACTIVERECORD_VERSION='4.1' bundle update
|
|
15
|
+
ACTIVERECORD_VERSION='4.1' ENABLE_TRANSITIONS='true' bundle exec rake test
|
|
16
|
+
ACTIVERECORD_VERSION='4.1' ENABLE_TRANSITIONS='false' bundle exec rake test
|
|
17
|
+
fi
|
|
16
18
|
|
|
17
19
|
ACTIVERECORD_VERSION='4.2' bundle update
|
|
18
20
|
ACTIVERECORD_VERSION='4.2' ENABLE_TRANSITIONS='true' bundle exec rake test
|
data/README.md
CHANGED
|
@@ -39,7 +39,7 @@ The main project goals are:
|
|
|
39
39
|
Version | Documentation
|
|
40
40
|
--------- | -------------
|
|
41
41
|
unreleased| https://github.com/serradura/u-case/blob/main/README.md
|
|
42
|
-
4.2.
|
|
42
|
+
4.2.2 | https://github.com/serradura/u-case/blob/v4.x/README.md
|
|
43
43
|
3.1.0 | https://github.com/serradura/u-case/blob/v3.x/README.md
|
|
44
44
|
2.6.0 | https://github.com/serradura/u-case/blob/v2.x/README.md
|
|
45
45
|
1.1.0 | https://github.com/serradura/u-case/blob/v1.x/README.md
|
|
@@ -102,7 +102,7 @@ unreleased| https://github.com/serradura/u-case/blob/main/README.md
|
|
|
102
102
|
| u-case | branch | ruby | activemodel | u-attributes |
|
|
103
103
|
| -------------- | ------- | -------- | ------------- | ------------ |
|
|
104
104
|
| unreleased | main | >= 2.2.0 | >= 3.2, < 6.1 | ~> 2.0 |
|
|
105
|
-
| 4.2.
|
|
105
|
+
| 4.2.2 | v4.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 2.0 |
|
|
106
106
|
| 3.1.0 | v3.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
|
|
107
107
|
| 2.6.0 | v2.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
|
|
108
108
|
| 1.1.0 | v1.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
|
data/README.pt-BR.md
CHANGED
|
@@ -39,7 +39,7 @@ Principais objetivos deste projeto:
|
|
|
39
39
|
Versão | Documentação
|
|
40
40
|
--------- | -------------
|
|
41
41
|
unreleased| https://github.com/serradura/u-case/blob/main/README.md
|
|
42
|
-
4.2.
|
|
42
|
+
4.2.2 | https://github.com/serradura/u-case/blob/v4.x/README.md
|
|
43
43
|
3.1.0 | https://github.com/serradura/u-case/blob/v3.x/README.md
|
|
44
44
|
2.6.0 | https://github.com/serradura/u-case/blob/v2.x/README.md
|
|
45
45
|
1.1.0 | https://github.com/serradura/u-case/blob/v1.x/README.md
|
|
@@ -70,9 +70,8 @@ unreleased| https://github.com/serradura/u-case/blob/main/README.md
|
|
|
70
70
|
- [É possível declarar um fluxo que inclui o próprio caso de uso?](#é-possível-declarar-um-fluxo-que-inclui-o-próprio-caso-de-uso)
|
|
71
71
|
- [`Micro::Case::Strict` - O que é um caso de uso estrito?](#microcasestrict---o-que-é-um-caso-de-uso-estrito)
|
|
72
72
|
- [`Micro::Case::Safe` - Existe algum recurso para lidar automaticamente com exceções dentro de um caso de uso ou fluxo?](#microcasesafe---existe-algum-recurso-para-lidar-automaticamente-com-exceções-dentro-de-um-caso-de-uso-ou-fluxo)
|
|
73
|
-
- [`Micro::Case::Result#on_exception`](#microcaseresulton_exception)
|
|
74
73
|
- [`Micro::Cases::Safe::Flow`](#microcasessafeflow)
|
|
75
|
-
- [`Micro::Case::Result#on_exception`](#microcaseresulton_exception
|
|
74
|
+
- [`Micro::Case::Result#on_exception`](#microcaseresulton_exception)
|
|
76
75
|
- [`u-case/with_activemodel_validation` - Como validar os atributos do caso de uso?](#u-casewith_activemodel_validation---como-validar-os-atributos-do-caso-de-uso)
|
|
77
76
|
- [Se eu habilitei a validação automática, é possível desabilitá-la apenas em casos de uso específicos?](#se-eu-habilitei-a-validação-automática-é-possível-desabilitá-la-apenas-em-casos-de-uso-específicos)
|
|
78
77
|
- [`Kind::Validator`](#kindvalidator)
|
|
@@ -100,7 +99,8 @@ unreleased| https://github.com/serradura/u-case/blob/main/README.md
|
|
|
100
99
|
|
|
101
100
|
| u-case | branch | ruby | activemodel | u-attributes |
|
|
102
101
|
| -------------- | ------- | -------- | ------------- | ------------ |
|
|
103
|
-
|
|
|
102
|
+
| unreleased | main | >= 2.2.0 | >= 3.2, < 6.1 | ~> 2.0 |
|
|
103
|
+
| 4.2.2 | v4.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 2.0 |
|
|
104
104
|
| 3.1.0 | v3.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
|
|
105
105
|
| 2.6.0 | v2.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
|
|
106
106
|
| 1.1.0 | v1.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
|
|
@@ -976,8 +976,6 @@ result.on_failure(:exception) do |result|
|
|
|
976
976
|
end
|
|
977
977
|
```
|
|
978
978
|
|
|
979
|
-
#### `Micro::Case::Result#on_exception`
|
|
980
|
-
|
|
981
979
|
Se você precisar lidar com um erro específico, recomendo o uso de uma instrução case. Exemplo:
|
|
982
980
|
|
|
983
981
|
```ruby
|
data/lib/micro/case.rb
CHANGED
|
@@ -4,38 +4,43 @@ module Micro
|
|
|
4
4
|
class Case
|
|
5
5
|
class Result
|
|
6
6
|
class Wrapper
|
|
7
|
-
|
|
8
|
-
@__is_unknown = true
|
|
7
|
+
attr_reader :output
|
|
9
8
|
|
|
9
|
+
def initialize(result)
|
|
10
10
|
@result = result
|
|
11
|
+
@output = ::Kind::Undefined
|
|
12
|
+
|
|
13
|
+
@__is_unknown = true
|
|
11
14
|
end
|
|
12
15
|
|
|
13
16
|
def failure(type = nil)
|
|
14
|
-
return if @result.success?
|
|
17
|
+
return if @result.success? || !undefined_output?
|
|
15
18
|
|
|
16
|
-
if result_type?(type)
|
|
17
|
-
@__is_unknown = false
|
|
18
|
-
|
|
19
|
-
yield(@result)
|
|
20
|
-
end
|
|
19
|
+
set_output(yield(@result)) if result_type?(type)
|
|
21
20
|
end
|
|
22
21
|
|
|
23
22
|
def success(type = nil)
|
|
24
|
-
return if @result.failure?
|
|
23
|
+
return if @result.failure? || !undefined_output?
|
|
25
24
|
|
|
26
|
-
if result_type?(type)
|
|
27
|
-
@__is_unknown = false
|
|
28
|
-
|
|
29
|
-
yield(@result)
|
|
30
|
-
end
|
|
25
|
+
set_output(yield(@result)) if result_type?(type)
|
|
31
26
|
end
|
|
32
27
|
|
|
33
28
|
def unknown
|
|
34
|
-
|
|
29
|
+
@output = yield(@result) if @__is_unknown && undefined_output?
|
|
35
30
|
end
|
|
36
31
|
|
|
37
32
|
private
|
|
38
33
|
|
|
34
|
+
def set_output(value)
|
|
35
|
+
@__is_unknown = false
|
|
36
|
+
|
|
37
|
+
@output = value
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def undefined_output?
|
|
41
|
+
::Kind::Undefined == @output
|
|
42
|
+
end
|
|
43
|
+
|
|
39
44
|
def result_type?(type)
|
|
40
45
|
type.nil? || @result.type == type
|
|
41
46
|
end
|
data/lib/micro/case/version.rb
CHANGED
data/lib/micro/cases/flow.rb
CHANGED
|
@@ -39,7 +39,11 @@ module Micro
|
|
|
39
39
|
|
|
40
40
|
return result unless block_given?
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
result_wrapper = ::Micro::Case::Result::Wrapper.new(result)
|
|
43
|
+
|
|
44
|
+
yield(result_wrapper)
|
|
45
|
+
|
|
46
|
+
result_wrapper.output
|
|
43
47
|
end
|
|
44
48
|
|
|
45
49
|
alias __call__ call
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: u-case
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.2.
|
|
4
|
+
version: 4.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rodrigo Serradura
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-12-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: kind
|