bcdd-result 0.7.0 → 0.9.0
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/.rubocop.yml +8 -0
- data/CHANGELOG.md +142 -0
- data/README.md +352 -144
- data/Rakefile +9 -3
- data/Steepfile +1 -1
- data/lib/bcdd/result/config/constant_alias.rb +35 -0
- data/lib/bcdd/result/config/options.rb +27 -0
- data/lib/bcdd/result/config/switcher.rb +82 -0
- data/lib/bcdd/result/config.rb +71 -0
- data/lib/bcdd/result/context/expectations/mixin.rb +5 -17
- data/lib/bcdd/result/context/expectations.rb +9 -25
- data/lib/bcdd/result/context/mixin.rb +23 -12
- data/lib/bcdd/result/context.rb +1 -1
- data/lib/bcdd/result/contract/evaluator.rb +1 -1
- data/lib/bcdd/result/contract/for_types_and_values.rb +7 -2
- data/lib/bcdd/result/contract.rb +4 -14
- data/lib/bcdd/result/data.rb +7 -7
- data/lib/bcdd/result/expectations/mixin.rb +30 -20
- data/lib/bcdd/result/expectations.rb +47 -13
- data/lib/bcdd/result/failure/methods.rb +1 -1
- data/lib/bcdd/result/mixin.rb +39 -18
- data/lib/bcdd/result/success/methods.rb +1 -1
- data/lib/bcdd/result/version.rb +1 -1
- data/lib/bcdd/result.rb +22 -6
- data/lib/bcdd-result.rb +3 -0
- data/sig/bcdd/result.rbs +174 -48
- metadata +11 -8
- data/lib/result.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e4fa0b7a751971ae5fd7987906342e6436535b9bb8729252c7651a5c533302c
|
4
|
+
data.tar.gz: c2f2359525d2c24e28da5d400ef3e7284ccb2c13b8955da84cddb8da7b229cb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fba0932c35635a248eeef6c88b8c386ce2f8a55f235784ea6c144299a0a17f8501efa16f5a171babd2a883b90a8d06726bd47bfcb2261196d726068b8d6e097
|
7
|
+
data.tar.gz: 66722933fdb17f8317c0989ee103a38479b49ffb151ac23199ad91669a48a693af9ccce2b863dda913c54bc3b9d446ce802b0b4221352dffd68a08de4c647a23
|
data/.rubocop.yml
CHANGED
@@ -58,6 +58,7 @@ Metrics/BlockLength:
|
|
58
58
|
|
59
59
|
Metrics/ClassLength:
|
60
60
|
Exclude:
|
61
|
+
- lib/bcdd/result.rb
|
61
62
|
- test/**/*.rb
|
62
63
|
|
63
64
|
Minitest/MultipleAssertions:
|
@@ -65,3 +66,10 @@ Minitest/MultipleAssertions:
|
|
65
66
|
|
66
67
|
Minitest/AssertEmptyLiteral:
|
67
68
|
Enabled: false
|
69
|
+
|
70
|
+
Minitest/AssertOperator:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
Naming/FileName:
|
74
|
+
Exclude:
|
75
|
+
- lib/bcdd-result.rb
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,147 @@
|
|
1
|
+
- [\[Unreleased\]](#unreleased)
|
2
|
+
- [\[0.9.0\] - 2023-12-12](#090---2023-12-12)
|
3
|
+
- [Added](#added)
|
4
|
+
- [Changed](#changed)
|
5
|
+
- [\[0.8.0\] - 2023-12-11](#080---2023-12-11)
|
6
|
+
- [Added](#added-1)
|
7
|
+
- [Changed](#changed-1)
|
8
|
+
- [Removed](#removed)
|
9
|
+
- [\[0.7.0\] - 2023-10-27](#070---2023-10-27)
|
10
|
+
- [Added](#added-2)
|
11
|
+
- [Changed](#changed-2)
|
12
|
+
- [\[0.6.0\] - 2023-10-11](#060---2023-10-11)
|
13
|
+
- [Added](#added-3)
|
14
|
+
- [Changed](#changed-3)
|
15
|
+
- [\[0.5.0\] - 2023-10-09](#050---2023-10-09)
|
16
|
+
- [Added](#added-4)
|
17
|
+
- [\[0.4.0\] - 2023-09-28](#040---2023-09-28)
|
18
|
+
- [Added](#added-5)
|
19
|
+
- [Changed](#changed-4)
|
20
|
+
- [Removed](#removed-1)
|
21
|
+
- [\[0.3.0\] - 2023-09-26](#030---2023-09-26)
|
22
|
+
- [Added](#added-6)
|
23
|
+
- [\[0.2.0\] - 2023-09-26](#020---2023-09-26)
|
24
|
+
- [Added](#added-7)
|
25
|
+
- [Removed](#removed-2)
|
26
|
+
- [\[0.1.0\] - 2023-09-25](#010---2023-09-25)
|
27
|
+
- [Added](#added-8)
|
28
|
+
|
1
29
|
## [Unreleased]
|
2
30
|
|
31
|
+
## [0.9.0] - 2023-12-12
|
32
|
+
|
33
|
+
### Added
|
34
|
+
|
35
|
+
- Add new `BCDD::Result.config.constant_alias` options. `Context` and `BCDD::Context` are now available as aliases for `BCDD::Result::Context`.
|
36
|
+
```ruby
|
37
|
+
BCDD::Result.config.constant_alias.enable!('Context')
|
38
|
+
|
39
|
+
BCDD::Result.config.constant_alias.enable!('BCDD::Context')
|
40
|
+
```
|
41
|
+
|
42
|
+
- Add `BCDD::Result#halted?` to check if the result is halted. Failure results are halted by default, but you can halt a successful result by enabling the `:continue` addon.
|
43
|
+
|
44
|
+
### Changed
|
45
|
+
|
46
|
+
- **(BREAKING)** Change the `:continue` addon to halt the step chain on the first `Success()` result. So, if you want to advance to the next step, you must use `Continue(value)` instead of `Success(type, value)`. Otherwise, the step chain will be halted. (Implementation of the following proposal: https://github.com/B-CDD/result/issues/14)
|
47
|
+
|
48
|
+
- **(BREAKING)** Rename `BCDD::Result::Data#name` to `BCDD::Result::Data#kind`. The new word is more appropriate as it represents a result's kind (success or failure).
|
49
|
+
|
50
|
+
## [0.8.0] - 2023-12-11
|
51
|
+
|
52
|
+
### Added
|
53
|
+
|
54
|
+
- Add `BCDD::Result.config`
|
55
|
+
- **Feature**
|
56
|
+
```ruby
|
57
|
+
BCDD::Result.config.feature.options
|
58
|
+
BCDD::Result.config.feature.enabled?(:expectations)
|
59
|
+
BCDD::Result.config.feature.enable!(:expectations)
|
60
|
+
BCDD::Result.config.feature.disable!(:expectations)
|
61
|
+
```
|
62
|
+
- **Default Add-ons**
|
63
|
+
```ruby
|
64
|
+
BCDD::Result.config.addon.options
|
65
|
+
BCDD::Result.config.addon.enabled?(:continue)
|
66
|
+
BCDD::Result.config.addon.enable!(:continue)
|
67
|
+
BCDD::Result.config.addon.disable!(:continue)
|
68
|
+
```
|
69
|
+
- **Pattern matching**
|
70
|
+
```ruby
|
71
|
+
BCDD::Result.config.pattern_matching.options
|
72
|
+
BCDD::Result.config.pattern_matching.enabled?(:nil_as_valid_value_checking)
|
73
|
+
BCDD::Result.config.pattern_matching.enable!(:nil_as_valid_value_checking)
|
74
|
+
BCDD::Result.config.pattern_matching.disable!(:nil_as_valid_value_checking)
|
75
|
+
```
|
76
|
+
- **Constant Aliases**
|
77
|
+
```ruby
|
78
|
+
BCDD::Result.config.constant_alias.options
|
79
|
+
BCDD::Result.config.constant_alias.enabled?('Result')
|
80
|
+
BCDD::Result.config.constant_alias.enable!('Result')
|
81
|
+
BCDD::Result.config.constant_alias.disable!('Result')
|
82
|
+
```
|
83
|
+
|
84
|
+
- Add `BCDD::Result::configuration`. It freezes the configuration, disallowing methods that promote changes but allowing the query ones. You can use this feature to ensure integrity in your configuration.
|
85
|
+
```ruby
|
86
|
+
BCDD::Result.configuration do |config|
|
87
|
+
config.addon.enable!(:continue)
|
88
|
+
|
89
|
+
config.constant_alias.enable!('Result')
|
90
|
+
|
91
|
+
config.pattern_matching.disable!(:nil_as_valid_value_checking)
|
92
|
+
|
93
|
+
config.feature.disable!(:expectations) if ::Rails.env.production?
|
94
|
+
end
|
95
|
+
|
96
|
+
BCDD::Result.config.addon.enabled?(:continue) # true
|
97
|
+
BCDD::Result.config.constant_alias.enabled?('Result') # true
|
98
|
+
|
99
|
+
BCDD::Result.config.addon.disable!(:continue) # raises FrozenError
|
100
|
+
BCDD::Result.config.constant_alias.disable!('Result') # raises FrozenError
|
101
|
+
```
|
102
|
+
|
103
|
+
- Allow the pattern matching feature to be turned on/off through the `BCDD::Result::Expectations.mixin`. Now, it can be used without enabling it for the whole project.
|
104
|
+
```ruby
|
105
|
+
extend BCDD::Result::Expectations.mixin(
|
106
|
+
config: {
|
107
|
+
addon: { continue: false },
|
108
|
+
pattern_matching: { nil_as_valid_value_checking: true },
|
109
|
+
},
|
110
|
+
success: {
|
111
|
+
numbers: ->(value) { value => [Numeric, Numeric] },
|
112
|
+
division_completed: Numeric
|
113
|
+
},
|
114
|
+
failure: {
|
115
|
+
invalid_arg: String,
|
116
|
+
division_by_zero: String
|
117
|
+
}
|
118
|
+
)
|
119
|
+
```
|
120
|
+
|
121
|
+
### Changed
|
122
|
+
|
123
|
+
- **(BREAKING)** Replace `BCDD::Result::Contract.nil_as_valid_value_checking!` with `BCDD::Result::Config.pattern_matching.enable!(:nil_as_valid_value_checking)`.
|
124
|
+
|
125
|
+
- **(BREAKING)** Replace `BCDD::Result::Contract.nil_as_valid_value_checking?` with `BCDD::Result::Config.pattern_matching.enabled?(:nil_as_valid_value_checking)`.
|
126
|
+
|
127
|
+
- **(BREAKING)** Replace `mixin(with:)` with `mixin(config:)` keyword argument.
|
128
|
+
|
129
|
+
- **(BREAKING)** Change the addons definition.
|
130
|
+
- **From**
|
131
|
+
```ruby
|
132
|
+
BCDD::Result.mixin(with: :Continue)
|
133
|
+
BCDD::Result.mixin(with: [:Continue])
|
134
|
+
```
|
135
|
+
- **To**
|
136
|
+
```ruby
|
137
|
+
BCDD::Result.mixin(config: { addon: { continue: true } })
|
138
|
+
```
|
139
|
+
- These examples are valid to all kinds of mixins (`BCDD::Result.mixin`, `BCDD::Result::Context.mixin`, `BCDD::Result::Expectations.mixin`, `BCDD::Result::Context::Expectations.mixin`)
|
140
|
+
|
141
|
+
### Removed
|
142
|
+
|
143
|
+
- **(BREAKING)** Remove the `lib/result` file. Now you can define `Result` as an alias for `BCDD::Result` using `BCDD::Result::Config.constant_alias.enable!('Result')`.
|
144
|
+
|
3
145
|
## [0.7.0] - 2023-10-27
|
4
146
|
|
5
147
|
### Added
|