dry-matcher 0.8.3 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +57 -33
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/dry-matcher.gemspec +22 -15
- data/lib/dry-matcher.rb +1 -1
- data/lib/dry/matcher.rb +3 -3
- data/lib/dry/matcher/evaluator.rb +1 -1
- data/lib/dry/matcher/version.rb +1 -1
- metadata +21 -32
- data/.codeclimate.yml +0 -12
- data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +0 -10
- data/.github/ISSUE_TEMPLATE/---bug-report.md +0 -30
- data/.github/ISSUE_TEMPLATE/---feature-request.md +0 -18
- data/.github/workflows/ci.yml +0 -52
- data/.github/workflows/docsite.yml +0 -34
- data/.github/workflows/sync_configs.yml +0 -56
- data/.gitignore +0 -8
- data/.rspec +0 -4
- data/.rubocop.yml +0 -101
- data/.yardopts +0 -1
- data/CODE_OF_CONDUCT.md +0 -13
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -18
- data/Gemfile.devtools +0 -14
- data/LICENSE.md +0 -9
- data/Rakefile +0 -8
- data/docsite/source/class-enhancement.html.md +0 -30
- data/docsite/source/index.html.md +0 -89
- data/docsite/source/result-matcher.html.md +0 -34
- data/project.yml +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b0215bfb6c841e25bcd167ebf29b6dd05c642926c04bb253cabe5a3d430ee27
|
4
|
+
data.tar.gz: 6a69936b8ce9b3edfd22653c0e358f8c6d1149064a74782661b8a251e306ba86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0641213eab8f65143040b0c6a61913415822e34fa985ff68a3efae84e4a21ffeb04675ad4ba5aaf7476cfd7d4bc89128f5faec7d705d36f8d262a0b131d2c76
|
7
|
+
data.tar.gz: 5b42966da62e0b5665ca89c20aaef62683a9e52e4fae91ae4eb852f9e2900f417800f5ce5ca82ccf3e5403d39ce54af7862942e7ee4fda12215eee297450c21f
|
data/CHANGELOG.md
CHANGED
@@ -1,22 +1,38 @@
|
|
1
|
-
|
1
|
+
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
2
|
|
3
|
-
##
|
3
|
+
## 0.9.0 2021-03-05
|
4
|
+
|
5
|
+
|
6
|
+
### Changed
|
7
|
+
|
8
|
+
- Matcher evaluator is now a standard `Object` descendant (see #32) (@solnic)
|
9
|
+
|
10
|
+
[Compare v0.8.3...v0.9.0](https://github.com/dry-rb/dry-matcher/compare/v0.8.3...v0.9.0)
|
11
|
+
|
12
|
+
## 0.8.3 2020-01-07
|
13
|
+
|
14
|
+
|
15
|
+
### Fixed
|
4
16
|
|
5
17
|
- Delegation warnings about keyword arguments (flash-gordon)
|
6
18
|
|
19
|
+
|
7
20
|
[Compare v0.8.2...v0.8.3](https://github.com/dry-rb/dry-matcher/compare/v0.8.2...v0.8.3)
|
8
21
|
|
9
|
-
|
22
|
+
## 0.8.2 2019-09-06
|
10
23
|
|
11
|
-
|
24
|
+
|
25
|
+
### Fixed
|
12
26
|
|
13
27
|
- Minimal dry-core version set to 0.4.8 (flash-gordon)
|
14
28
|
|
29
|
+
|
15
30
|
[Compare v0.8.1...v0.8.2](https://github.com/dry-rb/dry-matcher/compare/v0.8.1...v0.8.2)
|
16
31
|
|
17
|
-
|
32
|
+
## 0.8.1 2019-08-13
|
18
33
|
|
19
|
-
|
34
|
+
|
35
|
+
### Added
|
20
36
|
|
21
37
|
- `Dry::Matcher#for` is a shortcut for `Dry::Matcher.for(..., with: matcher)` (flash-gordon)
|
22
38
|
|
@@ -32,15 +48,13 @@
|
|
32
48
|
end
|
33
49
|
```
|
34
50
|
|
35
|
-
[Compare v0.8.0...v0.8.1](https://github.com/dry-rb/dry-matcher/compare/v0.8.0...v0.8.1)
|
36
51
|
|
37
|
-
|
52
|
+
[Compare v0.8.0...v0.8.1](https://github.com/dry-rb/dry-matcher/compare/v0.8.0...v0.8.1)
|
38
53
|
|
39
|
-
##
|
54
|
+
## 0.8.0 2019-07-30
|
40
55
|
|
41
|
-
- [BREAKING] Support for Ruby 2.3 was dropped as it's EOL
|
42
56
|
|
43
|
-
|
57
|
+
### Added
|
44
58
|
|
45
59
|
- 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)):
|
46
60
|
```ruby
|
@@ -74,36 +88,43 @@
|
|
74
88
|
end #=> "Cannot be done: :reasons"
|
75
89
|
```
|
76
90
|
|
91
|
+
### Changed
|
92
|
+
|
93
|
+
- [BREAKING] Support for Ruby 2.3 was dropped as it's EOL
|
94
|
+
|
77
95
|
[Compare v0.7.0...v0.8.0](https://github.com/dry-rb/dry-matcher/compare/v0.7.0...v0.8.0)
|
78
96
|
|
79
|
-
|
97
|
+
## 0.7.0 2018-01-11
|
98
|
+
|
80
99
|
|
81
|
-
|
100
|
+
### Changed
|
82
101
|
|
83
102
|
- `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))
|
84
103
|
|
85
104
|
[Compare v0.6.0...v0.7.0](https://github.com/dry-rb/dry-matcher/compare/v0.6.0...v0.7.0)
|
86
105
|
|
87
|
-
|
106
|
+
## 0.6.0 2016-12-19
|
88
107
|
|
89
|
-
|
108
|
+
|
109
|
+
### Added
|
90
110
|
|
91
111
|
- API documentation for most methods (alsemyonov in [#8](https://github.com/dry-rb/dry-matcher/pull/8))
|
92
112
|
|
93
|
-
|
113
|
+
### Fixed
|
94
114
|
|
95
|
-
-
|
96
|
-
- `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))
|
115
|
+
- Fixed handling of calls to non-existent cases within a matcher block (timriley)
|
97
116
|
|
98
|
-
|
117
|
+
### Changed
|
99
118
|
|
100
|
-
-
|
119
|
+
- 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))
|
120
|
+
- `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))
|
101
121
|
|
102
122
|
[Compare v0.5.0...v0.6.0](https://github.com/dry-rb/dry-matcher/compare/v0.5.0...v0.6.0)
|
103
123
|
|
104
|
-
|
124
|
+
## 0.5.0 2016-06-30
|
125
|
+
|
105
126
|
|
106
|
-
|
127
|
+
### Added
|
107
128
|
|
108
129
|
- 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)
|
109
130
|
|
@@ -145,7 +166,7 @@
|
|
145
166
|
result # => "Yay: success!"
|
146
167
|
```
|
147
168
|
|
148
|
-
|
169
|
+
### Changed
|
149
170
|
|
150
171
|
- 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)
|
151
172
|
- `Dry::Matcher.for` requires a matcher object to be passed when being included in a class:
|
@@ -160,39 +181,42 @@
|
|
160
181
|
end
|
161
182
|
end
|
162
183
|
```
|
163
|
-
|
164
184
|
- The previous `Dry::ResultMatcher.match` behaviour (for matching `Either` monads) has been moved to `Dry::Matcher::EitherMatcher.call`
|
165
185
|
|
166
186
|
[Compare v0.4.0...v0.5.0](https://github.com/dry-rb/dry-matcher/compare/v0.4.0...v0.5.0)
|
167
187
|
|
168
|
-
|
188
|
+
## 0.4.0 2016-06-08
|
189
|
+
|
169
190
|
|
170
|
-
|
191
|
+
### Added
|
171
192
|
|
172
193
|
- Support convertible result objects responding to `#to_either` (ttdonovan)
|
173
194
|
|
174
|
-
|
195
|
+
### Changed
|
175
196
|
|
176
197
|
- Expect monads from [dry-monads](https://github.com/dry-rb/dry-monads) instead of [Kleisli](https://github.com/txus/kleisli) (ttdonovan)
|
177
198
|
|
178
199
|
[Compare v0.3.0...v0.4.0](https://github.com/dry-rb/dry-matcher/compare/v0.3.0...v0.4.0)
|
179
200
|
|
180
|
-
|
201
|
+
## 0.3.0 2016-03-23
|
181
202
|
|
182
|
-
|
203
|
+
|
204
|
+
### Changed
|
183
205
|
|
184
206
|
- Renamed to `dry-result_matcher`. Match results using `Dry::ResultMatcher.match` or extend your own classes with `Dry::ResultMatcher.for`.
|
185
207
|
|
186
208
|
[Compare v0.2.0...v0.3.0](https://github.com/dry-rb/dry-matcher/compare/v0.2.0...v0.3.0)
|
187
209
|
|
188
|
-
|
210
|
+
## 0.2.0 2016-02-10
|
211
|
+
|
189
212
|
|
190
|
-
|
213
|
+
### Added
|
191
214
|
|
192
215
|
- 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)`.
|
193
216
|
|
194
|
-
[Compare v0.1.0...v0.22.0](https://github.com/dry-rb/dry-matcher/compare/v0.1.0...v0.2.0)
|
195
217
|
|
196
|
-
|
218
|
+
[Compare v0.1.0...v0.2.0](https://github.com/dry-rb/dry-matcher/compare/v0.1.0...v0.2.0)
|
219
|
+
|
220
|
+
## 0.1.0 2015-12-03
|
197
221
|
|
198
222
|
Initial release.
|
data/LICENSE
CHANGED
data/README.md
CHANGED
data/dry-matcher.gemspec
CHANGED
@@ -1,27 +1,34 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
# this file is managed by dry-rb/devtools project
|
2
3
|
|
3
4
|
lib = File.expand_path('lib', __dir__)
|
4
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
6
|
require 'dry/matcher/version'
|
6
7
|
|
7
8
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
spec.
|
12
|
-
spec.
|
9
|
+
spec.name = 'dry-matcher'
|
10
|
+
spec.authors = ["Tim Riley", "Nikita Shilnikov"]
|
11
|
+
spec.email = ["tim@icelab.com.au", "fg@flashgordon.ru"]
|
12
|
+
spec.license = 'MIT'
|
13
|
+
spec.version = Dry::Matcher::VERSION.dup
|
13
14
|
|
14
|
-
spec.summary
|
15
|
-
spec.description
|
16
|
-
spec.homepage
|
17
|
-
|
18
|
-
spec.
|
19
|
-
spec.
|
20
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
15
|
+
spec.summary = "Flexible, expressive pattern matching for Ruby"
|
16
|
+
spec.description = spec.summary
|
17
|
+
spec.homepage = 'https://dry-rb.org/gems/dry-matcher'
|
18
|
+
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-matcher.gemspec", "lib/**/*"]
|
19
|
+
spec.bindir = 'bin'
|
20
|
+
spec.executables = []
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
-
spec.
|
23
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
24
|
+
spec.metadata['changelog_uri'] = 'https://github.com/dry-rb/dry-matcher/blob/master/CHANGELOG.md'
|
25
|
+
spec.metadata['source_code_uri'] = 'https://github.com/dry-rb/dry-matcher'
|
26
|
+
spec.metadata['bug_tracker_uri'] = 'https://github.com/dry-rb/dry-matcher/issues'
|
27
|
+
|
28
|
+
spec.required_ruby_version = ">= 2.5.0"
|
29
|
+
|
30
|
+
# to update dependencies edit project.yml
|
31
|
+
spec.add_runtime_dependency "dry-core", "~> 0.4", ">= 0.4.8"
|
24
32
|
|
25
|
-
spec.
|
26
|
-
spec.add_development_dependency 'rake', '~> 13.0'
|
33
|
+
spec.add_development_dependency "rake"
|
27
34
|
end
|
data/lib/dry-matcher.rb
CHANGED
data/lib/dry/matcher.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "dry/core/constants"
|
4
|
+
require "dry/matcher/case"
|
5
|
+
require "dry/matcher/evaluator"
|
6
6
|
|
7
7
|
module Dry
|
8
8
|
# @see http://dry-rb.org/gems/dry-matcher
|
@@ -5,7 +5,7 @@ module Dry
|
|
5
5
|
NonExhaustiveMatchError = Class.new(StandardError)
|
6
6
|
|
7
7
|
# {Evaluator} is used in {Dry::Matcher#call Dry::Matcher#call} block to handle different {Case}s
|
8
|
-
class Evaluator
|
8
|
+
class Evaluator
|
9
9
|
# @param [Object] result
|
10
10
|
# @param [Hash{Symbol => Case}] cases
|
11
11
|
def initialize(result, cases)
|
data/lib/dry/matcher/version.rb
CHANGED
metadata
CHANGED
@@ -1,20 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-matcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Riley
|
8
8
|
- Nikita Shilnikov
|
9
9
|
autorequire:
|
10
|
-
bindir:
|
10
|
+
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-03-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dry-core
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.4'
|
18
21
|
- - ">="
|
19
22
|
- !ruby/object:Gem::Version
|
20
23
|
version: 0.4.8
|
@@ -22,6 +25,9 @@ dependencies:
|
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
28
|
+
- - "~>"
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0.4'
|
25
31
|
- - ">="
|
26
32
|
- !ruby/object:Gem::Version
|
27
33
|
version: 0.4.8
|
@@ -29,16 +35,16 @@ dependencies:
|
|
29
35
|
name: rake
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
31
37
|
requirements:
|
32
|
-
- - "
|
38
|
+
- - ">="
|
33
39
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
40
|
+
version: '0'
|
35
41
|
type: :development
|
36
42
|
prerelease: false
|
37
43
|
version_requirements: !ruby/object:Gem::Requirement
|
38
44
|
requirements:
|
39
|
-
- - "
|
45
|
+
- - ">="
|
40
46
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
47
|
+
version: '0'
|
42
48
|
description: Flexible, expressive pattern matching for Ruby
|
43
49
|
email:
|
44
50
|
- tim@icelab.com.au
|
@@ -47,29 +53,9 @@ executables: []
|
|
47
53
|
extensions: []
|
48
54
|
extra_rdoc_files: []
|
49
55
|
files:
|
50
|
-
- ".codeclimate.yml"
|
51
|
-
- ".github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md"
|
52
|
-
- ".github/ISSUE_TEMPLATE/---bug-report.md"
|
53
|
-
- ".github/ISSUE_TEMPLATE/---feature-request.md"
|
54
|
-
- ".github/workflows/ci.yml"
|
55
|
-
- ".github/workflows/docsite.yml"
|
56
|
-
- ".github/workflows/sync_configs.yml"
|
57
|
-
- ".gitignore"
|
58
|
-
- ".rspec"
|
59
|
-
- ".rubocop.yml"
|
60
|
-
- ".yardopts"
|
61
56
|
- CHANGELOG.md
|
62
|
-
- CODE_OF_CONDUCT.md
|
63
|
-
- CONTRIBUTING.md
|
64
|
-
- Gemfile
|
65
|
-
- Gemfile.devtools
|
66
57
|
- LICENSE
|
67
|
-
- LICENSE.md
|
68
58
|
- README.md
|
69
|
-
- Rakefile
|
70
|
-
- docsite/source/class-enhancement.html.md
|
71
|
-
- docsite/source/index.html.md
|
72
|
-
- docsite/source/result-matcher.html.md
|
73
59
|
- dry-matcher.gemspec
|
74
60
|
- lib/dry-matcher.rb
|
75
61
|
- lib/dry/matcher.rb
|
@@ -78,11 +64,14 @@ files:
|
|
78
64
|
- lib/dry/matcher/evaluator.rb
|
79
65
|
- lib/dry/matcher/result_matcher.rb
|
80
66
|
- lib/dry/matcher/version.rb
|
81
|
-
-
|
82
|
-
homepage: http://dry-rb.org/gems/dry-matcher
|
67
|
+
homepage: https://dry-rb.org/gems/dry-matcher
|
83
68
|
licenses:
|
84
69
|
- MIT
|
85
|
-
metadata:
|
70
|
+
metadata:
|
71
|
+
allowed_push_host: https://rubygems.org
|
72
|
+
changelog_uri: https://github.com/dry-rb/dry-matcher/blob/master/CHANGELOG.md
|
73
|
+
source_code_uri: https://github.com/dry-rb/dry-matcher
|
74
|
+
bug_tracker_uri: https://github.com/dry-rb/dry-matcher/issues
|
86
75
|
post_install_message:
|
87
76
|
rdoc_options: []
|
88
77
|
require_paths:
|
@@ -91,14 +80,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
80
|
requirements:
|
92
81
|
- - ">="
|
93
82
|
- !ruby/object:Gem::Version
|
94
|
-
version: 2.
|
83
|
+
version: 2.5.0
|
95
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
85
|
requirements:
|
97
86
|
- - ">="
|
98
87
|
- !ruby/object:Gem::Version
|
99
88
|
version: '0'
|
100
89
|
requirements: []
|
101
|
-
rubygems_version: 3.1.
|
90
|
+
rubygems_version: 3.1.4
|
102
91
|
signing_key:
|
103
92
|
specification_version: 4
|
104
93
|
summary: Flexible, expressive pattern matching for Ruby
|
data/.codeclimate.yml
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: "\U0001F41B Bug report"
|
3
|
-
about: See CONTRIBUTING.md for more information
|
4
|
-
title: ''
|
5
|
-
labels: bug
|
6
|
-
assignees: ''
|
7
|
-
|
8
|
-
---
|
9
|
-
|
10
|
-
**Before you submit this: WE ONLY ACCEPT BUG REPORTS AND FEATURE REQUESTS**
|
11
|
-
|
12
|
-
For more information see `CONTRIBUTING.md`.
|
13
|
-
|
14
|
-
**Describe the bug**
|
15
|
-
|
16
|
-
A clear and concise description of what the bug is.
|
17
|
-
|
18
|
-
**To Reproduce**
|
19
|
-
|
20
|
-
Provide detailed steps to reproduce, an executable script would be best.
|
21
|
-
|
22
|
-
**Expected behavior**
|
23
|
-
|
24
|
-
A clear and concise description of what you expected to happen.
|
25
|
-
|
26
|
-
**Your environment**
|
27
|
-
|
28
|
-
- Affects my production application: **YES/NO**
|
29
|
-
- Ruby version: ...
|
30
|
-
- OS: ...
|
@@ -1,18 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: "\U0001F6E0 Feature request"
|
3
|
-
about: See CONTRIBUTING.md for more information
|
4
|
-
title: ''
|
5
|
-
labels: feature
|
6
|
-
assignees: ''
|
7
|
-
|
8
|
-
---
|
9
|
-
|
10
|
-
Summary of what the feature is supposed to do.
|
11
|
-
|
12
|
-
## Examples
|
13
|
-
|
14
|
-
Code examples showing how the feature could be used.
|
15
|
-
|
16
|
-
## Resources
|
17
|
-
|
18
|
-
Additional information, like a link to the discussion forum thread where the feature was discussed etc.
|
data/.github/workflows/ci.yml
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
# this file is managed by dry-rb/devtools project
|
2
|
-
|
3
|
-
name: ci
|
4
|
-
|
5
|
-
on:
|
6
|
-
push:
|
7
|
-
paths:
|
8
|
-
- .github/workflows/ci.yml
|
9
|
-
- lib/**
|
10
|
-
- spec/**
|
11
|
-
- Rakefile
|
12
|
-
- Gemfile
|
13
|
-
- Gemfile.devtools
|
14
|
-
- "*.gemspec"
|
15
|
-
- ".rubocop.yml"
|
16
|
-
pull_request:
|
17
|
-
branches:
|
18
|
-
- master
|
19
|
-
|
20
|
-
jobs:
|
21
|
-
tests:
|
22
|
-
runs-on: ubuntu-latest
|
23
|
-
strategy:
|
24
|
-
fail-fast: false
|
25
|
-
matrix:
|
26
|
-
ruby:
|
27
|
-
- "2.7"
|
28
|
-
- "2.6"
|
29
|
-
- "2.5"
|
30
|
-
- "2.4"
|
31
|
-
- "jruby"
|
32
|
-
include:
|
33
|
-
- ruby: "2.6"
|
34
|
-
coverage: "true"
|
35
|
-
steps:
|
36
|
-
- uses: actions/checkout@v1
|
37
|
-
- name: Set up Ruby
|
38
|
-
uses: eregon/use-ruby-action@master
|
39
|
-
with:
|
40
|
-
ruby-version: ${{matrix.ruby}}
|
41
|
-
- name: Install latest bundler
|
42
|
-
run: |
|
43
|
-
gem install bundler
|
44
|
-
bundle config set without 'tools benchmarks docs'
|
45
|
-
- name: Bundle install
|
46
|
-
run: bundle install --jobs 4 --retry 3
|
47
|
-
- name: Run all tests
|
48
|
-
env:
|
49
|
-
COVERAGE: ${{matrix.coverage}}
|
50
|
-
CODACY_RUN_LOCAL: true
|
51
|
-
CODACY_PROJECT_TOKEN: ${{secrets.CODACY_PROJECT_TOKEN}}
|
52
|
-
run: bundle exec rake
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# this file is managed by dry-rb/devtools project
|
2
|
-
|
3
|
-
name: docsite
|
4
|
-
|
5
|
-
on:
|
6
|
-
push:
|
7
|
-
paths:
|
8
|
-
- docsite/**
|
9
|
-
- .github/workflows/docsite.yml
|
10
|
-
branches:
|
11
|
-
- master
|
12
|
-
- release-**
|
13
|
-
tags:
|
14
|
-
|
15
|
-
jobs:
|
16
|
-
update-docs:
|
17
|
-
runs-on: ubuntu-latest
|
18
|
-
steps:
|
19
|
-
- uses: actions/checkout@v1
|
20
|
-
- name: Set up Ruby
|
21
|
-
uses: actions/setup-ruby@v1
|
22
|
-
with:
|
23
|
-
ruby-version: "2.6.x"
|
24
|
-
- name: Install dependencies
|
25
|
-
run: |
|
26
|
-
gem install bundler
|
27
|
-
bundle install --jobs 4 --retry 3 --without benchmarks sql
|
28
|
-
- name: Symlink ossy
|
29
|
-
run: mkdir -p bin && ln -sf "$(bundle show ossy)/bin/ossy" bin/ossy
|
30
|
-
- name: Trigger dry-rb.org deploy
|
31
|
-
env:
|
32
|
-
GITHUB_LOGIN: dry-bot
|
33
|
-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
34
|
-
run: bin/ossy github workflow dry-rb/dry-rb.org ci
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# this file is managed by dry-rb/devtools project
|
2
|
-
|
3
|
-
name: sync_configs
|
4
|
-
|
5
|
-
on:
|
6
|
-
repository_dispatch:
|
7
|
-
|
8
|
-
jobs:
|
9
|
-
sync-configs:
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
if: github.event.action == 'sync_configs'
|
12
|
-
steps:
|
13
|
-
- uses: actions/checkout@v1
|
14
|
-
- name: Set up Ruby
|
15
|
-
uses: eregon/use-ruby-action@master
|
16
|
-
with:
|
17
|
-
ruby-version: 2.6
|
18
|
-
- name: Install latest bundler
|
19
|
-
run: |
|
20
|
-
gem install bundler
|
21
|
-
bundle config set without 'tools benchmarks docs'
|
22
|
-
- name: Install dependencies
|
23
|
-
run: bundle install --jobs 4 --retry 3 --without tools test benchmarks docs
|
24
|
-
- name: Symlink ossy
|
25
|
-
run: ln -sf "$(bundle info ossy --path)/bin/ossy" bin/ossy
|
26
|
-
- name: Clone devtools
|
27
|
-
run: git clone https://github.com/dry-rb/devtools.git tmp/devtools
|
28
|
-
- name: Compile file templates
|
29
|
-
env:
|
30
|
-
GITHUB_LOGIN: dry-bot
|
31
|
-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
32
|
-
run: |
|
33
|
-
if [ -f "project.yml" ]; then
|
34
|
-
for t in `ls tmp/devtools/templates`
|
35
|
-
do
|
36
|
-
bin/ossy t c tmp/devtools/templates/$t $(basename $t .erb) project.yml
|
37
|
-
done
|
38
|
-
fi
|
39
|
-
- name: Update configuration files from devtools
|
40
|
-
run: |
|
41
|
-
if [ -f ".github/workflows/custom_ci.yml" ]; then
|
42
|
-
rsync -arv --exclude '.github/workflows/ci.yml' tmp/devtools/shared/ . ;
|
43
|
-
else
|
44
|
-
rsync -arv tmp/devtools/shared/ . ;
|
45
|
-
fi
|
46
|
-
- name: Commit changes
|
47
|
-
run: |
|
48
|
-
rm bin/ossy
|
49
|
-
git config --local user.email "dry-bot@dry-rb.org"
|
50
|
-
git config --local user.name "dry-bot"
|
51
|
-
git add -A
|
52
|
-
git commit -m "[devtools] sync configs" || echo "nothing changed"
|
53
|
-
- name: Push changes
|
54
|
-
uses: ad-m/github-push-action@master
|
55
|
-
with:
|
56
|
-
github_token: ${{ secrets.GH_PAT }}
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
# this file is managed by dry-rb/devtools project
|
2
|
-
|
3
|
-
AllCops:
|
4
|
-
TargetRubyVersion: 2.4
|
5
|
-
|
6
|
-
Style/EachWithObject:
|
7
|
-
Enabled: false
|
8
|
-
|
9
|
-
Style/StringLiterals:
|
10
|
-
Enabled: true
|
11
|
-
EnforcedStyle: single_quotes
|
12
|
-
|
13
|
-
Style/ParallelAssignment:
|
14
|
-
Enabled: false
|
15
|
-
|
16
|
-
Style/Alias:
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
Style/LambdaCall:
|
20
|
-
Enabled: false
|
21
|
-
|
22
|
-
Style/StabbyLambdaParentheses:
|
23
|
-
Enabled: false
|
24
|
-
|
25
|
-
Style/FormatString:
|
26
|
-
Enabled: false
|
27
|
-
|
28
|
-
Style/Documentation:
|
29
|
-
Enabled: false
|
30
|
-
|
31
|
-
Layout/SpaceInLambdaLiteral:
|
32
|
-
Enabled: false
|
33
|
-
|
34
|
-
Layout/MultilineMethodCallIndentation:
|
35
|
-
Enabled: true
|
36
|
-
EnforcedStyle: indented
|
37
|
-
|
38
|
-
Metrics/LineLength:
|
39
|
-
Max: 100
|
40
|
-
|
41
|
-
Metrics/MethodLength:
|
42
|
-
Enabled: false
|
43
|
-
|
44
|
-
Metrics/ClassLength:
|
45
|
-
Enabled: false
|
46
|
-
|
47
|
-
Metrics/BlockLength:
|
48
|
-
Enabled: false
|
49
|
-
|
50
|
-
Metrics/AbcSize:
|
51
|
-
Max: 20
|
52
|
-
|
53
|
-
Metrics/CyclomaticComplexity:
|
54
|
-
Enabled: true
|
55
|
-
Max: 10
|
56
|
-
|
57
|
-
Lint/BooleanSymbol:
|
58
|
-
Enabled: false
|
59
|
-
|
60
|
-
Style/AccessModifierDeclarations:
|
61
|
-
Enabled: false
|
62
|
-
|
63
|
-
Style/BlockDelimiters:
|
64
|
-
Enabled: false
|
65
|
-
|
66
|
-
Layout/IndentFirstArrayElement:
|
67
|
-
EnforcedStyle: consistent
|
68
|
-
|
69
|
-
Style/ClassAndModuleChildren:
|
70
|
-
Exclude:
|
71
|
-
- "spec/**/*_spec.rb"
|
72
|
-
|
73
|
-
Lint/HandleExceptions:
|
74
|
-
Exclude:
|
75
|
-
- "spec/spec_helper.rb"
|
76
|
-
|
77
|
-
Naming/PredicateName:
|
78
|
-
Enabled: false
|
79
|
-
|
80
|
-
Naming/FileName:
|
81
|
-
Exclude:
|
82
|
-
- "lib/dry-*.rb"
|
83
|
-
|
84
|
-
Style/SymbolArray:
|
85
|
-
Exclude:
|
86
|
-
- "spec/**/*_spec.rb"
|
87
|
-
|
88
|
-
Style/ConditionalAssignment:
|
89
|
-
Enabled: false
|
90
|
-
|
91
|
-
Naming/MethodName:
|
92
|
-
Enabled: false
|
93
|
-
|
94
|
-
Style/AsciiComments:
|
95
|
-
Enabled: false
|
96
|
-
|
97
|
-
Style/DateTime:
|
98
|
-
Enabled: false
|
99
|
-
|
100
|
-
Style/IfUnlessModifier:
|
101
|
-
Enabled: false
|
data/.yardopts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--markup=markdown
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# Contributor Code of Conduct
|
2
|
-
|
3
|
-
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
-
|
5
|
-
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
-
|
7
|
-
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
-
|
9
|
-
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
-
|
11
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
-
|
13
|
-
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.4.0, available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct](https://www.contributor-covenant.org/version/1/4/code-of-conduct)
|
data/CONTRIBUTING.md
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# Issue Guidelines
|
2
|
-
|
3
|
-
## Reporting bugs
|
4
|
-
|
5
|
-
If you found a bug, report an issue and describe what's the expected behavior versus what actually happens. If the bug causes a crash, attach a full backtrace. If possible, a reproduction script showing the problem is highly appreciated.
|
6
|
-
|
7
|
-
## Reporting feature requests
|
8
|
-
|
9
|
-
Report a feature request **only after discussing it first on [discourse.dry-rb.org](https://discourse.dry-rb.org)** where it was accepted. Please provide a concise description of the feature, don't link to a discussion thread, and instead summarize what was discussed.
|
10
|
-
|
11
|
-
## Reporting questions, support requests, ideas, concerns etc.
|
12
|
-
|
13
|
-
**PLEASE DON'T** - use [discourse.dry-rb.org](http://discourse.dry-rb.org) instead.
|
14
|
-
|
15
|
-
# Pull Request Guidelines
|
16
|
-
|
17
|
-
A Pull Request will only be accepted if it addresses a specific issue that was reported previously, or fixes typos, mistakes in documentation etc.
|
18
|
-
|
19
|
-
Other requirements:
|
20
|
-
|
21
|
-
1) Do not open a pull request if you can't provide tests along with it. If you have problems writing tests, ask for help in the related issue.
|
22
|
-
2) Follow the style conventions of the surrounding code. In most cases, this is standard ruby style.
|
23
|
-
3) Add API documentation if it's a new feature
|
24
|
-
4) Update API documentation if it changes an existing feature
|
25
|
-
5) Bonus points for sending a PR to [github.com/dry-rb/dry-rb.org](github.com/dry-rb/dry-rb.org) which updates user documentation and guides
|
26
|
-
|
27
|
-
# Asking for help
|
28
|
-
|
29
|
-
If these guidelines aren't helpful, and you're stuck, please post a message on [discourse.dry-rb.org](https://discourse.dry-rb.org) or join [our chat](https://dry-rb.zulipchat.com).
|
data/Gemfile
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
eval_gemfile 'Gemfile.devtools'
|
6
|
-
|
7
|
-
gemspec
|
8
|
-
|
9
|
-
group :test do
|
10
|
-
gem 'dry-monads', '~> 1.2.0'
|
11
|
-
gem 'rspec', '~> 3.8'
|
12
|
-
end
|
13
|
-
|
14
|
-
group :tools do
|
15
|
-
gem 'yard'
|
16
|
-
gem 'byebug', platform: :mri
|
17
|
-
gem 'pry'
|
18
|
-
end
|
data/Gemfile.devtools
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
2
|
-
|
3
|
-
gem "ossy", github: "solnic/ossy", branch: "master", platforms: :ruby
|
4
|
-
|
5
|
-
group :test do
|
6
|
-
gem 'codacy-coverage', require: false, platforms: :ruby
|
7
|
-
gem 'simplecov', require: false, platforms: :ruby
|
8
|
-
gem 'warning'
|
9
|
-
end
|
10
|
-
|
11
|
-
group :tools do
|
12
|
-
# this is the same version that we use on codacy
|
13
|
-
gem 'rubocop', '0.71.0'
|
14
|
-
end
|
data/LICENSE.md
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright © 2015-2016 [Icelab](http://icelab.com.au/).
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
-
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
-
|
9
|
-
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: Class enhancement
|
3
|
-
layout: gem-single
|
4
|
-
name: dry-matcher
|
5
|
-
---
|
6
|
-
|
7
|
-
You can offer a match block API from your own methods using `Dry::Matcher.for`:
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
require "dry-matcher"
|
11
|
-
|
12
|
-
# First, build a matcher or use an existing one (like dry-matcher's ResultMatcher)
|
13
|
-
MyMatcher = Dry::Matcher.new(...)
|
14
|
-
|
15
|
-
# Offer it from your class with `Dry::Matcher.for`
|
16
|
-
class MyOperation
|
17
|
-
include Dry::Matcher.for(:call, with: MyMatcher)
|
18
|
-
|
19
|
-
def call
|
20
|
-
# return a value here
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# And now `MyOperation#call` offers the matcher block API
|
25
|
-
operation = MyOperation.new
|
26
|
-
|
27
|
-
operation.() do |m|
|
28
|
-
# Use the matcher's API here
|
29
|
-
end
|
30
|
-
```
|
@@ -1,89 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: Introduction
|
3
|
-
description: Expressive match API for operating on computation results
|
4
|
-
layout: gem-single
|
5
|
-
type: gem
|
6
|
-
name: dry-matcher
|
7
|
-
sections:
|
8
|
-
- class-enhancement
|
9
|
-
- result-matcher
|
10
|
-
---
|
11
|
-
|
12
|
-
dry-matcher offers flexible, expressive pattern matching for Ruby.
|
13
|
-
|
14
|
-
You can build your own matcher or use the out-of-the-box support for matching on [dry-monads](/gems/dry-monads) `Result` values.
|
15
|
-
|
16
|
-
## Building a matcher
|
17
|
-
|
18
|
-
To build your own matcher, create a series of "case" objects with their own resolving logic. First argument of the case block is the value to match, second argument is the list of patterns (see below). The block must either return the result or `Dry::Matcher::Undefined` if the has no match. The latter signals dry-matcher to try the next case.
|
19
|
-
|
20
|
-
```ruby
|
21
|
-
require "dry-matcher"
|
22
|
-
|
23
|
-
# Match `[:ok, some_value]` for success
|
24
|
-
success_case = Dry::Matcher::Case.new do |(code, value), _|
|
25
|
-
if code.equal?(:ok)
|
26
|
-
value
|
27
|
-
else
|
28
|
-
# this is a constant from dry/core/constants
|
29
|
-
Dry::Matcher::Undefined
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# Match `[:err, some_error_code, some_value]` for failure
|
34
|
-
failure_case = Dry::Matcher::Case.new do |(code, value), patterns|
|
35
|
-
if code.equal?(:err) && (patterns.empty? || patterns.include?(value))
|
36
|
-
value
|
37
|
-
else
|
38
|
-
Dry::Matcher::Undefined
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# Build the matcher
|
43
|
-
matcher = Dry::Matcher.new(success: success_case, failure: failure_case)
|
44
|
-
```
|
45
|
-
|
46
|
-
Then use these cases as part of an API to match on results:
|
47
|
-
|
48
|
-
```ruby
|
49
|
-
my_success = [:ok, "success!"]
|
50
|
-
|
51
|
-
result = matcher.(my_success) do |m|
|
52
|
-
m.success do |v|
|
53
|
-
"Yay: #{v}"
|
54
|
-
end
|
55
|
-
|
56
|
-
# :not_found and :lost are patterns
|
57
|
-
m.failure :not_found, :lost do |v|
|
58
|
-
"Oops, not found: #{v}"
|
59
|
-
end
|
60
|
-
|
61
|
-
m.failure do |v|
|
62
|
-
"Boo: #{v}"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
result # => "Yay: success!"
|
67
|
-
```
|
68
|
-
|
69
|
-
Cases are executed in order. The first match wins and halts subsequent matching.
|
70
|
-
|
71
|
-
```ruby
|
72
|
-
my_failure = [:err, :not_found, "missing!"]
|
73
|
-
|
74
|
-
result = matcher.(my_failure) do |m|
|
75
|
-
m.success do |v|
|
76
|
-
"Yay: #{v}"
|
77
|
-
end
|
78
|
-
|
79
|
-
m.failure :not_found do |v|
|
80
|
-
"Oops, not found: #{v}"
|
81
|
-
end
|
82
|
-
|
83
|
-
m.failure do |v|
|
84
|
-
"Boo: #{v}"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
result # => "Oops, not found: missing!"
|
89
|
-
```
|
@@ -1,34 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: Result matcher
|
3
|
-
layout: gem-single
|
4
|
-
name: dry-matcher
|
5
|
-
---
|
6
|
-
|
7
|
-
dry-matcher provides a ready-to-use `ResultMatcher` for working with `Result` or `Try` monads from [dry-monads](/gems/dry-monads) or any other compatible gems.
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
require "dry/monads/result"
|
11
|
-
require "dry/matcher/result_matcher"
|
12
|
-
|
13
|
-
value = Dry::Monads::Success("success!")
|
14
|
-
|
15
|
-
result = Dry::Matcher::ResultMatcher.(value) do |m|
|
16
|
-
m.success(Integer) do |i|
|
17
|
-
"Got int: #{i}"
|
18
|
-
end
|
19
|
-
|
20
|
-
m.success do |v|
|
21
|
-
"Yay: #{v}"
|
22
|
-
end
|
23
|
-
|
24
|
-
m.failure :not_found do |_err, reason|
|
25
|
-
"Nope: #{reason}"
|
26
|
-
end
|
27
|
-
|
28
|
-
m.failure do |v|
|
29
|
-
"Boo: #{v}"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
result # => "Yay: success!"
|
34
|
-
```
|
data/project.yml
DELETED