-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
changelog.yml
186 lines (168 loc) · 6.06 KB
/
changelog.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
---
- version: 1.0.0
summary:
date: 2023-01-01
fixed:
added:
changed:
- 'Update dry-core dependency (via #34) (@pnomolos)'
- version: 0.10.0
summary:
date: 2022-11-16
added:
- 'MaybeMatcher for matching against Maybe values from dry-monads (@gabfssilva)
in #33'
changed:
- This version is compatible with recently released dry-rb dependencies (@flash-gordon)
- version: 0.9.0
summary:
date: 2021-03-05
changed:
- 'Matcher evaluator is now a standard `Object` descendant (see #32) (@solnic)'
- version: 0.8.3
date: '2020-01-07'
fixed:
- Delegation warnings about keyword arguments (flash-gordon)
- version: 0.8.2
date: '2019-09-06'
fixed:
- Minimal dry-core version set to 0.4.8 (flash-gordon)
- version: 0.8.1
date: '2019-08-13'
added:
- |-
`Dry::Matcher#for` is a shortcut for `Dry::Matcher.for(..., with: matcher)` (flash-gordon)
```ruby
require 'dry/matcher/result_matcher'
class CreateUser
include Dry::Matcher::ResultMatcher.for(:call)
def call(...)
# code returning an instance of Dry::Monads::Result
end
end
```
- version: 0.8.0
date: '2019-07-30'
changed:
- "[BREAKING] Support for Ruby 2.3 was dropped as it's EOL"
added:
- |-
API for cases was changed to work with a single block instead of `match`/`resolve` combination (flash-gordon in [#23](https://github.com/dry-rb/dry-matcher/pull/23)):
```ruby
Dry::Matcher::Case.new do |value, patterns|
if patterns.include?(value)
# value will be passed to the block
value
else
# Undefined stands for no match
Dry::Matcher::Undefined
end
end
```
- |-
`ResultMatcher` now uses patterns for matching and matches against the first element if an array is passed (flash-gordon in [#24](https://github.com/dry-rb/dry-matcher/pull/24) and [#22](https://github.com/dry-rb/dry-matcher/pull/22) and michaelherold in [#21](https://github.com/dry-rb/dry-matcher/pull/21))
```ruby
value = Dry::Monads::Result::Failure.new([:invalid, :reasons])
Dry::Matcher::ResultMatcher.(value) do |m|
m.success do |v|
"Yay: #{v}"
end
m.failure(:not_found) do
"No such thing"
end
m.failure(:invalid) do |_code, errors|
"Cannot be done: #{errors.inspect}"
end
end #=> "Cannot be done: :reasons"
```
- version: 0.7.0
date: '2018-01-11'
changed:
- "`EitherMatcher` was renamed to `ResultMatcher` according to match the rename
of `Either` to `Result` in dry-monads 0.4.0. The previous name is still there
for backward compatibility, we'll deprecate and drop it in furure releases (flash-gordon
in [#13](https://github.com/dry-rb/dry-matcher/pull/13))"
- version: 0.6.0
date: '2016-12-19'
added:
- API documentation for most methods (alsemyonov in [#8](https://github.com/dry-rb/dry-matcher/pull/8))
changed:
- Matches must now be exhaustive - when matching against a value, at least one match
block must be provided for each of a matcher's cases (timriley in [#7](https://github.com/dry-rb/dry-matcher/pull/7))
- "`Dry::Matcher::Case` objects can now be created without a `resolve:` proc. In
this case, a default will be provided that passes the result value through (timriley
in [#9](https://github.com/dry-rb/dry-matcher/pull/9))"
fixed:
- Fixed handling of calls to non-existent cases within a matcher block (timriley)
- version: 0.5.0
date: '2016-06-30'
added:
- |-
Added support for building custom matchers, with an any number of match cases, each offering their own matching and resolving logic. This is now the primary API for dry-matcher. (timriley)
```ruby
# Match `[:ok, some_value]` for success
success_case = Dry::Matcher::Case.new(
match: -> value { value.first == :ok },
resolve: -> value { value.last }
)
# Match `[:err, some_error_code, some_value]` for failure
failure_case = Dry::Matcher::Case.new(
match: -> value, *pattern {
value[0] == :err && (pattern.any? ? pattern.include?(value[1]) : true)
},
resolve: -> value { value.last }
)
# Build the matcher
matcher = Dry::Matcher.new(success: success_case, failure: failure_case)
# Then put it to use
my_success = [:ok, "success!"]
result = matcher.(my_success) do |m|
m.success do |v|
"Yay: #{v}"
end
m.failure :not_found do |v|
"Oops, not found: #{v}"
end
m.failure do |v|
"Boo: #{v}"
end
end
result # => "Yay: success!"
```
changed:
- Renamed to `dry-matcher`, since this is now a flexible, general purpose pattern
matching API. All components are now available under the `Dry::Matcher` namespace.
(timriley)
- |-
`Dry::Matcher.for` requires a matcher object to be passed when being included in a class:
```ruby
MyMatcher = Dry::Matcher.new(...)
class MyOperation
include Dry::Matcher.for(:call, with: MyMatcher)
def call
end
end
```
- The previous `Dry::ResultMatcher.match` behaviour (for matching `Either` monads)
has been moved to `Dry::Matcher::EitherMatcher.call`
- version: 0.4.0
date: '2016-06-08'
added:
- Support convertible result objects responding to `#to_either` (ttdonovan)
changed:
- Expect monads from [dry-monads](https://github.com/dry-rb/dry-monads) instead
of [Kleisli](https://github.com/txus/kleisli) (ttdonovan)
- version: 0.3.0
date: '2016-03-23'
changed:
- Renamed to `dry-result_matcher`. Match results using `Dry::ResultMatcher.match`
or extend your own classes with `Dry::ResultMatcher.for`.
- version: 0.2.0
date: '2016-02-10'
added:
- 'Added `EitherResultMatcher.for(*methods)` to return a module wrapping the specified
methods (returning an `Either`) with the match block API. Example usage, in a
class with a `#call` method: `include EitherResultMatcher.for(:call)`.'
- version: 0.1.0
date: '2015-12-03'
summary: Initial release.