dry-logic 0.6.1 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +2 -5
- data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +10 -0
- data/.github/ISSUE_TEMPLATE/---bug-report.md +34 -0
- data/.github/ISSUE_TEMPLATE/---feature-request.md +18 -0
- data/.github/workflows/ci.yml +70 -0
- data/.github/workflows/docsite.yml +34 -0
- data/.github/workflows/sync_configs.yml +34 -0
- data/.gitignore +2 -1
- data/.rspec +1 -0
- data/.rubocop.yml +89 -0
- data/CHANGELOG.md +52 -3
- data/CODE_OF_CONDUCT.md +13 -0
- data/CONTRIBUTING.md +3 -3
- data/Gemfile +3 -0
- data/LICENSE +1 -1
- data/README.md +6 -6
- data/Rakefile +2 -0
- data/benchmarks/rule_application.rb +2 -0
- data/benchmarks/setup.rb +2 -0
- data/bin/console +1 -0
- data/docsite/source/index.html.md +54 -0
- data/docsite/source/operations.html.md +62 -0
- data/docsite/source/predicates.html.md +102 -0
- data/dry-logic.gemspec +8 -0
- data/examples/basic.rb +2 -0
- data/lib/dry-logic.rb +2 -0
- data/lib/dry/logic.rb +2 -0
- data/lib/dry/logic/appliable.rb +2 -0
- data/lib/dry/logic/evaluator.rb +2 -0
- data/lib/dry/logic/operations.rb +2 -0
- data/lib/dry/logic/operations/abstract.rb +5 -3
- data/lib/dry/logic/operations/and.rb +3 -1
- data/lib/dry/logic/operations/attr.rb +2 -0
- data/lib/dry/logic/operations/binary.rb +2 -0
- data/lib/dry/logic/operations/check.rb +3 -1
- data/lib/dry/logic/operations/each.rb +2 -0
- data/lib/dry/logic/operations/implication.rb +2 -0
- data/lib/dry/logic/operations/key.rb +4 -2
- data/lib/dry/logic/operations/negation.rb +2 -0
- data/lib/dry/logic/operations/or.rb +2 -0
- data/lib/dry/logic/operations/set.rb +2 -0
- data/lib/dry/logic/operations/unary.rb +2 -0
- data/lib/dry/logic/operations/xor.rb +2 -0
- data/lib/dry/logic/operators.rb +2 -0
- data/lib/dry/logic/predicates.rb +39 -21
- data/lib/dry/logic/result.rb +2 -0
- data/lib/dry/logic/rule.rb +5 -3
- data/lib/dry/logic/rule/interface.rb +2 -0
- data/lib/dry/logic/rule/predicate.rb +2 -0
- data/lib/dry/logic/rule_compiler.rb +2 -0
- data/lib/dry/logic/version.rb +3 -1
- data/spec/integration/result_spec.rb +2 -0
- data/spec/integration/rule_spec.rb +2 -0
- data/spec/shared/predicates.rb +2 -0
- data/spec/shared/rule.rb +2 -0
- data/spec/spec_helper.rb +6 -10
- data/spec/support/mutant.rb +2 -0
- data/spec/unit/operations/and_spec.rb +2 -0
- data/spec/unit/operations/attr_spec.rb +2 -0
- data/spec/unit/operations/check_spec.rb +2 -0
- data/spec/unit/operations/each_spec.rb +2 -0
- data/spec/unit/operations/implication_spec.rb +2 -0
- data/spec/unit/operations/key_spec.rb +2 -0
- data/spec/unit/operations/negation_spec.rb +2 -0
- data/spec/unit/operations/or_spec.rb +2 -0
- data/spec/unit/operations/set_spec.rb +2 -0
- data/spec/unit/operations/xor_spec.rb +2 -0
- data/spec/unit/predicates/array_spec.rb +2 -0
- data/spec/unit/predicates/attr_spec.rb +2 -0
- data/spec/unit/predicates/bool_spec.rb +3 -1
- data/spec/unit/predicates/bytesize_spec.rb +48 -0
- data/spec/unit/predicates/case_spec.rb +2 -0
- data/spec/unit/predicates/date_spec.rb +2 -0
- data/spec/unit/predicates/date_time_spec.rb +3 -1
- data/spec/unit/predicates/decimal_spec.rb +3 -1
- data/spec/unit/predicates/empty_spec.rb +2 -0
- data/spec/unit/predicates/eql_spec.rb +2 -0
- data/spec/unit/predicates/even_spec.rb +2 -0
- data/spec/unit/predicates/excluded_from_spec.rb +2 -0
- data/spec/unit/predicates/excludes_spec.rb +2 -0
- data/spec/unit/predicates/false_spec.rb +3 -1
- data/spec/unit/predicates/filled_spec.rb +2 -0
- data/spec/unit/predicates/float_spec.rb +2 -0
- data/spec/unit/predicates/format_spec.rb +12 -2
- data/spec/unit/predicates/gt_spec.rb +2 -0
- data/spec/unit/predicates/gteq_spec.rb +2 -0
- data/spec/unit/predicates/hash_spec.rb +40 -0
- data/spec/unit/predicates/included_in_spec.rb +2 -0
- data/spec/unit/predicates/int_spec.rb +2 -0
- data/spec/unit/predicates/key_spec.rb +2 -0
- data/spec/unit/predicates/lt_spec.rb +2 -0
- data/spec/unit/predicates/lteq_spec.rb +2 -0
- data/spec/unit/predicates/max_bytesize_spec.rb +39 -0
- data/spec/unit/predicates/max_size_spec.rb +2 -0
- data/spec/unit/predicates/min_bytesize_spec.rb +39 -0
- data/spec/unit/predicates/min_size_spec.rb +2 -0
- data/spec/unit/predicates/none_spec.rb +2 -0
- data/spec/unit/predicates/not_eql_spec.rb +2 -0
- data/spec/unit/predicates/number_spec.rb +2 -0
- data/spec/unit/predicates/odd_spec.rb +2 -0
- data/spec/unit/predicates/respond_to_spec.rb +31 -0
- data/spec/unit/predicates/size_spec.rb +2 -0
- data/spec/unit/predicates/str_spec.rb +2 -0
- data/spec/unit/predicates/time_spec.rb +3 -1
- data/spec/unit/predicates/true_spec.rb +3 -1
- data/spec/unit/predicates/type_spec.rb +2 -0
- data/spec/unit/predicates/uuid_v4_spec.rb +29 -0
- data/spec/unit/predicates_spec.rb +2 -0
- data/spec/unit/rule/predicate_spec.rb +2 -0
- data/spec/unit/rule_compiler_spec.rb +2 -0
- data/spec/unit/rule_spec.rb +6 -4
- metadata +30 -6
- data/.travis.yml +0 -31
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry/logic/predicates'
|
4
|
+
|
5
|
+
RSpec.describe Dry::Logic::Predicates do
|
6
|
+
describe '#uuid_v4?' do
|
7
|
+
let(:predicate_name) { :uuid_v4? }
|
8
|
+
|
9
|
+
context 'when value is a valid V4 UUID' do
|
10
|
+
let(:arguments_list) do
|
11
|
+
[['f2d26c57-e07c-4416-a749-57e937930e04']]
|
12
|
+
end
|
13
|
+
|
14
|
+
it_behaves_like 'a passing predicate'
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'with value is not a valid V4 UUID' do
|
18
|
+
let(:arguments_list) do
|
19
|
+
[
|
20
|
+
['f2d26c57-e07c-3416-a749-57e937930e04'], # wrong version number (3, not 4)
|
21
|
+
['20633928-6a07-11e9-a923-1681be663d3e'], # UUID V1
|
22
|
+
['not-a-uuid-at-all']
|
23
|
+
]
|
24
|
+
end
|
25
|
+
|
26
|
+
it_behaves_like 'a failing predicate'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/spec/unit/rule_spec.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Dry::Logic::Rule do
|
2
|
-
subject(:rule) { Rule.build(predicate, options) }
|
4
|
+
subject(:rule) { Rule.build(predicate, **options) }
|
3
5
|
|
4
6
|
let(:predicate) { -> { true } }
|
5
7
|
let(:options) { {} }
|
@@ -178,8 +180,8 @@ RSpec.describe Dry::Logic::Rule do
|
|
178
180
|
end
|
179
181
|
|
180
182
|
describe 'arbitrary arity' do
|
181
|
-
let(:arity) { rand(20) }
|
182
|
-
let(:curried) {
|
183
|
+
let(:arity) { rand(1..20) }
|
184
|
+
let(:curried) { rand(arity) }
|
183
185
|
|
184
186
|
let(:options) { { args: [1] * curried, arity: arity } }
|
185
187
|
let(:predicate) { double(:predicate) }
|
@@ -202,7 +204,7 @@ RSpec.describe Dry::Logic::Rule do
|
|
202
204
|
describe 'constants' do
|
203
205
|
let(:options) { { args: [], arity: 0 } }
|
204
206
|
|
205
|
-
|
207
|
+
it 'accepts variable number of arguments' do
|
206
208
|
expect(rule.method(:call).arity).to be(-1)
|
207
209
|
expect(rule.method(:[]).arity).to be(-1)
|
208
210
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-logic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -102,10 +102,17 @@ extensions: []
|
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
104
|
- ".codeclimate.yml"
|
105
|
+
- ".github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md"
|
106
|
+
- ".github/ISSUE_TEMPLATE/---bug-report.md"
|
107
|
+
- ".github/ISSUE_TEMPLATE/---feature-request.md"
|
108
|
+
- ".github/workflows/ci.yml"
|
109
|
+
- ".github/workflows/docsite.yml"
|
110
|
+
- ".github/workflows/sync_configs.yml"
|
105
111
|
- ".gitignore"
|
106
112
|
- ".rspec"
|
107
|
-
- ".
|
113
|
+
- ".rubocop.yml"
|
108
114
|
- CHANGELOG.md
|
115
|
+
- CODE_OF_CONDUCT.md
|
109
116
|
- CONTRIBUTING.md
|
110
117
|
- Gemfile
|
111
118
|
- LICENSE
|
@@ -114,6 +121,9 @@ files:
|
|
114
121
|
- benchmarks/rule_application.rb
|
115
122
|
- benchmarks/setup.rb
|
116
123
|
- bin/console
|
124
|
+
- docsite/source/index.html.md
|
125
|
+
- docsite/source/operations.html.md
|
126
|
+
- docsite/source/predicates.html.md
|
117
127
|
- dry-logic.gemspec
|
118
128
|
- examples/basic.rb
|
119
129
|
- lib/dry-logic.rb
|
@@ -161,6 +171,7 @@ files:
|
|
161
171
|
- spec/unit/predicates/array_spec.rb
|
162
172
|
- spec/unit/predicates/attr_spec.rb
|
163
173
|
- spec/unit/predicates/bool_spec.rb
|
174
|
+
- spec/unit/predicates/bytesize_spec.rb
|
164
175
|
- spec/unit/predicates/case_spec.rb
|
165
176
|
- spec/unit/predicates/date_spec.rb
|
166
177
|
- spec/unit/predicates/date_time_spec.rb
|
@@ -176,23 +187,28 @@ files:
|
|
176
187
|
- spec/unit/predicates/format_spec.rb
|
177
188
|
- spec/unit/predicates/gt_spec.rb
|
178
189
|
- spec/unit/predicates/gteq_spec.rb
|
190
|
+
- spec/unit/predicates/hash_spec.rb
|
179
191
|
- spec/unit/predicates/included_in_spec.rb
|
180
192
|
- spec/unit/predicates/includes_spec.rb
|
181
193
|
- spec/unit/predicates/int_spec.rb
|
182
194
|
- spec/unit/predicates/key_spec.rb
|
183
195
|
- spec/unit/predicates/lt_spec.rb
|
184
196
|
- spec/unit/predicates/lteq_spec.rb
|
197
|
+
- spec/unit/predicates/max_bytesize_spec.rb
|
185
198
|
- spec/unit/predicates/max_size_spec.rb
|
199
|
+
- spec/unit/predicates/min_bytesize_spec.rb
|
186
200
|
- spec/unit/predicates/min_size_spec.rb
|
187
201
|
- spec/unit/predicates/none_spec.rb
|
188
202
|
- spec/unit/predicates/not_eql_spec.rb
|
189
203
|
- spec/unit/predicates/number_spec.rb
|
190
204
|
- spec/unit/predicates/odd_spec.rb
|
205
|
+
- spec/unit/predicates/respond_to_spec.rb
|
191
206
|
- spec/unit/predicates/size_spec.rb
|
192
207
|
- spec/unit/predicates/str_spec.rb
|
193
208
|
- spec/unit/predicates/time_spec.rb
|
194
209
|
- spec/unit/predicates/true_spec.rb
|
195
210
|
- spec/unit/predicates/type_spec.rb
|
211
|
+
- spec/unit/predicates/uuid_v4_spec.rb
|
196
212
|
- spec/unit/predicates_spec.rb
|
197
213
|
- spec/unit/rule/predicate_spec.rb
|
198
214
|
- spec/unit/rule_compiler_spec.rb
|
@@ -200,7 +216,9 @@ files:
|
|
200
216
|
homepage: https://github.com/dry-rb/dry-logic
|
201
217
|
licenses:
|
202
218
|
- MIT
|
203
|
-
metadata:
|
219
|
+
metadata:
|
220
|
+
source_code_uri: https://github.com/dry-rb/dry-logic
|
221
|
+
changelog_uri: https://github.com/dry-rb/dry-logic/blob/master/CHANGELOG.md
|
204
222
|
post_install_message:
|
205
223
|
rdoc_options: []
|
206
224
|
require_paths:
|
@@ -209,14 +227,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
209
227
|
requirements:
|
210
228
|
- - ">="
|
211
229
|
- !ruby/object:Gem::Version
|
212
|
-
version:
|
230
|
+
version: 2.4.0
|
213
231
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
214
232
|
requirements:
|
215
233
|
- - ">="
|
216
234
|
- !ruby/object:Gem::Version
|
217
235
|
version: '0'
|
218
236
|
requirements: []
|
219
|
-
rubygems_version: 3.0.
|
237
|
+
rubygems_version: 3.0.6
|
220
238
|
signing_key:
|
221
239
|
specification_version: 4
|
222
240
|
summary: Predicate logic with rule composition
|
@@ -240,6 +258,7 @@ test_files:
|
|
240
258
|
- spec/unit/predicates/array_spec.rb
|
241
259
|
- spec/unit/predicates/attr_spec.rb
|
242
260
|
- spec/unit/predicates/bool_spec.rb
|
261
|
+
- spec/unit/predicates/bytesize_spec.rb
|
243
262
|
- spec/unit/predicates/case_spec.rb
|
244
263
|
- spec/unit/predicates/date_spec.rb
|
245
264
|
- spec/unit/predicates/date_time_spec.rb
|
@@ -255,23 +274,28 @@ test_files:
|
|
255
274
|
- spec/unit/predicates/format_spec.rb
|
256
275
|
- spec/unit/predicates/gt_spec.rb
|
257
276
|
- spec/unit/predicates/gteq_spec.rb
|
277
|
+
- spec/unit/predicates/hash_spec.rb
|
258
278
|
- spec/unit/predicates/included_in_spec.rb
|
259
279
|
- spec/unit/predicates/includes_spec.rb
|
260
280
|
- spec/unit/predicates/int_spec.rb
|
261
281
|
- spec/unit/predicates/key_spec.rb
|
262
282
|
- spec/unit/predicates/lt_spec.rb
|
263
283
|
- spec/unit/predicates/lteq_spec.rb
|
284
|
+
- spec/unit/predicates/max_bytesize_spec.rb
|
264
285
|
- spec/unit/predicates/max_size_spec.rb
|
286
|
+
- spec/unit/predicates/min_bytesize_spec.rb
|
265
287
|
- spec/unit/predicates/min_size_spec.rb
|
266
288
|
- spec/unit/predicates/none_spec.rb
|
267
289
|
- spec/unit/predicates/not_eql_spec.rb
|
268
290
|
- spec/unit/predicates/number_spec.rb
|
269
291
|
- spec/unit/predicates/odd_spec.rb
|
292
|
+
- spec/unit/predicates/respond_to_spec.rb
|
270
293
|
- spec/unit/predicates/size_spec.rb
|
271
294
|
- spec/unit/predicates/str_spec.rb
|
272
295
|
- spec/unit/predicates/time_spec.rb
|
273
296
|
- spec/unit/predicates/true_spec.rb
|
274
297
|
- spec/unit/predicates/type_spec.rb
|
298
|
+
- spec/unit/predicates/uuid_v4_spec.rb
|
275
299
|
- spec/unit/predicates_spec.rb
|
276
300
|
- spec/unit/rule/predicate_spec.rb
|
277
301
|
- spec/unit/rule_compiler_spec.rb
|
data/.travis.yml
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
bundler_args: --without benchmarks tools
|
4
|
-
before_script:
|
5
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
6
|
-
- chmod +x ./cc-test-reporter
|
7
|
-
- ./cc-test-reporter before-build
|
8
|
-
after_script:
|
9
|
-
- "[ -d coverage ] && ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
10
|
-
script:
|
11
|
-
- bundle exec rake
|
12
|
-
rvm:
|
13
|
-
- 2.6.2
|
14
|
-
- 2.5.5
|
15
|
-
- 2.4.6
|
16
|
-
- jruby-9.2.7.0
|
17
|
-
- truffleruby
|
18
|
-
env:
|
19
|
-
global:
|
20
|
-
- COVERAGE=true
|
21
|
-
matrix:
|
22
|
-
allow_failures:
|
23
|
-
- rvm: truffleruby
|
24
|
-
notifications:
|
25
|
-
email: false
|
26
|
-
webhooks:
|
27
|
-
urls:
|
28
|
-
- https://dry-rb.zulipchat.com/api/v1/external/travis?api_key=SY8LLz6fShd4TJeLDXEdT0eBEgRqT2lv&stream=notifications&topic=ci
|
29
|
-
on_success: change # options: [always|never|change] default: always
|
30
|
-
on_failure: always # options: [always|never|change] default: always
|
31
|
-
on_start: false # default: false
|