u-case 4.0.0 → 4.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.sh +32 -10
- data/Gemfile +20 -9
- data/README.md +103 -99
- data/README.pt-BR.md +106 -105
- data/lib/micro/case.rb +70 -14
- data/lib/micro/case/result.rb +36 -6
- data/lib/micro/case/result/transitions.rb +0 -1
- data/lib/micro/case/result/wrapper.rb +50 -0
- data/lib/micro/case/safe.rb +1 -1
- data/lib/micro/case/utils.rb +19 -10
- data/lib/micro/case/version.rb +1 -1
- data/lib/micro/cases.rb +7 -0
- data/lib/micro/cases/error.rb +13 -0
- data/lib/micro/cases/flow.rb +27 -14
- data/lib/micro/cases/map.rb +39 -0
- data/lib/micro/cases/safe/flow.rb +2 -2
- data/lib/micro/cases/utils.rb +21 -0
- metadata +6 -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,22 +2,44 @@
|
|
2
2
|
|
3
3
|
ruby_v=$(ruby -v)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
18
|
+
|
19
|
+
ACTIVERECORD_VERSION='4.2' bundle update
|
20
|
+
ACTIVERECORD_VERSION='4.2' ENABLE_TRANSITIONS='true' bundle exec rake test
|
21
|
+
ACTIVERECORD_VERSION='4.2' ENABLE_TRANSITIONS='false' bundle exec rake test
|
22
|
+
|
23
|
+
ACTIVERECORD_VERSION='5.0' bundle update
|
24
|
+
ACTIVERECORD_VERSION='5.0' ENABLE_TRANSITIONS='true' bundle exec rake test
|
25
|
+
ACTIVERECORD_VERSION='5.0' ENABLE_TRANSITIONS='false' bundle exec rake test
|
26
|
+
|
27
|
+
ACTIVERECORD_VERSION='5.1' bundle update
|
28
|
+
ACTIVERECORD_VERSION='5.1' ENABLE_TRANSITIONS='true' bundle exec rake test
|
29
|
+
ACTIVERECORD_VERSION='5.1' ENABLE_TRANSITIONS='false' bundle exec rake test
|
8
30
|
|
9
31
|
if [[ ! $ruby_v =~ '2.2.0' ]]; then
|
10
|
-
|
11
|
-
|
12
|
-
|
32
|
+
ACTIVERECORD_VERSION='5.2' bundle update
|
33
|
+
ACTIVERECORD_VERSION='5.2' ENABLE_TRANSITIONS='true' bundle exec rake test
|
34
|
+
ACTIVERECORD_VERSION='5.2' ENABLE_TRANSITIONS='false' bundle exec rake test
|
13
35
|
fi
|
14
36
|
|
15
37
|
if [[ $ruby_v =~ '2.5.' ]] || [[ $ruby_v =~ '2.6.' ]] || [[ $ruby_v =~ '2.7.' ]]; then
|
16
|
-
|
17
|
-
|
18
|
-
|
38
|
+
ACTIVERECORD_VERSION='6.0' bundle update
|
39
|
+
ACTIVERECORD_VERSION='6.0' ENABLE_TRANSITIONS='true' bundle exec rake test
|
40
|
+
ACTIVERECORD_VERSION='6.0' ENABLE_TRANSITIONS='false' bundle exec rake test
|
19
41
|
fi
|
20
42
|
|
21
43
|
bundle update
|
22
|
-
ENABLE_TRANSITIONS='false' bundle exec rake test
|
23
44
|
ENABLE_TRANSITIONS='true' bundle exec rake test
|
45
|
+
ENABLE_TRANSITIONS='false' bundle exec rake test
|
data/Gemfile
CHANGED
@@ -2,19 +2,19 @@ source "https://rubygems.org"
|
|
2
2
|
|
3
3
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
4
|
|
5
|
-
|
5
|
+
activerecord_version = ENV.fetch('ACTIVERECORD_VERSION', '6.1')
|
6
6
|
|
7
|
-
|
7
|
+
activerecord = case activerecord_version
|
8
8
|
when '3.2' then '3.2.22'
|
9
|
+
when '4.0' then '4.0.13'
|
10
|
+
when '4.1' then '4.1.16'
|
11
|
+
when '4.2' then '4.2.11'
|
12
|
+
when '5.0' then '5.0.7'
|
13
|
+
when '5.1' then '5.1.7'
|
9
14
|
when '5.2' then '5.2.3'
|
10
|
-
when '6.0' then '6.0.
|
15
|
+
when '6.0' then '6.0.3'
|
11
16
|
end
|
12
17
|
|
13
|
-
if activemodel_version < '6.1.0'
|
14
|
-
gem 'activemodel', activemodel, require: false
|
15
|
-
gem 'activesupport', activemodel, require: false
|
16
|
-
end
|
17
|
-
|
18
18
|
simplecov_version =
|
19
19
|
case RUBY_VERSION
|
20
20
|
when /\A2.[23]/ then '~> 0.17.1'
|
@@ -23,9 +23,20 @@ simplecov_version =
|
|
23
23
|
end
|
24
24
|
|
25
25
|
group :test do
|
26
|
-
gem 'minitest',
|
26
|
+
gem 'minitest', activerecord_version < '4.1' ? '~> 4.2' : '~> 5.0'
|
27
27
|
|
28
28
|
gem 'simplecov', simplecov_version, require: false
|
29
|
+
|
30
|
+
if activerecord
|
31
|
+
sqlite3 =
|
32
|
+
case activerecord
|
33
|
+
when /\A6\.0/, nil then '~> 1.4.0'
|
34
|
+
else '~> 1.3.0'
|
35
|
+
end
|
36
|
+
|
37
|
+
gem 'sqlite3', sqlite3
|
38
|
+
gem 'activerecord', activerecord, require: 'active_record'
|
39
|
+
end
|
29
40
|
end
|
30
41
|
|
31
42
|
pry_byebug_version =
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
</p>
|
7
7
|
|
8
8
|
<p align="center">
|
9
|
-
<img src="https://img.shields.io/badge/ruby
|
9
|
+
<img src="https://img.shields.io/badge/ruby->%3D%202.2.0-ruby.svg?colorA=99004d&colorB=cc0066" alt="Ruby">
|
10
10
|
|
11
11
|
<a href="https://rubygems.org/gems/u-case">
|
12
12
|
<img alt="Gem" src="https://img.shields.io/gem/v/u-case.svg?style=flat-square">
|
@@ -38,12 +38,13 @@ The main project goals are:
|
|
38
38
|
|
39
39
|
Version | Documentation
|
40
40
|
--------- | -------------
|
41
|
-
|
41
|
+
unreleased| https://github.com/serradura/u-case/blob/main/README.md
|
42
|
+
4.2.2 | https://github.com/serradura/u-case/blob/v4.x/README.md
|
42
43
|
3.1.0 | https://github.com/serradura/u-case/blob/v3.x/README.md
|
43
44
|
2.6.0 | https://github.com/serradura/u-case/blob/v2.x/README.md
|
44
45
|
1.1.0 | https://github.com/serradura/u-case/blob/v1.x/README.md
|
45
46
|
|
46
|
-
> **Note:** Você entende português?
|
47
|
+
> **Note:** Você entende português? 🇧🇷 🇵🇹 Verifique o [README traduzido em pt-BR](https://github.com/serradura/u-case/blob/main/README.pt-BR.md).
|
47
48
|
|
48
49
|
## Table of Contents <!-- omit in toc -->
|
49
50
|
- [Compatibility](#compatibility)
|
@@ -100,7 +101,8 @@ Version | Documentation
|
|
100
101
|
|
101
102
|
| u-case | branch | ruby | activemodel | u-attributes |
|
102
103
|
| -------------- | ------- | -------- | ------------- | ------------ |
|
103
|
-
|
|
104
|
+
| unreleased | main | >= 2.2.0 | >= 3.2, < 6.1 | ~> 2.0 |
|
105
|
+
| 4.2.2 | v4.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 2.0 |
|
104
106
|
| 3.1.0 | v3.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
|
105
107
|
| 2.6.0 | v2.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
|
106
108
|
| 1.1.0 | v1.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
|
@@ -124,7 +126,7 @@ Version | Documentation
|
|
124
126
|
Add this line to your application's Gemfile:
|
125
127
|
|
126
128
|
```ruby
|
127
|
-
gem 'u-case', '~>
|
129
|
+
gem 'u-case', '~> 4.1.0'
|
128
130
|
```
|
129
131
|
|
130
132
|
And then execute:
|
@@ -1198,42 +1200,44 @@ end
|
|
1198
1200
|
|
1199
1201
|
| Gem / Abstraction | Iterations per second | Comparison |
|
1200
1202
|
| ----------------- | --------------------: | ----------------: |
|
1201
|
-
| Dry::Monads |
|
1202
|
-
| **Micro::Case** |
|
1203
|
-
| Interactor |
|
1204
|
-
| Trailblazer::Operation |
|
1205
|
-
| Dry::Transaction |
|
1203
|
+
| Dry::Monads | 315635.1 | _**The Fastest**_ |
|
1204
|
+
| **Micro::Case** | 75837.7 | 4.16x slower |
|
1205
|
+
| Interactor | 59745.5 | 5.28x slower |
|
1206
|
+
| Trailblazer::Operation | 28423.9 | 11.10x slower |
|
1207
|
+
| Dry::Transaction | 10130.9 | 31.16x slower |
|
1206
1208
|
|
1207
1209
|
<details>
|
1208
1210
|
<summary>Show the full <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a> results.</summary>
|
1209
1211
|
|
1210
1212
|
```ruby
|
1211
1213
|
# Warming up --------------------------------------
|
1212
|
-
# Interactor 5.
|
1213
|
-
# Trailblazer::Operation
|
1214
|
-
#
|
1215
|
-
#
|
1216
|
-
#
|
1217
|
-
#
|
1218
|
-
#
|
1214
|
+
# Interactor 5.711k i/100ms
|
1215
|
+
# Trailblazer::Operation
|
1216
|
+
# 2.283k i/100ms
|
1217
|
+
# Dry::Monads 31.130k i/100ms
|
1218
|
+
# Dry::Transaction 994.000 i/100ms
|
1219
|
+
# Micro::Case 7.911k i/100ms
|
1220
|
+
# Micro::Case::Safe 7.911k i/100ms
|
1221
|
+
# Micro::Case::Strict 6.248k i/100ms
|
1219
1222
|
|
1220
1223
|
# Calculating -------------------------------------
|
1221
|
-
# Interactor
|
1222
|
-
# Trailblazer::Operation
|
1223
|
-
#
|
1224
|
-
#
|
1225
|
-
#
|
1226
|
-
#
|
1227
|
-
#
|
1224
|
+
# Interactor 59.746k (±29.9%) i/s - 274.128k in 5.049901s
|
1225
|
+
# Trailblazer::Operation
|
1226
|
+
# 28.424k (±15.8%) i/s - 141.546k in 5.087882s
|
1227
|
+
# Dry::Monads 315.635k (± 6.1%) i/s - 1.588M in 5.048914s
|
1228
|
+
# Dry::Transaction 10.131k (± 6.4%) i/s - 50.694k in 5.025150s
|
1229
|
+
# Micro::Case 75.838k (± 9.7%) i/s - 379.728k in 5.052573s
|
1230
|
+
# Micro::Case::Safe 75.461k (±10.1%) i/s - 379.728k in 5.079238s
|
1231
|
+
# Micro::Case::Strict 64.235k (± 9.0%) i/s - 324.896k in 5.097028s
|
1228
1232
|
|
1229
1233
|
# Comparison:
|
1230
|
-
# Dry::Monads:
|
1231
|
-
# Micro::Case:
|
1232
|
-
# Micro::Case::Safe:
|
1233
|
-
# Micro::Case::Strict:
|
1234
|
-
# Interactor:
|
1235
|
-
# Trailblazer::Operation:
|
1236
|
-
# Dry::Transaction:
|
1234
|
+
# Dry::Monads: 315635.1 i/s
|
1235
|
+
# Micro::Case: 75837.7 i/s - 4.16x (± 0.00) slower
|
1236
|
+
# Micro::Case::Safe: 75461.3 i/s - 4.18x (± 0.00) slower
|
1237
|
+
# Micro::Case::Strict: 64234.9 i/s - 4.91x (± 0.00) slower
|
1238
|
+
# Interactor: 59745.5 i/s - 5.28x (± 0.00) slower
|
1239
|
+
# Trailblazer::Operation: 28423.9 i/s - 11.10x (± 0.00) slower
|
1240
|
+
# Dry::Transaction: 10130.9 i/s - 31.16x (± 0.00) slower
|
1237
1241
|
```
|
1238
1242
|
</details>
|
1239
1243
|
|
@@ -1243,42 +1247,42 @@ https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/use_case/suc
|
|
1243
1247
|
|
1244
1248
|
| Gem / Abstraction | Iterations per second | Comparison |
|
1245
1249
|
| ----------------- | --------------------: | ----------------: |
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
| Trailblazer::Operation |
|
1249
|
-
| Interactor |
|
1250
|
-
| Dry::Transaction |
|
1250
|
+
| Dry::Monads | 135386.9 | _**The Fastest**_ |
|
1251
|
+
| **Micro::Case** | 73489.3 | 1.85x slower |
|
1252
|
+
| Trailblazer::Operation | 29016.4 | 4.67x slower |
|
1253
|
+
| Interactor | 27037.0 | 5.01x slower |
|
1254
|
+
| Dry::Transaction | 8988.6 | 15.06x slower |
|
1251
1255
|
|
1252
1256
|
<details>
|
1253
1257
|
<summary>Show the full <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a> results.</summary>
|
1254
1258
|
|
1255
1259
|
```ruby
|
1256
1260
|
# Warming up --------------------------------------
|
1257
|
-
# Interactor 2.
|
1258
|
-
# Trailblazer::Operation
|
1259
|
-
# Dry::Monads 13.
|
1260
|
-
# Dry::Transaction
|
1261
|
-
# Micro::Case
|
1262
|
-
# Micro::Case::Safe
|
1263
|
-
# Micro::Case::Strict
|
1261
|
+
# Interactor 2.626k i/100ms
|
1262
|
+
# Trailblazer::Operation 2.343k i/100ms
|
1263
|
+
# Dry::Monads 13.386k i/100ms
|
1264
|
+
# Dry::Transaction 868.000 i/100ms
|
1265
|
+
# Micro::Case 7.603k i/100ms
|
1266
|
+
# Micro::Case::Safe 7.598k i/100ms
|
1267
|
+
# Micro::Case::Strict 6.178k i/100ms
|
1264
1268
|
|
1265
1269
|
# Calculating -------------------------------------
|
1266
|
-
# Interactor
|
1267
|
-
# Trailblazer::Operation
|
1268
|
-
# Dry::Monads
|
1269
|
-
# Dry::Transaction
|
1270
|
-
# Micro::Case
|
1271
|
-
# Micro::Case::Safe
|
1272
|
-
# Micro::Case::Strict
|
1270
|
+
# Interactor 27.037k (±24.9%) i/s - 128.674k in 5.102133s
|
1271
|
+
# Trailblazer::Operation 29.016k (±12.4%) i/s - 145.266k in 5.074991s
|
1272
|
+
# Dry::Monads 135.387k (±15.1%) i/s - 669.300k in 5.055356s
|
1273
|
+
# Dry::Transaction 8.989k (± 9.2%) i/s - 45.136k in 5.084820s
|
1274
|
+
# Micro::Case 73.247k (± 9.9%) i/s - 364.944k in 5.030449s
|
1275
|
+
# Micro::Case::Safe 73.489k (± 9.6%) i/s - 364.704k in 5.007282s
|
1276
|
+
# Micro::Case::Strict 61.980k (± 8.0%) i/s - 308.900k in 5.014821s
|
1273
1277
|
|
1274
1278
|
# Comparison:
|
1275
|
-
#
|
1276
|
-
#
|
1277
|
-
# Micro::Case:
|
1278
|
-
# Micro::Case::Strict:
|
1279
|
-
# Trailblazer::Operation:
|
1280
|
-
# Interactor:
|
1281
|
-
# Dry::Transaction:
|
1279
|
+
# Dry::Monads: 135386.9 i/s
|
1280
|
+
# Micro::Case::Safe: 73489.3 i/s - 1.84x (± 0.00) slower
|
1281
|
+
# Micro::Case: 73246.6 i/s - 1.85x (± 0.00) slower
|
1282
|
+
# Micro::Case::Strict: 61979.7 i/s - 2.18x (± 0.00) slower
|
1283
|
+
# Trailblazer::Operation: 29016.4 i/s - 4.67x (± 0.00) slower
|
1284
|
+
# Interactor: 27037.0 i/s - 5.01x (± 0.00) slower
|
1285
|
+
# Dry::Transaction: 8988.6 i/s - 15.06x (± 0.00) slower
|
1282
1286
|
```
|
1283
1287
|
</details>
|
1284
1288
|
|
@@ -1290,12 +1294,12 @@ https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/use_case/fai
|
|
1290
1294
|
|
1291
1295
|
| Gems / Abstraction | [Success results](https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/flow/success_results.rb) | [Failure results](https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/flow/failure_results.rb) |
|
1292
1296
|
| ------------------------------------------- | ----------------: | ----------------: |
|
1293
|
-
| Micro::Case::Result `pipe` method |
|
1294
|
-
| Micro::Case::Result `then` method |
|
1295
|
-
| Micro::Cases.flow |
|
1296
|
-
| Micro::Case class with an inner flow |
|
1297
|
-
| Micro::Case class including itself as a step|
|
1298
|
-
| Interactor::Organizer |
|
1297
|
+
| Micro::Case::Result `pipe` method | 80936.2 i/s | 78280.4 i/s |
|
1298
|
+
| Micro::Case::Result `then` method | 0x slower | 0x slower |
|
1299
|
+
| Micro::Cases.flow | 0x slower | 0x slower |
|
1300
|
+
| Micro::Case class with an inner flow | 1.72x slower | 1.68x slower |
|
1301
|
+
| Micro::Case class including itself as a step| 1.93x slower | 1.87x slower |
|
1302
|
+
| Interactor::Organizer | 3.33x slower | 3.22x slower |
|
1299
1303
|
|
1300
1304
|
\* The `Dry::Monads`, `Dry::Transaction`, `Trailblazer::Operation` gems are out of this analysis because all of them doesn't have this kind of feature.
|
1301
1305
|
|
@@ -1304,28 +1308,28 @@ https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/use_case/fai
|
|
1304
1308
|
|
1305
1309
|
```ruby
|
1306
1310
|
# Warming up --------------------------------------
|
1307
|
-
# Interactor::Organizer
|
1308
|
-
# Micro::Cases.flow([])
|
1309
|
-
# Micro::Case flow in a class
|
1310
|
-
# Micro::Case including the class
|
1311
|
-
# Micro::Case::Result#|
|
1312
|
-
# Micro::Case::Result#then
|
1311
|
+
# Interactor::Organizer 1.809k i/100ms
|
1312
|
+
# Micro::Cases.flow([]) 7.808k i/100ms
|
1313
|
+
# Micro::Case flow in a class 4.816k i/100ms
|
1314
|
+
# Micro::Case including the class 4.094k i/100ms
|
1315
|
+
# Micro::Case::Result#| 7.656k i/100ms
|
1316
|
+
# Micro::Case::Result#then 7.138k i/100ms
|
1313
1317
|
|
1314
1318
|
# Calculating -------------------------------------
|
1315
|
-
# Interactor::Organizer
|
1316
|
-
# Micro::Cases.flow([])
|
1317
|
-
# Micro::Case flow in a class
|
1318
|
-
# Micro::Case including the class
|
1319
|
-
# Micro::Case::Result#|
|
1320
|
-
# Micro::Case::Result#then
|
1319
|
+
# Interactor::Organizer 24.290k (±24.0%) i/s - 113.967k in 5.032825s
|
1320
|
+
# Micro::Cases.flow([]) 74.790k (±11.1%) i/s - 374.784k in 5.071740s
|
1321
|
+
# Micro::Case flow in a class 47.043k (± 8.0%) i/s - 235.984k in 5.047477s
|
1322
|
+
# Micro::Case including the class 42.030k (± 8.5%) i/s - 208.794k in 5.002138s
|
1323
|
+
# Micro::Case::Result#| 80.936k (±15.9%) i/s - 398.112k in 5.052531s
|
1324
|
+
# Micro::Case::Result#then 71.459k (± 8.8%) i/s - 356.900k in 5.030526s
|
1321
1325
|
|
1322
1326
|
# Comparison:
|
1323
|
-
# Micro::Case::Result#|:
|
1324
|
-
# Micro::
|
1325
|
-
# Micro::
|
1326
|
-
# Micro::Case flow in a class:
|
1327
|
-
# Micro::Case including the class:
|
1328
|
-
# Interactor::Organizer:
|
1327
|
+
# Micro::Case::Result#|: 80936.2 i/s
|
1328
|
+
# Micro::Cases.flow([]): 74790.1 i/s - same-ish: difference falls within error
|
1329
|
+
# Micro::Case::Result#then: 71459.5 i/s - same-ish: difference falls within error
|
1330
|
+
# Micro::Case flow in a class: 47042.6 i/s - 1.72x (± 0.00) slower
|
1331
|
+
# Micro::Case including the class: 42030.2 i/s - 1.93x (± 0.00) slower
|
1332
|
+
# Interactor::Organizer: 24290.3 i/s - 3.33x (± 0.00) slower
|
1329
1333
|
```
|
1330
1334
|
</details>
|
1331
1335
|
|
@@ -1334,28 +1338,28 @@ https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/use_case/fai
|
|
1334
1338
|
|
1335
1339
|
```ruby
|
1336
1340
|
# Warming up --------------------------------------
|
1337
|
-
# Interactor::Organizer
|
1338
|
-
# Micro::Cases.flow([])
|
1339
|
-
# Micro::Case flow in a class
|
1340
|
-
# Micro::Case including the class
|
1341
|
-
# Micro::Case::Result#|
|
1342
|
-
# Micro::Case::Result#then
|
1341
|
+
# Interactor::Organizer 1.734k i/100ms
|
1342
|
+
# Micro::Cases.flow([]) 7.515k i/100ms
|
1343
|
+
# Micro::Case flow in a class 4.636k i/100ms
|
1344
|
+
# Micro::Case including the class 4.114k i/100ms
|
1345
|
+
# Micro::Case::Result#| 7.588k i/100ms
|
1346
|
+
# Micro::Case::Result#then 6.681k i/100ms
|
1343
1347
|
|
1344
1348
|
# Calculating -------------------------------------
|
1345
|
-
# Interactor::Organizer
|
1346
|
-
# Micro::Cases.flow([])
|
1347
|
-
# Micro::Case flow in a class
|
1348
|
-
# Micro::Case including the class
|
1349
|
-
# Micro::Case::Result#|
|
1350
|
-
# Micro::Case::Result#then
|
1349
|
+
# Interactor::Organizer 24.280k (±24.5%) i/s - 112.710k in 5.013334s
|
1350
|
+
# Micro::Cases.flow([]) 74.999k (± 9.8%) i/s - 375.750k in 5.055777s
|
1351
|
+
# Micro::Case flow in a class 46.681k (± 9.3%) i/s - 236.436k in 5.105105s
|
1352
|
+
# Micro::Case including the class 41.921k (± 8.9%) i/s - 209.814k in 5.043622s
|
1353
|
+
# Micro::Case::Result#| 78.280k (±12.6%) i/s - 386.988k in 5.022146s
|
1354
|
+
# Micro::Case::Result#then 68.898k (± 8.8%) i/s - 347.412k in 5.080116s
|
1351
1355
|
|
1352
1356
|
# Comparison:
|
1353
|
-
# Micro::Case::Result#|:
|
1354
|
-
# Micro::
|
1355
|
-
# Micro::
|
1356
|
-
# Micro::Case flow in a class:
|
1357
|
-
# Micro::Case including the class:
|
1358
|
-
# Interactor::Organizer:
|
1357
|
+
# Micro::Case::Result#|: 78280.4 i/s
|
1358
|
+
# Micro::Cases.flow([]): 74999.4 i/s - same-ish: difference falls within error
|
1359
|
+
# Micro::Case::Result#then: 68898.4 i/s - same-ish: difference falls within error
|
1360
|
+
# Micro::Case flow in a class: 46681.0 i/s - 1.68x (± 0.00) slower
|
1361
|
+
# Micro::Case including the class: 41920.8 i/s - 1.87x (± 0.00) slower
|
1362
|
+
# Interactor::Organizer: 24280.0 i/s - 3.22x (± 0.00) slower
|
1359
1363
|
```
|
1360
1364
|
</details>
|
1361
1365
|
|
data/README.pt-BR.md
CHANGED
@@ -38,7 +38,8 @@ Principais objetivos deste projeto:
|
|
38
38
|
|
39
39
|
Versão | Documentação
|
40
40
|
--------- | -------------
|
41
|
-
|
41
|
+
unreleased| https://github.com/serradura/u-case/blob/main/README.md
|
42
|
+
4.2.2 | https://github.com/serradura/u-case/blob/v4.x/README.md
|
42
43
|
3.1.0 | https://github.com/serradura/u-case/blob/v3.x/README.md
|
43
44
|
2.6.0 | https://github.com/serradura/u-case/blob/v2.x/README.md
|
44
45
|
1.1.0 | https://github.com/serradura/u-case/blob/v1.x/README.md
|
@@ -69,9 +70,8 @@ Versão | Documentação
|
|
69
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)
|
70
71
|
- [`Micro::Case::Strict` - O que é um caso de uso estrito?](#microcasestrict---o-que-é-um-caso-de-uso-estrito)
|
71
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)
|
72
|
-
- [`Micro::Case::Result#on_exception`](#microcaseresulton_exception)
|
73
73
|
- [`Micro::Cases::Safe::Flow`](#microcasessafeflow)
|
74
|
-
- [`Micro::Case::Result#on_exception`](#microcaseresulton_exception
|
74
|
+
- [`Micro::Case::Result#on_exception`](#microcaseresulton_exception)
|
75
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)
|
76
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)
|
77
77
|
- [`Kind::Validator`](#kindvalidator)
|
@@ -99,7 +99,8 @@ Versão | Documentação
|
|
99
99
|
|
100
100
|
| u-case | branch | ruby | activemodel | u-attributes |
|
101
101
|
| -------------- | ------- | -------- | ------------- | ------------ |
|
102
|
-
|
|
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 |
|
103
104
|
| 3.1.0 | v3.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
|
104
105
|
| 2.6.0 | v2.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
|
105
106
|
| 1.1.0 | v1.x | >= 2.2.0 | >= 3.2, < 6.1 | ~> 1.1 |
|
@@ -123,7 +124,7 @@ Versão | Documentação
|
|
123
124
|
Adicione essa linha ao Gemfile da sua aplicação:
|
124
125
|
|
125
126
|
```ruby
|
126
|
-
gem 'u-case', '~>
|
127
|
+
gem 'u-case', '~> 4.1.0'
|
127
128
|
```
|
128
129
|
|
129
130
|
E então execute:
|
@@ -975,8 +976,6 @@ result.on_failure(:exception) do |result|
|
|
975
976
|
end
|
976
977
|
```
|
977
978
|
|
978
|
-
#### `Micro::Case::Result#on_exception`
|
979
|
-
|
980
979
|
Se você precisar lidar com um erro específico, recomendo o uso de uma instrução case. Exemplo:
|
981
980
|
|
982
981
|
```ruby
|
@@ -1200,44 +1199,46 @@ end
|
|
1200
1199
|
|
1201
1200
|
#### Success results
|
1202
1201
|
|
1203
|
-
| Gem / Abstração | Iterações por segundo |
|
1204
|
-
| ----------------- | --------------------: |
|
1205
|
-
| Dry::Monads |
|
1206
|
-
| **Micro::Case** |
|
1207
|
-
| Interactor |
|
1208
|
-
| Trailblazer::Operation |
|
1209
|
-
| Dry::Transaction |
|
1202
|
+
| Gem / Abstração | Iterações por segundo | Comparação |
|
1203
|
+
| ----------------- | --------------------: | -------------------: |
|
1204
|
+
| Dry::Monads | 315635.1 | _**O mais rápido**_ |
|
1205
|
+
| **Micro::Case** | 75837.7 | 4.16x mais lento |
|
1206
|
+
| Interactor | 59745.5 | 5.28x mais lento |
|
1207
|
+
| Trailblazer::Operation | 28423.9 | 11.10x mais lento |
|
1208
|
+
| Dry::Transaction | 10130.9 | 31.16x mais lento |
|
1210
1209
|
|
1211
1210
|
<details>
|
1212
1211
|
<summary>Show the full <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a> results.</summary>
|
1213
1212
|
|
1214
1213
|
```ruby
|
1215
1214
|
# Warming up --------------------------------------
|
1216
|
-
# Interactor 5.
|
1217
|
-
# Trailblazer::Operation
|
1218
|
-
#
|
1219
|
-
#
|
1220
|
-
#
|
1221
|
-
#
|
1222
|
-
#
|
1215
|
+
# Interactor 5.711k i/100ms
|
1216
|
+
# Trailblazer::Operation
|
1217
|
+
# 2.283k i/100ms
|
1218
|
+
# Dry::Monads 31.130k i/100ms
|
1219
|
+
# Dry::Transaction 994.000 i/100ms
|
1220
|
+
# Micro::Case 7.911k i/100ms
|
1221
|
+
# Micro::Case::Safe 7.911k i/100ms
|
1222
|
+
# Micro::Case::Strict 6.248k i/100ms
|
1223
1223
|
|
1224
1224
|
# Calculating -------------------------------------
|
1225
|
-
# Interactor
|
1226
|
-
# Trailblazer::Operation
|
1227
|
-
#
|
1228
|
-
#
|
1229
|
-
#
|
1230
|
-
#
|
1231
|
-
#
|
1225
|
+
# Interactor 59.746k (±29.9%) i/s - 274.128k in 5.049901s
|
1226
|
+
# Trailblazer::Operation
|
1227
|
+
# 28.424k (±15.8%) i/s - 141.546k in 5.087882s
|
1228
|
+
# Dry::Monads 315.635k (± 6.1%) i/s - 1.588M in 5.048914s
|
1229
|
+
# Dry::Transaction 10.131k (± 6.4%) i/s - 50.694k in 5.025150s
|
1230
|
+
# Micro::Case 75.838k (± 9.7%) i/s - 379.728k in 5.052573s
|
1231
|
+
# Micro::Case::Safe 75.461k (±10.1%) i/s - 379.728k in 5.079238s
|
1232
|
+
# Micro::Case::Strict 64.235k (± 9.0%) i/s - 324.896k in 5.097028s
|
1232
1233
|
|
1233
1234
|
# Comparison:
|
1234
|
-
# Dry::Monads:
|
1235
|
-
# Micro::Case:
|
1236
|
-
# Micro::Case::Safe:
|
1237
|
-
# Micro::Case::Strict:
|
1238
|
-
# Interactor:
|
1239
|
-
# Trailblazer::Operation:
|
1240
|
-
# Dry::Transaction:
|
1235
|
+
# Dry::Monads: 315635.1 i/s
|
1236
|
+
# Micro::Case: 75837.7 i/s - 4.16x (± 0.00) slower
|
1237
|
+
# Micro::Case::Safe: 75461.3 i/s - 4.18x (± 0.00) slower
|
1238
|
+
# Micro::Case::Strict: 64234.9 i/s - 4.91x (± 0.00) slower
|
1239
|
+
# Interactor: 59745.5 i/s - 5.28x (± 0.00) slower
|
1240
|
+
# Trailblazer::Operation: 28423.9 i/s - 11.10x (± 0.00) slower
|
1241
|
+
# Dry::Transaction: 10130.9 i/s - 31.16x (± 0.00) slower
|
1241
1242
|
```
|
1242
1243
|
</details>
|
1243
1244
|
|
@@ -1245,44 +1246,44 @@ https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/use_case/suc
|
|
1245
1246
|
|
1246
1247
|
#### Failure results
|
1247
1248
|
|
1248
|
-
| Gem / Abstração | Iterações por segundo |
|
1249
|
-
| ----------------- | --------------------: |
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
| Trailblazer::Operation |
|
1253
|
-
| Interactor |
|
1254
|
-
| Dry::Transaction |
|
1249
|
+
| Gem / Abstração | Iterações por segundo | Comparação |
|
1250
|
+
| ----------------- | --------------------: | -------------------: |
|
1251
|
+
| Dry::Monads | 135386.9 | _**O mais rápido**_ |
|
1252
|
+
| **Micro::Case** | 73489.3 | 1.85x mais lento |
|
1253
|
+
| Trailblazer::Operation | 29016.4 | 4.67x mais lento |
|
1254
|
+
| Interactor | 27037.0 | 5.01x mais lento |
|
1255
|
+
| Dry::Transaction | 8988.6 | 15.06x mais lento |
|
1255
1256
|
|
1256
1257
|
<details>
|
1257
1258
|
<summary>Mostrar o resultado completo do <a href="https://github.com/evanphx/benchmark-ips">benchmark/ips</a>.</summary>
|
1258
1259
|
|
1259
1260
|
```ruby
|
1260
1261
|
# Warming up --------------------------------------
|
1261
|
-
# Interactor 2.
|
1262
|
-
# Trailblazer::Operation
|
1263
|
-
# Dry::Monads 13.
|
1264
|
-
# Dry::Transaction
|
1265
|
-
# Micro::Case
|
1266
|
-
# Micro::Case::Safe
|
1267
|
-
# Micro::Case::Strict
|
1262
|
+
# Interactor 2.626k i/100ms
|
1263
|
+
# Trailblazer::Operation 2.343k i/100ms
|
1264
|
+
# Dry::Monads 13.386k i/100ms
|
1265
|
+
# Dry::Transaction 868.000 i/100ms
|
1266
|
+
# Micro::Case 7.603k i/100ms
|
1267
|
+
# Micro::Case::Safe 7.598k i/100ms
|
1268
|
+
# Micro::Case::Strict 6.178k i/100ms
|
1268
1269
|
|
1269
1270
|
# Calculating -------------------------------------
|
1270
|
-
# Interactor
|
1271
|
-
# Trailblazer::Operation
|
1272
|
-
# Dry::Monads
|
1273
|
-
# Dry::Transaction
|
1274
|
-
# Micro::Case
|
1275
|
-
# Micro::Case::Safe
|
1276
|
-
# Micro::Case::Strict
|
1271
|
+
# Interactor 27.037k (±24.9%) i/s - 128.674k in 5.102133s
|
1272
|
+
# Trailblazer::Operation 29.016k (±12.4%) i/s - 145.266k in 5.074991s
|
1273
|
+
# Dry::Monads 135.387k (±15.1%) i/s - 669.300k in 5.055356s
|
1274
|
+
# Dry::Transaction 8.989k (± 9.2%) i/s - 45.136k in 5.084820s
|
1275
|
+
# Micro::Case 73.247k (± 9.9%) i/s - 364.944k in 5.030449s
|
1276
|
+
# Micro::Case::Safe 73.489k (± 9.6%) i/s - 364.704k in 5.007282s
|
1277
|
+
# Micro::Case::Strict 61.980k (± 8.0%) i/s - 308.900k in 5.014821s
|
1277
1278
|
|
1278
1279
|
# Comparison:
|
1279
|
-
#
|
1280
|
-
#
|
1281
|
-
# Micro::Case:
|
1282
|
-
# Micro::Case::Strict:
|
1283
|
-
# Trailblazer::Operation:
|
1284
|
-
# Interactor:
|
1285
|
-
# Dry::Transaction:
|
1280
|
+
# Dry::Monads: 135386.9 i/s
|
1281
|
+
# Micro::Case::Safe: 73489.3 i/s - 1.84x (± 0.00) slower
|
1282
|
+
# Micro::Case: 73246.6 i/s - 1.85x (± 0.00) slower
|
1283
|
+
# Micro::Case::Strict: 61979.7 i/s - 2.18x (± 0.00) slower
|
1284
|
+
# Trailblazer::Operation: 29016.4 i/s - 4.67x (± 0.00) slower
|
1285
|
+
# Interactor: 27037.0 i/s - 5.01x (± 0.00) slower
|
1286
|
+
# Dry::Transaction: 8988.6 i/s - 15.06x (± 0.00) slower
|
1286
1287
|
```
|
1287
1288
|
</details>
|
1288
1289
|
|
@@ -1294,12 +1295,12 @@ https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/use_case/fai
|
|
1294
1295
|
|
1295
1296
|
| Gem / Abstração | [Resultados de sucesso](https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/flow/success_results.rb) | [Resultados de falha](https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/flow/failure_results.rb) |
|
1296
1297
|
| ------------------------------------------- | ----------------: | ----------------: |
|
1297
|
-
| Micro::Case::Result `pipe` method |
|
1298
|
-
| Micro::Case::Result `then` method |
|
1299
|
-
| Micro::Cases.flow |
|
1300
|
-
| Micro::Case class with an inner flow |
|
1301
|
-
| Micro::Case class including itself as a step|
|
1302
|
-
| Interactor::Organizer |
|
1298
|
+
| Micro::Case::Result `pipe` method | 80936.2 i/s | 78280.4 i/s |
|
1299
|
+
| Micro::Case::Result `then` method | 0x mais lento | 0x mais lento |
|
1300
|
+
| Micro::Cases.flow | 0x mais lento | 0x mais lento |
|
1301
|
+
| Micro::Case class with an inner flow | 1.72x mais lento | 1.68x mais lento |
|
1302
|
+
| Micro::Case class including itself as a step| 1.93x mais lento | 1.87x mais lento |
|
1303
|
+
| Interactor::Organizer | 3.33x mais lento | 3.22x mais lento |
|
1303
1304
|
|
1304
1305
|
\* As gems `Dry::Monads`, `Dry::Transaction`, `Trailblazer::Operation` estão fora desta análise por não terem esse tipo de funcionalidade.
|
1305
1306
|
|
@@ -1308,28 +1309,28 @@ https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/use_case/fai
|
|
1308
1309
|
|
1309
1310
|
```ruby
|
1310
1311
|
# Warming up --------------------------------------
|
1311
|
-
# Interactor::Organizer
|
1312
|
-
# Micro::Cases.flow([])
|
1313
|
-
# Micro::Case flow in a class
|
1314
|
-
# Micro::Case including the class
|
1315
|
-
# Micro::Case::Result#|
|
1316
|
-
# Micro::Case::Result#then
|
1312
|
+
# Interactor::Organizer 1.809k i/100ms
|
1313
|
+
# Micro::Cases.flow([]) 7.808k i/100ms
|
1314
|
+
# Micro::Case flow in a class 4.816k i/100ms
|
1315
|
+
# Micro::Case including the class 4.094k i/100ms
|
1316
|
+
# Micro::Case::Result#| 7.656k i/100ms
|
1317
|
+
# Micro::Case::Result#then 7.138k i/100ms
|
1317
1318
|
|
1318
1319
|
# Calculating -------------------------------------
|
1319
|
-
# Interactor::Organizer
|
1320
|
-
# Micro::Cases.flow([])
|
1321
|
-
# Micro::Case flow in a class
|
1322
|
-
# Micro::Case including the class
|
1323
|
-
# Micro::Case::Result#|
|
1324
|
-
# Micro::Case::Result#then
|
1320
|
+
# Interactor::Organizer 24.290k (±24.0%) i/s - 113.967k in 5.032825s
|
1321
|
+
# Micro::Cases.flow([]) 74.790k (±11.1%) i/s - 374.784k in 5.071740s
|
1322
|
+
# Micro::Case flow in a class 47.043k (± 8.0%) i/s - 235.984k in 5.047477s
|
1323
|
+
# Micro::Case including the class 42.030k (± 8.5%) i/s - 208.794k in 5.002138s
|
1324
|
+
# Micro::Case::Result#| 80.936k (±15.9%) i/s - 398.112k in 5.052531s
|
1325
|
+
# Micro::Case::Result#then 71.459k (± 8.8%) i/s - 356.900k in 5.030526s
|
1325
1326
|
|
1326
1327
|
# Comparison:
|
1327
|
-
# Micro::Case::Result#|:
|
1328
|
-
# Micro::
|
1329
|
-
# Micro::
|
1330
|
-
# Micro::Case flow in a class:
|
1331
|
-
# Micro::Case including the class:
|
1332
|
-
# Interactor::Organizer:
|
1328
|
+
# Micro::Case::Result#|: 80936.2 i/s
|
1329
|
+
# Micro::Cases.flow([]): 74790.1 i/s - same-ish: difference falls within error
|
1330
|
+
# Micro::Case::Result#then: 71459.5 i/s - same-ish: difference falls within error
|
1331
|
+
# Micro::Case flow in a class: 47042.6 i/s - 1.72x (± 0.00) slower
|
1332
|
+
# Micro::Case including the class: 42030.2 i/s - 1.93x (± 0.00) slower
|
1333
|
+
# Interactor::Organizer: 24290.3 i/s - 3.33x (± 0.00) slower
|
1333
1334
|
```
|
1334
1335
|
</details>
|
1335
1336
|
|
@@ -1338,28 +1339,28 @@ https://github.com/serradura/u-case/blob/main/benchmarks/perfomance/use_case/fai
|
|
1338
1339
|
|
1339
1340
|
```ruby
|
1340
1341
|
# Warming up --------------------------------------
|
1341
|
-
# Interactor::Organizer
|
1342
|
-
# Micro::Cases.flow([])
|
1343
|
-
# Micro::Case flow in a class
|
1344
|
-
# Micro::Case including the class
|
1345
|
-
# Micro::Case::Result#|
|
1346
|
-
# Micro::Case::Result#then
|
1342
|
+
# Interactor::Organizer 1.734k i/100ms
|
1343
|
+
# Micro::Cases.flow([]) 7.515k i/100ms
|
1344
|
+
# Micro::Case flow in a class 4.636k i/100ms
|
1345
|
+
# Micro::Case including the class 4.114k i/100ms
|
1346
|
+
# Micro::Case::Result#| 7.588k i/100ms
|
1347
|
+
# Micro::Case::Result#then 6.681k i/100ms
|
1347
1348
|
|
1348
1349
|
# Calculating -------------------------------------
|
1349
|
-
# Interactor::Organizer
|
1350
|
-
# Micro::Cases.flow([])
|
1351
|
-
# Micro::Case flow in a class
|
1352
|
-
# Micro::Case including the class
|
1353
|
-
# Micro::Case::Result#|
|
1354
|
-
# Micro::Case::Result#then
|
1350
|
+
# Interactor::Organizer 24.280k (±24.5%) i/s - 112.710k in 5.013334s
|
1351
|
+
# Micro::Cases.flow([]) 74.999k (± 9.8%) i/s - 375.750k in 5.055777s
|
1352
|
+
# Micro::Case flow in a class 46.681k (± 9.3%) i/s - 236.436k in 5.105105s
|
1353
|
+
# Micro::Case including the class 41.921k (± 8.9%) i/s - 209.814k in 5.043622s
|
1354
|
+
# Micro::Case::Result#| 78.280k (±12.6%) i/s - 386.988k in 5.022146s
|
1355
|
+
# Micro::Case::Result#then 68.898k (± 8.8%) i/s - 347.412k in 5.080116s
|
1355
1356
|
|
1356
1357
|
# Comparison:
|
1357
|
-
# Micro::Case::Result#|:
|
1358
|
-
# Micro::
|
1359
|
-
# Micro::
|
1360
|
-
# Micro::Case flow in a class:
|
1361
|
-
# Micro::Case including the class:
|
1362
|
-
# Interactor::Organizer:
|
1358
|
+
# Micro::Case::Result#|: 78280.4 i/s
|
1359
|
+
# Micro::Cases.flow([]): 74999.4 i/s - same-ish: difference falls within error
|
1360
|
+
# Micro::Case::Result#then: 68898.4 i/s - same-ish: difference falls within error
|
1361
|
+
# Micro::Case flow in a class: 46681.0 i/s - 1.68x (± 0.00) slower
|
1362
|
+
# Micro::Case including the class: 41920.8 i/s - 1.87x (± 0.00) slower
|
1363
|
+
# Interactor::Organizer: 24280.0 i/s - 3.22x (± 0.00) slower
|
1363
1364
|
```
|
1364
1365
|
</details>
|
1365
1366
|
|