dry-logic 0.5.0 → 1.5.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/CHANGELOG.md +222 -17
- data/LICENSE +1 -1
- data/README.md +11 -20
- data/dry-logic.gemspec +36 -20
- data/lib/dry/logic/appliable.rb +2 -0
- data/lib/dry/logic/builder.rb +88 -0
- data/lib/dry/logic/evaluator.rb +1 -1
- data/lib/dry/logic/operations/abstract.rb +4 -6
- data/lib/dry/logic/operations/and.rb +12 -3
- data/lib/dry/logic/operations/attr.rb +1 -1
- data/lib/dry/logic/operations/binary.rb +4 -3
- data/lib/dry/logic/operations/check.rb +3 -5
- data/lib/dry/logic/operations/each.rb +1 -2
- data/lib/dry/logic/operations/implication.rb +1 -2
- data/lib/dry/logic/operations/key.rb +3 -5
- data/lib/dry/logic/operations/negation.rb +1 -2
- data/lib/dry/logic/operations/or.rb +1 -2
- data/lib/dry/logic/operations/set.rb +3 -4
- data/lib/dry/logic/operations/unary.rb +1 -1
- data/lib/dry/logic/operations/xor.rb +1 -2
- data/lib/dry/logic/operators.rb +6 -4
- data/lib/dry/logic/predicates.rb +110 -28
- data/lib/dry/logic/result.rb +2 -4
- data/lib/dry/logic/rule/interface.rb +143 -0
- data/lib/dry/logic/rule/predicate.rb +23 -17
- data/lib/dry/logic/rule.rb +31 -31
- data/lib/dry/logic/rule_compiler.rb +2 -7
- data/lib/dry/logic/version.rb +3 -1
- data/lib/dry/logic.rb +21 -5
- data/lib/dry-logic.rb +3 -1
- metadata +27 -143
- data/.codeclimate.yml +0 -23
- data/.gitignore +0 -7
- data/.rspec +0 -3
- data/.rubocop.yml +0 -16
- data/.rubocop_todo.yml +0 -7
- data/.travis.yml +0 -30
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -17
- data/Rakefile +0 -12
- data/bin/console +0 -10
- data/examples/basic.rb +0 -14
- data/lib/dry/logic/operations.rb +0 -13
- data/spec/integration/result_spec.rb +0 -59
- data/spec/integration/rule_spec.rb +0 -53
- data/spec/shared/predicates.rb +0 -57
- data/spec/shared/rule.rb +0 -67
- data/spec/spec_helper.rb +0 -34
- data/spec/support/mutant.rb +0 -9
- data/spec/unit/operations/and_spec.rb +0 -64
- data/spec/unit/operations/attr_spec.rb +0 -27
- data/spec/unit/operations/check_spec.rb +0 -49
- data/spec/unit/operations/each_spec.rb +0 -47
- data/spec/unit/operations/implication_spec.rb +0 -30
- data/spec/unit/operations/key_spec.rb +0 -133
- data/spec/unit/operations/negation_spec.rb +0 -49
- data/spec/unit/operations/or_spec.rb +0 -73
- data/spec/unit/operations/set_spec.rb +0 -41
- data/spec/unit/operations/xor_spec.rb +0 -61
- data/spec/unit/predicates/array_spec.rb +0 -41
- data/spec/unit/predicates/attr_spec.rb +0 -29
- data/spec/unit/predicates/bool_spec.rb +0 -34
- data/spec/unit/predicates/case_spec.rb +0 -33
- data/spec/unit/predicates/date_spec.rb +0 -31
- data/spec/unit/predicates/date_time_spec.rb +0 -31
- data/spec/unit/predicates/decimal_spec.rb +0 -32
- data/spec/unit/predicates/empty_spec.rb +0 -38
- data/spec/unit/predicates/eql_spec.rb +0 -21
- data/spec/unit/predicates/even_spec.rb +0 -31
- data/spec/unit/predicates/excluded_from_spec.rb +0 -35
- data/spec/unit/predicates/excludes_spec.rb +0 -56
- data/spec/unit/predicates/false_spec.rb +0 -35
- data/spec/unit/predicates/filled_spec.rb +0 -38
- data/spec/unit/predicates/float_spec.rb +0 -31
- data/spec/unit/predicates/format_spec.rb +0 -21
- data/spec/unit/predicates/gt_spec.rb +0 -40
- data/spec/unit/predicates/gteq_spec.rb +0 -40
- data/spec/unit/predicates/included_in_spec.rb +0 -35
- data/spec/unit/predicates/includes_spec.rb +0 -24
- data/spec/unit/predicates/int_spec.rb +0 -34
- data/spec/unit/predicates/key_spec.rb +0 -29
- data/spec/unit/predicates/lt_spec.rb +0 -40
- data/spec/unit/predicates/lteq_spec.rb +0 -40
- data/spec/unit/predicates/max_size_spec.rb +0 -49
- data/spec/unit/predicates/min_size_spec.rb +0 -49
- data/spec/unit/predicates/none_spec.rb +0 -28
- data/spec/unit/predicates/not_eql_spec.rb +0 -21
- data/spec/unit/predicates/number_spec.rb +0 -37
- data/spec/unit/predicates/odd_spec.rb +0 -31
- data/spec/unit/predicates/size_spec.rb +0 -55
- data/spec/unit/predicates/str_spec.rb +0 -32
- data/spec/unit/predicates/time_spec.rb +0 -31
- data/spec/unit/predicates/true_spec.rb +0 -35
- data/spec/unit/predicates/type_spec.rb +0 -35
- data/spec/unit/predicates_spec.rb +0 -23
- data/spec/unit/rule/predicate_spec.rb +0 -53
- data/spec/unit/rule_compiler_spec.rb +0 -127
- data/spec/unit/rule_spec.rb +0 -141
data/lib/dry/logic.rb
CHANGED
@@ -1,9 +1,25 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "zeitwerk"
|
4
|
+
require "dry/core"
|
5
|
+
|
3
6
|
module Dry
|
4
7
|
module Logic
|
8
|
+
include Dry::Core::Constants
|
9
|
+
|
10
|
+
def self.loader
|
11
|
+
@loader ||= Zeitwerk::Loader.new.tap do |loader|
|
12
|
+
root = File.expand_path("..", __dir__)
|
13
|
+
loader.tag = "dry-logic"
|
14
|
+
loader.inflector = Zeitwerk::GemInflector.new("#{root}/dry-logic.rb")
|
15
|
+
loader.push_dir(root)
|
16
|
+
loader.ignore(
|
17
|
+
"#{root}/dry-logic.rb",
|
18
|
+
"#{root}/dry/logic/version.rb"
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
loader.setup
|
5
24
|
end
|
6
25
|
end
|
7
|
-
|
8
|
-
require 'dry/logic/rule/predicate'
|
9
|
-
require 'dry/logic/operations'
|
data/lib/dry-logic.rb
CHANGED
metadata
CHANGED
@@ -1,63 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-logic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: concurrent-ruby
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0
|
19
|
+
version: '1.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0
|
26
|
+
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: dry-
|
28
|
+
name: dry-core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0
|
34
|
-
- - "
|
33
|
+
version: '1.0'
|
34
|
+
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
36
|
+
version: '2'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '0
|
44
|
-
- - "
|
43
|
+
version: '1.0'
|
44
|
+
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: '2'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: zeitwerk
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '2.6'
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '2.6'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: bundler
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,33 +100,22 @@ dependencies:
|
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
|
-
description:
|
103
|
+
description: Predicate logic with rule composition
|
104
104
|
email:
|
105
105
|
- piotr.solnica@gmail.com
|
106
106
|
executables: []
|
107
107
|
extensions: []
|
108
108
|
extra_rdoc_files: []
|
109
109
|
files:
|
110
|
-
- ".codeclimate.yml"
|
111
|
-
- ".gitignore"
|
112
|
-
- ".rspec"
|
113
|
-
- ".rubocop.yml"
|
114
|
-
- ".rubocop_todo.yml"
|
115
|
-
- ".travis.yml"
|
116
110
|
- CHANGELOG.md
|
117
|
-
- CONTRIBUTING.md
|
118
|
-
- Gemfile
|
119
111
|
- LICENSE
|
120
112
|
- README.md
|
121
|
-
- Rakefile
|
122
|
-
- bin/console
|
123
113
|
- dry-logic.gemspec
|
124
|
-
- examples/basic.rb
|
125
114
|
- lib/dry-logic.rb
|
126
115
|
- lib/dry/logic.rb
|
127
116
|
- lib/dry/logic/appliable.rb
|
117
|
+
- lib/dry/logic/builder.rb
|
128
118
|
- lib/dry/logic/evaluator.rb
|
129
|
-
- lib/dry/logic/operations.rb
|
130
119
|
- lib/dry/logic/operations/abstract.rb
|
131
120
|
- lib/dry/logic/operations/and.rb
|
132
121
|
- lib/dry/logic/operations/attr.rb
|
@@ -144,68 +133,18 @@ files:
|
|
144
133
|
- lib/dry/logic/predicates.rb
|
145
134
|
- lib/dry/logic/result.rb
|
146
135
|
- lib/dry/logic/rule.rb
|
136
|
+
- lib/dry/logic/rule/interface.rb
|
147
137
|
- lib/dry/logic/rule/predicate.rb
|
148
138
|
- lib/dry/logic/rule_compiler.rb
|
149
139
|
- lib/dry/logic/version.rb
|
150
|
-
-
|
151
|
-
- spec/integration/rule_spec.rb
|
152
|
-
- spec/shared/predicates.rb
|
153
|
-
- spec/shared/rule.rb
|
154
|
-
- spec/spec_helper.rb
|
155
|
-
- spec/support/mutant.rb
|
156
|
-
- spec/unit/operations/and_spec.rb
|
157
|
-
- spec/unit/operations/attr_spec.rb
|
158
|
-
- spec/unit/operations/check_spec.rb
|
159
|
-
- spec/unit/operations/each_spec.rb
|
160
|
-
- spec/unit/operations/implication_spec.rb
|
161
|
-
- spec/unit/operations/key_spec.rb
|
162
|
-
- spec/unit/operations/negation_spec.rb
|
163
|
-
- spec/unit/operations/or_spec.rb
|
164
|
-
- spec/unit/operations/set_spec.rb
|
165
|
-
- spec/unit/operations/xor_spec.rb
|
166
|
-
- spec/unit/predicates/array_spec.rb
|
167
|
-
- spec/unit/predicates/attr_spec.rb
|
168
|
-
- spec/unit/predicates/bool_spec.rb
|
169
|
-
- spec/unit/predicates/case_spec.rb
|
170
|
-
- spec/unit/predicates/date_spec.rb
|
171
|
-
- spec/unit/predicates/date_time_spec.rb
|
172
|
-
- spec/unit/predicates/decimal_spec.rb
|
173
|
-
- spec/unit/predicates/empty_spec.rb
|
174
|
-
- spec/unit/predicates/eql_spec.rb
|
175
|
-
- spec/unit/predicates/even_spec.rb
|
176
|
-
- spec/unit/predicates/excluded_from_spec.rb
|
177
|
-
- spec/unit/predicates/excludes_spec.rb
|
178
|
-
- spec/unit/predicates/false_spec.rb
|
179
|
-
- spec/unit/predicates/filled_spec.rb
|
180
|
-
- spec/unit/predicates/float_spec.rb
|
181
|
-
- spec/unit/predicates/format_spec.rb
|
182
|
-
- spec/unit/predicates/gt_spec.rb
|
183
|
-
- spec/unit/predicates/gteq_spec.rb
|
184
|
-
- spec/unit/predicates/included_in_spec.rb
|
185
|
-
- spec/unit/predicates/includes_spec.rb
|
186
|
-
- spec/unit/predicates/int_spec.rb
|
187
|
-
- spec/unit/predicates/key_spec.rb
|
188
|
-
- spec/unit/predicates/lt_spec.rb
|
189
|
-
- spec/unit/predicates/lteq_spec.rb
|
190
|
-
- spec/unit/predicates/max_size_spec.rb
|
191
|
-
- spec/unit/predicates/min_size_spec.rb
|
192
|
-
- spec/unit/predicates/none_spec.rb
|
193
|
-
- spec/unit/predicates/not_eql_spec.rb
|
194
|
-
- spec/unit/predicates/number_spec.rb
|
195
|
-
- spec/unit/predicates/odd_spec.rb
|
196
|
-
- spec/unit/predicates/size_spec.rb
|
197
|
-
- spec/unit/predicates/str_spec.rb
|
198
|
-
- spec/unit/predicates/time_spec.rb
|
199
|
-
- spec/unit/predicates/true_spec.rb
|
200
|
-
- spec/unit/predicates/type_spec.rb
|
201
|
-
- spec/unit/predicates_spec.rb
|
202
|
-
- spec/unit/rule/predicate_spec.rb
|
203
|
-
- spec/unit/rule_compiler_spec.rb
|
204
|
-
- spec/unit/rule_spec.rb
|
205
|
-
homepage: https://github.com/dry-rb/dry-logic
|
140
|
+
homepage: https://dry-rb.org/gems/dry-logic
|
206
141
|
licenses:
|
207
142
|
- MIT
|
208
|
-
metadata:
|
143
|
+
metadata:
|
144
|
+
allowed_push_host: https://rubygems.org
|
145
|
+
changelog_uri: https://github.com/dry-rb/dry-logic/blob/main/CHANGELOG.md
|
146
|
+
source_code_uri: https://github.com/dry-rb/dry-logic
|
147
|
+
bug_tracker_uri: https://github.com/dry-rb/dry-logic/issues
|
209
148
|
post_install_message:
|
210
149
|
rdoc_options: []
|
211
150
|
require_paths:
|
@@ -214,70 +153,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
214
153
|
requirements:
|
215
154
|
- - ">="
|
216
155
|
- !ruby/object:Gem::Version
|
217
|
-
version:
|
156
|
+
version: 2.7.0
|
218
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
219
158
|
requirements:
|
220
159
|
- - ">="
|
221
160
|
- !ruby/object:Gem::Version
|
222
161
|
version: '0'
|
223
162
|
requirements: []
|
224
|
-
rubygems_version: 3.
|
163
|
+
rubygems_version: 3.1.6
|
225
164
|
signing_key:
|
226
165
|
specification_version: 4
|
227
166
|
summary: Predicate logic with rule composition
|
228
|
-
test_files:
|
229
|
-
- spec/integration/result_spec.rb
|
230
|
-
- spec/integration/rule_spec.rb
|
231
|
-
- spec/shared/predicates.rb
|
232
|
-
- spec/shared/rule.rb
|
233
|
-
- spec/spec_helper.rb
|
234
|
-
- spec/support/mutant.rb
|
235
|
-
- spec/unit/operations/and_spec.rb
|
236
|
-
- spec/unit/operations/attr_spec.rb
|
237
|
-
- spec/unit/operations/check_spec.rb
|
238
|
-
- spec/unit/operations/each_spec.rb
|
239
|
-
- spec/unit/operations/implication_spec.rb
|
240
|
-
- spec/unit/operations/key_spec.rb
|
241
|
-
- spec/unit/operations/negation_spec.rb
|
242
|
-
- spec/unit/operations/or_spec.rb
|
243
|
-
- spec/unit/operations/set_spec.rb
|
244
|
-
- spec/unit/operations/xor_spec.rb
|
245
|
-
- spec/unit/predicates/array_spec.rb
|
246
|
-
- spec/unit/predicates/attr_spec.rb
|
247
|
-
- spec/unit/predicates/bool_spec.rb
|
248
|
-
- spec/unit/predicates/case_spec.rb
|
249
|
-
- spec/unit/predicates/date_spec.rb
|
250
|
-
- spec/unit/predicates/date_time_spec.rb
|
251
|
-
- spec/unit/predicates/decimal_spec.rb
|
252
|
-
- spec/unit/predicates/empty_spec.rb
|
253
|
-
- spec/unit/predicates/eql_spec.rb
|
254
|
-
- spec/unit/predicates/even_spec.rb
|
255
|
-
- spec/unit/predicates/excluded_from_spec.rb
|
256
|
-
- spec/unit/predicates/excludes_spec.rb
|
257
|
-
- spec/unit/predicates/false_spec.rb
|
258
|
-
- spec/unit/predicates/filled_spec.rb
|
259
|
-
- spec/unit/predicates/float_spec.rb
|
260
|
-
- spec/unit/predicates/format_spec.rb
|
261
|
-
- spec/unit/predicates/gt_spec.rb
|
262
|
-
- spec/unit/predicates/gteq_spec.rb
|
263
|
-
- spec/unit/predicates/included_in_spec.rb
|
264
|
-
- spec/unit/predicates/includes_spec.rb
|
265
|
-
- spec/unit/predicates/int_spec.rb
|
266
|
-
- spec/unit/predicates/key_spec.rb
|
267
|
-
- spec/unit/predicates/lt_spec.rb
|
268
|
-
- spec/unit/predicates/lteq_spec.rb
|
269
|
-
- spec/unit/predicates/max_size_spec.rb
|
270
|
-
- spec/unit/predicates/min_size_spec.rb
|
271
|
-
- spec/unit/predicates/none_spec.rb
|
272
|
-
- spec/unit/predicates/not_eql_spec.rb
|
273
|
-
- spec/unit/predicates/number_spec.rb
|
274
|
-
- spec/unit/predicates/odd_spec.rb
|
275
|
-
- spec/unit/predicates/size_spec.rb
|
276
|
-
- spec/unit/predicates/str_spec.rb
|
277
|
-
- spec/unit/predicates/time_spec.rb
|
278
|
-
- spec/unit/predicates/true_spec.rb
|
279
|
-
- spec/unit/predicates/type_spec.rb
|
280
|
-
- spec/unit/predicates_spec.rb
|
281
|
-
- spec/unit/rule/predicate_spec.rb
|
282
|
-
- spec/unit/rule_compiler_spec.rb
|
283
|
-
- spec/unit/rule_spec.rb
|
167
|
+
test_files: []
|
data/.codeclimate.yml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
engines:
|
2
|
-
rubocop:
|
3
|
-
enabled: true
|
4
|
-
checks:
|
5
|
-
Rubocop/Metrics/LineLength:
|
6
|
-
enabled: true
|
7
|
-
max: 100
|
8
|
-
Rubocop/Style/Documentation:
|
9
|
-
enabled: false
|
10
|
-
Rubocop/Lint/HandleExceptions:
|
11
|
-
enabled: true
|
12
|
-
exclude:
|
13
|
-
- rakelib/*.rake
|
14
|
-
Rubocop/Style/FileName:
|
15
|
-
enabled: true
|
16
|
-
exclude:
|
17
|
-
- 'lib/dry-logic.rb'
|
18
|
-
ratings:
|
19
|
-
paths:
|
20
|
-
- lib/**/*.rb
|
21
|
-
exclude_paths:
|
22
|
-
- spec/**/*
|
23
|
-
- examples/**/*
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# Generated by `rubocop --auto-gen-config`
|
2
|
-
inherit_from: .rubocop_todo.yml
|
3
|
-
|
4
|
-
Metrics/LineLength:
|
5
|
-
Max: 100
|
6
|
-
|
7
|
-
Style/Documentation:
|
8
|
-
Enabled: false
|
9
|
-
|
10
|
-
Lint/HandleExceptions:
|
11
|
-
Exclude:
|
12
|
-
- rakelib/*.rake
|
13
|
-
|
14
|
-
Style/FileName:
|
15
|
-
Exclude:
|
16
|
-
- lib/dry-logic.rb
|
data/.rubocop_todo.yml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on 2015-10-30 01:32:46 +0000 using RuboCop version 0.34.2.
|
4
|
-
# The point is for the user to remove these configuration records
|
5
|
-
# one by one as the offenses are removed from the code base.
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
data/.travis.yml
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
sudo: false
|
4
|
-
bundler_args: --without benchmarks tools
|
5
|
-
before_install: gem update --system
|
6
|
-
before_script:
|
7
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
8
|
-
- chmod +x ./cc-test-reporter
|
9
|
-
- ./cc-test-reporter before-build
|
10
|
-
after_script:
|
11
|
-
- "[ -d coverage ] && ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
12
|
-
script:
|
13
|
-
- bundle exec rake
|
14
|
-
rvm:
|
15
|
-
- 2.6.0
|
16
|
-
- 2.5.3
|
17
|
-
- 2.4.5
|
18
|
-
- 2.3.8
|
19
|
-
- jruby-9.2.5.0
|
20
|
-
env:
|
21
|
-
global:
|
22
|
-
- COVERAGE=true
|
23
|
-
notifications:
|
24
|
-
email: false
|
25
|
-
webhooks:
|
26
|
-
urls:
|
27
|
-
- https://webhooks.gitter.im/e/19098b4253a72c9796db
|
28
|
-
on_success: change # options: [always|never|change] default: always
|
29
|
-
on_failure: always # options: [always|never|change] default: always
|
30
|
-
on_start: false # default: false
|
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 [discuss.dry-rb.org](https://discuss.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 [discuss.dry-rb.org](http://discuss.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 [discuss.dry-rb.org](https://discuss.dry-rb.org).
|
data/Gemfile
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gemspec
|
4
|
-
|
5
|
-
group :test do
|
6
|
-
gem 'simplecov', require: false, platform: :mri
|
7
|
-
end
|
8
|
-
|
9
|
-
group :tools do
|
10
|
-
gem 'rubocop'
|
11
|
-
gem 'byebug', platform: :mri
|
12
|
-
|
13
|
-
unless ENV['TRAVIS']
|
14
|
-
gem 'mutant', github: 'mbj/mutant'
|
15
|
-
gem 'mutant-rspec', github: 'mbj/mutant'
|
16
|
-
end
|
17
|
-
end
|
data/Rakefile
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
require 'bundler/gem_tasks'
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
5
|
-
|
6
|
-
require 'rspec/core'
|
7
|
-
require 'rspec/core/rake_task'
|
8
|
-
|
9
|
-
task default: :spec
|
10
|
-
|
11
|
-
desc 'Run all specs in spec directory'
|
12
|
-
RSpec::Core::RakeTask.new(:spec)
|
data/bin/console
DELETED
data/examples/basic.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'dry/logic'
|
2
|
-
require 'dry/logic/predicates'
|
3
|
-
|
4
|
-
include Dry::Logic
|
5
|
-
|
6
|
-
user_present = Rule::Predicate.new(Predicates[:key?]).curry(:user)
|
7
|
-
|
8
|
-
has_min_age = Operations::Key.new(Rule::Predicate.new(Predicates[:gt?]).curry(18), name: [:user, :age])
|
9
|
-
|
10
|
-
user_rule = user_present & has_min_age
|
11
|
-
|
12
|
-
puts user_rule.(user: { age: 19 }).success?
|
13
|
-
|
14
|
-
puts user_rule.(user: { age: 18 }).success?
|
data/lib/dry/logic/operations.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'dry/logic/operations/and'
|
2
|
-
require 'dry/logic/operations/or'
|
3
|
-
require 'dry/logic/operations/xor'
|
4
|
-
require 'dry/logic/operations/implication'
|
5
|
-
require 'dry/logic/operations/negation'
|
6
|
-
|
7
|
-
require 'dry/logic/operations/key'
|
8
|
-
require 'dry/logic/operations/attr'
|
9
|
-
require 'dry/logic/operations/each'
|
10
|
-
require 'dry/logic/operations/set'
|
11
|
-
require 'dry/logic/operations/check'
|
12
|
-
|
13
|
-
require 'dry/logic/operators'
|
@@ -1,59 +0,0 @@
|
|
1
|
-
RSpec.describe Result do
|
2
|
-
include_context 'predicates'
|
3
|
-
|
4
|
-
describe '#to_s' do
|
5
|
-
shared_examples_for 'string representation' do
|
6
|
-
it 'returns string representation' do
|
7
|
-
expect(rule.(input).to_s).to eql(output)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
context 'with a predicate' do
|
12
|
-
let(:rule) { Rule::Predicate.new(gt?, args: [18]) }
|
13
|
-
let(:input) { 17 }
|
14
|
-
let(:output) { 'gt?(18, 17)' }
|
15
|
-
|
16
|
-
it_behaves_like 'string representation'
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'with AND operation' do
|
20
|
-
let(:rule) { Rule::Predicate.new(array?).and(Rule::Predicate.new(empty?)) }
|
21
|
-
let(:input) { '' }
|
22
|
-
let(:output) { 'array?("") AND empty?("")' }
|
23
|
-
|
24
|
-
it_behaves_like 'string representation'
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'with OR operation' do
|
28
|
-
let(:rule) { Rule::Predicate.new(array?).or(Rule::Predicate.new(empty?)) }
|
29
|
-
let(:input) { 123 }
|
30
|
-
let(:output) { 'array?(123) OR empty?(123)' }
|
31
|
-
|
32
|
-
it_behaves_like 'string representation'
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'with XOR operation' do
|
36
|
-
let(:rule) { Rule::Predicate.new(array?).xor(Rule::Predicate.new(empty?)) }
|
37
|
-
let(:input) { [] }
|
38
|
-
let(:output) { 'array?([]) XOR empty?([])' }
|
39
|
-
|
40
|
-
it_behaves_like 'string representation'
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'with THEN operation' do
|
44
|
-
let(:rule) { Rule::Predicate.new(array?).then(Rule::Predicate.new(empty?)) }
|
45
|
-
let(:input) { [1, 2, 3] }
|
46
|
-
let(:output) { 'empty?([1, 2, 3])' }
|
47
|
-
|
48
|
-
it_behaves_like 'string representation'
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'with NOT operation' do
|
52
|
-
let(:rule) { Operations::Negation.new(Rule::Predicate.new(array?)) }
|
53
|
-
let(:input) { 'foo' }
|
54
|
-
let(:output) { 'not(array?("foo"))' }
|
55
|
-
|
56
|
-
it_behaves_like 'string representation'
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'dry-logic'
|
2
|
-
|
3
|
-
RSpec.describe 'Rules' do
|
4
|
-
specify 'defining an anonymous rule with an arbitrary predicate' do
|
5
|
-
rule = Dry::Logic.Rule { |value| value.is_a?(Integer) }
|
6
|
-
|
7
|
-
expect(rule.(1)).to be_success
|
8
|
-
expect(rule[1]).to be(true)
|
9
|
-
end
|
10
|
-
|
11
|
-
specify 'defining a conjunction' do
|
12
|
-
rule = Dry::Logic.Rule(&:even?) & Dry::Logic.Rule { |v| v > 4 }
|
13
|
-
|
14
|
-
expect(rule.(3)).to be_failure
|
15
|
-
expect(rule.(4)).to be_failure
|
16
|
-
expect(rule.(5)).to be_failure
|
17
|
-
expect(rule.(6)).to be_success
|
18
|
-
end
|
19
|
-
|
20
|
-
specify 'defining a disjunction' do
|
21
|
-
rule = Dry::Logic.Rule { |v| v < 4 } | Dry::Logic.Rule { |v| v > 6 }
|
22
|
-
|
23
|
-
expect(rule.(5)).to be_failure
|
24
|
-
expect(rule.(3)).to be_success
|
25
|
-
expect(rule.(7)).to be_success
|
26
|
-
end
|
27
|
-
|
28
|
-
specify 'defining an implication' do
|
29
|
-
rule = Dry::Logic.Rule(&:empty?) > Dry::Logic.Rule { |v| v.is_a?(Array) }
|
30
|
-
|
31
|
-
expect(rule.('foo')).to be_success
|
32
|
-
expect(rule.([1, 2])).to be_success
|
33
|
-
expect(rule.([])).to be_success
|
34
|
-
expect(rule.('')).to be_failure
|
35
|
-
end
|
36
|
-
|
37
|
-
specify 'defining an exclusive disjunction' do
|
38
|
-
rule = Dry::Logic.Rule(&:empty?) ^ Dry::Logic.Rule { |v| v.is_a?(Array) }
|
39
|
-
|
40
|
-
expect(rule.('foo')).to be_failure
|
41
|
-
expect(rule.([])).to be_failure
|
42
|
-
expect(rule.([1, 2])).to be_success
|
43
|
-
expect(rule.('')).to be_success
|
44
|
-
end
|
45
|
-
|
46
|
-
specify 'defining a rule with options' do
|
47
|
-
rule = Dry::Logic::Rule(id: :empty?) { |value| value.empty? }
|
48
|
-
|
49
|
-
expect(rule.('foo')).to be_failure
|
50
|
-
expect(rule.('')).to be_success
|
51
|
-
expect(rule.ast('foo')).to eql([:predicate, [:empty?, [[:value, 'foo']]]])
|
52
|
-
end
|
53
|
-
end
|
data/spec/shared/predicates.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'dry/logic/predicates'
|
2
|
-
|
3
|
-
RSpec.shared_examples 'predicates' do
|
4
|
-
let(:nil?) { Dry::Logic::Predicates[:nil?] }
|
5
|
-
|
6
|
-
let(:array?) { Dry::Logic::Predicates[:array?] }
|
7
|
-
|
8
|
-
let(:empty?) { Dry::Logic::Predicates[:empty?] }
|
9
|
-
|
10
|
-
let(:str?) { Dry::Logic::Predicates[:str?] }
|
11
|
-
|
12
|
-
let(:true?) { Dry::Logic::Predicates[:true?] }
|
13
|
-
|
14
|
-
let(:hash?) { Dry::Logic::Predicates[:hash?] }
|
15
|
-
|
16
|
-
let(:int?) { Dry::Logic::Predicates[:int?] }
|
17
|
-
|
18
|
-
let(:filled?) { Dry::Logic::Predicates[:filled?] }
|
19
|
-
|
20
|
-
let(:min_size?) { Dry::Logic::Predicates[:min_size?] }
|
21
|
-
|
22
|
-
let(:lt?) { Dry::Logic::Predicates[:lt?] }
|
23
|
-
|
24
|
-
let(:gt?) { Dry::Logic::Predicates[:gt?] }
|
25
|
-
|
26
|
-
let(:key?) { Dry::Logic::Predicates[:key?] }
|
27
|
-
|
28
|
-
let(:attr?) { Dry::Logic::Predicates[:attr?] }
|
29
|
-
|
30
|
-
let(:eql?) { Dry::Logic::Predicates[:eql?] }
|
31
|
-
|
32
|
-
let(:size?) { Dry::Logic::Predicates[:size?] }
|
33
|
-
|
34
|
-
let(:case?) { Dry::Logic::Predicates[:case?] }
|
35
|
-
|
36
|
-
let(:equal?) { Dry::Logic::Predicates[:equal?] }
|
37
|
-
end
|
38
|
-
|
39
|
-
RSpec.shared_examples 'a passing predicate' do
|
40
|
-
let(:predicate) { Dry::Logic::Predicates[predicate_name] }
|
41
|
-
|
42
|
-
it do
|
43
|
-
arguments_list.each do |args|
|
44
|
-
expect(predicate.call(*args)).to be(true)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
RSpec.shared_examples 'a failing predicate' do
|
50
|
-
let(:predicate) { Dry::Logic::Predicates[predicate_name] }
|
51
|
-
|
52
|
-
it do
|
53
|
-
arguments_list.each do |args|
|
54
|
-
expect(predicate.call(*args)).to be(false)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|