bcdd-result 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +24 -11
  3. data/CHANGELOG.md +28 -0
  4. data/README.md +585 -160
  5. data/lib/bcdd/result/context/expectations/mixin.rb +35 -0
  6. data/lib/bcdd/result/context/expectations.rb +41 -0
  7. data/lib/bcdd/result/context/failure.rb +9 -0
  8. data/lib/bcdd/result/context/mixin.rb +38 -0
  9. data/lib/bcdd/result/context/success.rb +15 -0
  10. data/lib/bcdd/result/context.rb +74 -0
  11. data/lib/bcdd/result/{expectations/contract → contract}/disabled.rb +2 -2
  12. data/lib/bcdd/result/{expectations → contract}/error.rb +5 -3
  13. data/lib/bcdd/result/{expectations/contract → contract}/evaluator.rb +2 -2
  14. data/lib/bcdd/result/{expectations/contract → contract}/for_types.rb +2 -2
  15. data/lib/bcdd/result/{expectations/contract → contract}/for_types_and_values.rb +10 -8
  16. data/lib/bcdd/result/contract/interface.rb +21 -0
  17. data/lib/bcdd/result/{expectations → contract}/type_checker.rb +1 -1
  18. data/lib/bcdd/result/contract.rb +43 -0
  19. data/lib/bcdd/result/error.rb +7 -9
  20. data/lib/bcdd/result/expectations/mixin.rb +14 -9
  21. data/lib/bcdd/result/expectations.rb +28 -37
  22. data/lib/bcdd/result/failure/methods.rb +21 -0
  23. data/lib/bcdd/result/failure.rb +2 -16
  24. data/lib/bcdd/result/mixin.rb +8 -3
  25. data/lib/bcdd/result/success/methods.rb +21 -0
  26. data/lib/bcdd/result/success.rb +2 -16
  27. data/lib/bcdd/result/version.rb +1 -1
  28. data/lib/bcdd/result.rb +6 -4
  29. data/sig/bcdd/result.rbs +227 -83
  30. metadata +18 -10
  31. data/lib/bcdd/result/expectations/contract/interface.rb +0 -21
  32. data/lib/bcdd/result/expectations/contract.rb +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d43af37c2ffd8d2764fc62039ac1d3e4398b2872fa25bc80192a9aca1b08dfb5
4
- data.tar.gz: 8aaab364445f279d207390479bce6680c4ed4b7fe4b2fc026e203ddece47a398
3
+ metadata.gz: dda53cc516fcb8d18b2bd3c8431f2ca8d5d7363b6e58fd57d3fe3d1b49877e20
4
+ data.tar.gz: 367b97ba29f35dd2d6918817db38a2253929252c616aebcb47d7fc024888d258
5
5
  SHA512:
6
- metadata.gz: 6dbac4fdded1e36d6f2af6e5c7e0d0bebfe44b489410a35445935c8da656fe244fca7a6e769a5b73d6070929e790be420887b2576cb9b523a798fe3ff759e564
7
- data.tar.gz: 12055de39a9a3a93f69670da7b3a93a0e3749568590be14d02ce750cb5b5e5b00c7b56da422941bdea8842b073573e589d2a11681496f18f7160ddeaf3ceb7bb
6
+ metadata.gz: 3618c5090981f4923977708944d94c257879fe57c06d1b2c922b7378c026e4d39c8ab13fdf64ad6277cfea4229d43d120b0d3ec3d7cb676676f0bf8d6714892d
7
+ data.tar.gz: 880a2f0ebcd8f7bb9ee32b2967c39011211e604981d43b59735fc912ec414635bc152ab13549ba64c87af987f66a7c334fae909cd860d3f36f6b092565b8cf24
data/.rubocop.yml CHANGED
@@ -15,31 +15,41 @@ Layout/LineLength:
15
15
  Layout/ExtraSpacing:
16
16
  AllowBeforeTrailingComments: true
17
17
 
18
- Style/ClassAndModuleChildren:
18
+ Layout/MultilineMethodCallIndentation:
19
+ Enabled: false
20
+
21
+ Lint/UnderscorePrefixedVariableName:
22
+ Enabled: false
23
+
24
+ Style/AccessModifierDeclarations:
19
25
  Enabled: false
20
26
 
21
27
  Style/CaseEquality:
22
- Exclude:
23
- - lib/bcdd/result/expectations/contract/for_types_and_values.rb
28
+ Enabled: false
29
+
30
+ Style/ClassAndModuleChildren:
31
+ Enabled: false
24
32
 
