bcdd-result 0.7.0 → 0.8.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 +7 -0
- data/CHANGELOG.md +120 -0
- data/README.md +315 -133
- data/Rakefile +9 -3
- data/Steepfile +1 -1
- data/lib/bcdd/result/config/constant_alias.rb +33 -0
- data/lib/bcdd/result/config/options.rb +26 -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 +7 -23
- data/lib/bcdd/result/context/mixin.rb +12 -9
- data/lib/bcdd/result/contract/for_types_and_values.rb +7 -2
- data/lib/bcdd/result/contract.rb +4 -14
- data/lib/bcdd/result/expectations/mixin.rb +12 -10
- data/lib/bcdd/result/expectations.rb +31 -7
- data/lib/bcdd/result/mixin.rb +27 -14
- data/lib/bcdd/result/version.rb +1 -1
- data/lib/bcdd/result.rb +11 -0
- data/lib/bcdd-result.rb +3 -0
- data/sig/bcdd/result.rbs +146 -38
- 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: 2b49559a4258169692f89f3263c14485cde2e17e36c90ccde9bf88dab355d458
|
4
|
+
data.tar.gz: b62c215886f572f942a752767db89544ae5e483a496975882fcc9108d99edc0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2794daec03ab43d9d9549887dae87d0138195f0c85f65ddcc1015d74a9a940c639e7dc73086c9f948de00c8ce95d576105a3ad9e671b068d56d39e4ef075c3ff
|
7
|
+
data.tar.gz: 197572b1a2dc61a72de744af1bbb50a642731dc4e248133164da36fb8ff8d257fe89c2874798ea9f77533aa462e386dd002cc2dd25f241ca12cd02ff8d080fa4
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,125 @@
|
|
1
|
+
- [\[Unreleased\]](#unreleased)
|
2
|
+
- [\[0.8.0\] - 2023-12-11](#080---2023-12-11)
|
3
|
+
- [Added](#added)
|
4
|
+
- [Changed](#changed)
|
5
|
+
- [Removed](#removed)
|
6
|
+
- [\[0.7.0\] - 2023-10-27](#070---2023-10-27)
|
7
|
+
- [Added](#added-1)
|
8
|
+
- [Changed](#changed-1)
|
9
|
+
- [\[0.6.0\] - 2023-10-11](#060---2023-10-11)
|
10
|
+
- [Added](#added-2)
|
11
|
+
- [Changed](#changed-2)
|
12
|
+
- [\[0.5.0\] - 2023-10-09](#050---2023-10-09)
|
13
|
+
- [Added](#added-3)
|
14
|
+
- [\[0.4.0\] - 2023-09-28](#040---2023-09-28)
|
15
|
+
- [Added](#added-4)
|
16
|
+
- [Changed](#changed-3)
|
17
|
+
- [Removed](#removed-1)
|
18
|
+
- [\[0.3.0\] - 2023-09-26](#030---2023-09-26)
|
19
|
+
- [Added](#added-5)
|
20
|
+
- [\[0.2.0\] - 2023-09-26](#020---2023-09-26)
|
21
|
+
- [Added](#added-6)
|
22
|
+
- [Removed](#removed-2)
|
23
|
+
- [\[0.1.0\] - 2023-09-25](#010---2023-09-25)
|
24
|
+
- [Added](#added-7)
|
25
|
+
|
1
26
|
## [Unreleased]
|
2
27
|
|
28
|
+
## [0.8.0] - 2023-12-11
|
29
|
+
|
30
|
+
### Added
|
31
|
+
|
32
|
+
- Add `BCDD::Result.config`
|
33
|
+
- **Feature**
|
34
|
+
```ruby
|
35
|
+
BCDD::Result.config.feature.options
|
36
|
+
BCDD::Result.config.feature.enabled?(:expectations)
|
37
|
+
BCDD::Result.config.feature.enable!(:expectations)
|
38
|
+
BCDD::Result.config.feature.disable!(:expectations)
|
39
|
+
```
|
40
|
+
- **Default Add-ons**
|
41
|
+
```ruby
|
42
|
+
BCDD::Result.config.addon.options
|
43
|
+
BCDD::Result.config.addon.enabled?(:continue)
|
44
|
+
BCDD::Result.config.addon.enable!(:continue)
|
45
|
+
BCDD::Result.config.addon.disable!(:continue)
|
46
|
+
```
|
47
|
+
- **Pattern matching**
|
48
|
+
```ruby
|
49
|
+
BCDD::Result.config.pattern_matching.options
|
50
|
+
BCDD::Result.config.pattern_matching.enabled?(:nil_as_valid_value_checking)
|
51
|
+
BCDD::Result.config.pattern_matching.enable!(:nil_as_valid_value_checking)
|
52
|
+
BCDD::Result.config.pattern_matching.disable!(:nil_as_valid_value_checking)
|
53
|
+
```
|
54
|
+
- **Constant Aliases**
|
55
|
+
```ruby
|
56
|
+
BCDD::Result.config.constant_alias.options
|
57
|
+
BCDD::Result.config.constant_alias.enabled?('Result')
|
58
|
+
BCDD::Result.config.constant_alias.enable!('Result')
|
59
|
+
BCDD::Result.config.constant_alias.disable!('Result')
|
60
|
+
```
|
61
|
+
|
62
|
+
- 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.
|
63
|
+
```ruby
|
64
|
+
BCDD::Result.configuration do |config|
|
65
|
+
config.addon.enable!(:continue)
|
66
|
+
|
67
|
+
config.constant_alias.enable!('Result')
|
68
|
+
|
69
|
+
config.pattern_matching.disable!(:nil_as_valid_value_checking)
|
70
|
+
|
71
|
+
config.feature.disable!(:expectations) if ::Rails.env.production?
|
72
|
+
end
|
73
|
+
|
74
|
+
BCDD::Result.config.addon.enabled?(:continue) # true
|
75
|
+
BCDD::Result.config.constant_alias.enabled?('Result') # true
|
76
|
+
|
77
|
+
BCDD::Result.config.addon.disable!(:continue) # raises FrozenError
|
78
|
+
BCDD::Result.config.constant_alias.disable!('Result') # raises FrozenError
|
79
|
+
```
|
80
|
+
|
81
|
+
- 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.
|
82
|
+
```ruby
|
83
|
+
extend BCDD::Result::Expectations.mixin(
|
84
|
+
config: {
|
85
|
+
addon: { continue: false },
|
86
|
+
pattern_matching: { nil_as_valid_value_checking: true },
|
87
|
+
},
|
88
|
+
success: {
|
89
|
+
numbers: ->(value) { value => [Numeric, Numeric] },
|
90
|
+
division_completed: Numeric
|
91
|
+
},
|
92
|
+
failure: {
|
93
|
+
invalid_arg: String,
|
94
|
+
division_by_zero: String
|
95
|
+
}
|
96
|
+
)
|
97
|
+
```
|
98
|
+
|
99
|
+
### Changed
|
100
|
+
|
101
|
+
- **(BREAKING)** Replace `BCDD::Result::Contract.nil_as_valid_value_checking!` with `BCDD::Result::Config.pattern_matching.enable!(:nil_as_valid_value_checking)`.
|
102
|
+
|
103
|
+
- **(BREAKING)** Replace `BCDD::Result::Contract.nil_as_valid_value_checking?` with `BCDD::Result::Config.pattern_matching.enabled?(:nil_as_valid_value_checking)`.
|
104
|
+
|
105
|
+
- **(BREAKING)** Replace `mixin(with:)` with `mixin(config:)` keyword argument.
|
106
|
+
|
107
|
+
- **(BREAKING)** Change the addons definition.
|
108
|
+
- **From**
|
109
|
+
```ruby
|
110
|
+
BCDD::Result.mixin(with: :Continue)
|
111
|
+
BCDD::Result.mixin(with: [:Continue])
|
112
|
+
```
|
113
|
+
- **To**
|
114
|
+
```ruby
|
115
|
+
BCDD::Result.mixin(config: { addon: { continue: true } })
|
116
|
+
```
|
117
|
+
- 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`)
|
118
|
+
|
119
|
+
### Removed
|
120
|
+
|
121
|
+
- **(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')`.
|
122
|
+
|
3
123
|
## [0.7.0] - 2023-10-27
|
4
124
|
|
5
125
|
### Added
|