25
33
  Style/Lambda:
26
34
  EnforcedStyle: literal
27
35
 
36
+ Style/ParallelAssignment:
37
+ Enabled: false
38
+
39
+ Style/SingleLineMethods:
40
+ Enabled: false
41
+
28
42
  Style/MapToSet:
29
- Exclude:
30
- - lib/bcdd/result/expectations/contract/for_types.rb
43
+ Enabled: false
31
44
 
32
45
  Style/MixinGrouping:
33
46
  Enabled: false
34
47
 
35
- Style/AccessModifierDeclarations:
48
+ Naming/MethodName:
36
49
  Enabled: false
37
50
 
38
- Naming/MethodName:
39
- Exclude:
40
- - lib/bcdd/result/mixin.rb
41
- - lib/bcdd/result/expectations.rb
42
- - lib/bcdd/result/expectations/mixin.rb
51
+ Naming/VariableName:
52
+ Enabled: false
43
53
 
44
54
  Metrics/BlockLength:
45
55
  Exclude:
@@ -52,3 +62,6 @@ Metrics/ClassLength:
52
62
 
53
63
  Minitest/MultipleAssertions:
54
64
  Enabled: false
65
+
66
+ Minitest/AssertEmptyLiteral:
67
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.7.0] - 2023-10-27
4
+
5
+ ### Added
6
+
7
+ - Add `BCDD::Result::Context`. It is a `BCDD::Result`, meaning it has all the features of the `BCDD::Result`. The main difference is that it only accepts keyword arguments as a value, which applies to the `and_then`: The called methods must receive keyword arguments, and the dependency injection will be performed through keyword arguments.<br/><br/>
8
+ As the input/output are hashes, the results of each `and_then` call will automatically accumulate. This is useful in operations chaining, as the result of the previous operations will be automatically available for the next one. Because of this behavior, the `BCDD::Result::Context` has the `#and_expose` method to expose only the desired keys from the accumulated result.
9
+
10
+ - Add `BCDD::Result::Context::Expectations.new` and `BCDD::Result::Context::Expectations.mixin`. Both are similar to `BCDD::Result::Expectations.new` and `BCDD::Result::Expectations.mixin`, but they are for `BCDD::Result::Context` instead of `BCDD::Result`.
11
+ - The `BCDD::Result::Context.mixin` and `BCDD::Result::Context::Expectations.mixin` support the `with: :Continue` option.
12
+
13
+ - Enhance Pattern Matching support. When a `NoMatchingPatternError` occurs inside a value checking, the `BCDD::Result::Contract::Error::UnexpectedValue` message will include the value and the expected patterns.
14
+
15
+ - Add `BCDD::Result::Success::Methods` to be share common methods between `BCDD::Result::Success` and `BCDD::Result::Context::Success`.
16
+
17
+ - Add `BCDD::Result::Failure::Methods` to be share common methods between `BCDD::Failure::Success` and `BCDD::Result::Context::Failure`.
18
+
19
+ - Make all mixin generators produce a named module. The module name will be added to the target class/module (who included/extended a `BCDD::Result`/`BCDD::Result::Context` mixin module).
20
+
21
+ - Add `BCDD::Result::Contract.nil_as_valid_value_checking!`. Please use this method when using the one-line pattern-matching operators on the result's value expectations.
22
+
23
+ ### Changed
24
+
25
+ - **(BREAKING)** Rename `BCDD::Result::WrongResultSubject` to `BCDD::Result::Error::InvalidResultSubject`.
26
+ - **(BREAKING)** Rename `BCDD::Result::WrongSubjectMethodArity` to `BCDD::Result::Error::InvalidSubjectMethodArity`.
27
+ - **(BREAKING)** Rename the constant produced by `BCDD::Result::Expectations.mixins` from `Expected` to `Result`.
28
+ - Extract the major part of the `BCDD::Result::Expectations` components/features to `BCDD::Result::Contract`.
29
+ - **(BREAKING)** `BCDD::Result::Expectations::Error` became `BCDD::Result::Contract::Error`. So, `BCDD::Result::Expectations::Error::UnexpectedType` and `BCDD::Result::Expectations::Error::UnexpectedValue` are now `BCDD::Result::Contract::Error::UnexpectedType` and `BCDD::Result::Contract::Error::UnexpectedValue`.
30
+
3
31
  ## [0.6.0] - 2023-10-11
4
32
 
5
33
  ### Added