dry-logic 1.1.1 → 1.3.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 +33 -0
- data/LICENSE +1 -1
- data/README.md +5 -4
- data/dry-logic.gemspec +16 -14
- data/lib/dry/logic/builder.rb +88 -0
- data/lib/dry/logic/evaluator.rb +0 -2
- data/lib/dry/logic/operations/abstract.rb +0 -4
- data/lib/dry/logic/operations/and.rb +0 -3
- data/lib/dry/logic/operations/attr.rb +0 -2
- data/lib/dry/logic/operations/binary.rb +0 -2
- data/lib/dry/logic/operations/check.rb +0 -4
- data/lib/dry/logic/operations/each.rb +0 -3
- data/lib/dry/logic/operations/implication.rb +0 -3
- data/lib/dry/logic/operations/key.rb +0 -4
- data/lib/dry/logic/operations/negation.rb +0 -3
- data/lib/dry/logic/operations/or.rb +0 -3
- data/lib/dry/logic/operations/set.rb +1 -4
- data/lib/dry/logic/operations/unary.rb +0 -2
- data/lib/dry/logic/operations/xor.rb +0 -3
- data/lib/dry/logic/predicates.rb +29 -10
- data/lib/dry/logic/result.rb +0 -4
- data/lib/dry/logic/rule/interface.rb +18 -16
- data/lib/dry/logic/rule/predicate.rb +21 -21
- data/lib/dry/logic/rule.rb +1 -6
- data/lib/dry/logic/rule_compiler.rb +0 -7
- data/lib/dry/logic/version.rb +1 -1
- data/lib/dry/logic.rb +19 -5
- metadata +27 -13
- data/lib/dry/logic/operations.rb +0 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f9302f3c5ad02f81c99c8e873eb0b4e7ecc4c8fd2c7f964590f6f39db4f509ee
|
|
4
|
+
data.tar.gz: 13799ef7e9224fd519eec2b902224f9f84002dd1647f77a9584e2e4305e15e47
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f16154529f4b4c74bc8e4551d147422da5e09c04981bea3b4bfafb4a5356661e2ea39fee2ff84994d9e9a886b157a92e422b6581300f755518f156f018d87372
|
|
7
|
+
data.tar.gz: b72cc11b159301e3ca7c2a6f0df47d8d4cc44cf3986ab931614fb2e688500c8a3437192b8bf34a0f4a976d1e18f61adcb10fe3cdbd414b20305fbbe7d6d7f1f6
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
|
2
2
|
|
|
3
|
+
## unreleased
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Added
|
|
7
|
+
|
|
8
|
+
- `uri_rfc3986?` predicate that uses a better regexp than `uri?` (see #94 for more details) (@hieuk09)
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Deprecate `eql?` in favor of `is_eql?` (issue #92 via #98) (@solnic)
|
|
13
|
+
- Deprecate `respond_to?` in favor of `interface?` (issue #73 closed via #99) (@solnic)
|
|
14
|
+
|
|
15
|
+
[Compare v1.3.0...master](https://github.com/dry-rb/dry-logic/compare/v1.3.0...master)
|
|
16
|
+
|
|
17
|
+
## 1.3.0 2022-10-15
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Use zeitwerk for auto-loading (@solnic + @flash-gordon)
|
|
23
|
+
|
|
24
|
+
[Compare v1.2.0...v1.3.0](https://github.com/dry-rb/dry-logic/compare/v1.2.0...v1.3.0)
|
|
25
|
+
|
|
26
|
+
## 1.2.0 2021-04-26
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- Add predicate and operation builder DSL (@oleander)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
[Compare v1.1.1...v1.2.0](https://github.com/dry-rb/dry-logic/compare/v1.1.1...v1.2.0)
|
|
35
|
+
|
|
3
36
|
## 1.1.1 2021-04-14
|
|
4
37
|
|
|
5
38
|
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!--- this file is synced from dry-rb/template-gem project -->
|
|
1
2
|
[gem]: https://rubygems.org/gems/dry-logic
|
|
2
3
|
[actions]: https://github.com/dry-rb/dry-logic/actions
|
|
3
4
|
[codacy]: https://www.codacy.com/gh/dry-rb/dry-logic
|
|
@@ -10,19 +11,19 @@
|
|
|
10
11
|
[][actions]
|
|
11
12
|
[][codacy]
|
|
12
13
|
[][codacy]
|
|
13
|
-
[][inchpages]
|
|
14
15
|
|
|
15
16
|
## Links
|
|
16
17
|
|
|
17
|
-
* [User documentation](
|
|
18
|
+
* [User documentation](https://dry-rb.org/gems/dry-logic)
|
|
18
19
|
* [API documentation](http://rubydoc.info/gems/dry-logic)
|
|
19
20
|
|
|
20
21
|
## Supported Ruby versions
|
|
21
22
|
|
|
22
23
|
This library officially supports the following Ruby versions:
|
|
23
24
|
|
|
24
|
-
* MRI
|
|
25
|
-
* jruby
|
|
25
|
+
* MRI `>= 2.7.0`
|
|
26
|
+
* jruby `>= 9.3` (postponed until 2.7 is supported)
|
|
26
27
|
|
|
27
28
|
## License
|
|
28
29
|
|
data/dry-logic.gemspec
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# this file is managed by dry-rb/devtools project
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
# this file is synced from dry-rb/template-gem project
|
|
4
|
+
|
|
5
|
+
lib = File.expand_path("lib", __dir__)
|
|
5
6
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
|
-
require
|
|
7
|
+
require "dry/logic/version"
|
|
7
8
|
|
|
8
9
|
Gem::Specification.new do |spec|
|
|
9
|
-
spec.name =
|
|
10
|
+
spec.name = "dry-logic"
|
|
10
11
|
spec.authors = ["Piotr Solnica"]
|
|
11
12
|
spec.email = ["piotr.solnica@gmail.com"]
|
|
12
|
-
spec.license =
|
|
13
|
+
spec.license = "MIT"
|
|
13
14
|
spec.version = Dry::Logic::VERSION.dup
|
|
14
15
|
|
|
15
16
|
spec.summary = "Predicate logic with rule composition"
|
|
16
17
|
spec.description = spec.summary
|
|
17
|
-
spec.homepage =
|
|
18
|
+
spec.homepage = "https://dry-rb.org/gems/dry-logic"
|
|
18
19
|
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-logic.gemspec", "lib/**/*"]
|
|
19
|
-
spec.bindir =
|
|
20
|
+
spec.bindir = "bin"
|
|
20
21
|
spec.executables = []
|
|
21
|
-
spec.require_paths = [
|
|
22
|
+
spec.require_paths = ["lib"]
|
|
22
23
|
|
|
23
|
-
spec.metadata[
|
|
24
|
-
spec.metadata[
|
|
25
|
-
spec.metadata[
|
|
26
|
-
spec.metadata[
|
|
24
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
25
|
+
spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-logic/blob/main/CHANGELOG.md"
|
|
26
|
+
spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-logic"
|
|
27
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-logic/issues"
|
|
27
28
|
|
|
28
|
-
spec.required_ruby_version = ">= 2.
|
|
29
|
+
spec.required_ruby_version = ">= 2.7.0"
|
|
29
30
|
|
|
30
31
|
# to update dependencies edit project.yml
|
|
31
32
|
spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
|
|
32
|
-
spec.add_runtime_dependency "dry-core", "~> 0.
|
|
33
|
+
spec.add_runtime_dependency "dry-core", "~> 0.9", ">= 0.9"
|
|
34
|
+
spec.add_runtime_dependency "zeitwerk", "~> 2.6"
|
|
33
35
|
|
|
34
36
|
spec.add_development_dependency "bundler"
|
|
35
37
|
spec.add_development_dependency "rake"
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "singleton"
|
|
4
|
+
require "delegate"
|
|
5
|
+
|
|
6
|
+
module Dry
|
|
7
|
+
module Logic
|
|
8
|
+
module Builder
|
|
9
|
+
IGNORED_OPERATIONS = %i[
|
|
10
|
+
Abstract
|
|
11
|
+
Binary
|
|
12
|
+
Unary
|
|
13
|
+
].freeze
|
|
14
|
+
|
|
15
|
+
IGNORED_PREDICATES = [
|
|
16
|
+
:predicate
|
|
17
|
+
].freeze
|
|
18
|
+
|
|
19
|
+
# Predicate and operation builder
|
|
20
|
+
#
|
|
21
|
+
# @block [Proc]
|
|
22
|
+
# @return [Builder::Result]
|
|
23
|
+
# @example Check if input is zero
|
|
24
|
+
# is_zero = Dry::Logic::Builder.call do
|
|
25
|
+
# negation { lt?(0) ^ gt?(0) }
|
|
26
|
+
# end
|
|
27
|
+
#
|
|
28
|
+
# p is_zero.call(1) # => false
|
|
29
|
+
# p is_zero.call(0) # => true
|
|
30
|
+
# p is_zero.call(-1) # => false
|
|
31
|
+
def call(&context)
|
|
32
|
+
Context.instance.call(&context)
|
|
33
|
+
end
|
|
34
|
+
module_function :call
|
|
35
|
+
alias_method :build, :call
|
|
36
|
+
public :call, :build
|
|
37
|
+
|
|
38
|
+
class Context
|
|
39
|
+
include Dry::Logic
|
|
40
|
+
include Singleton
|
|
41
|
+
|
|
42
|
+
module Predicates
|
|
43
|
+
include Logic::Predicates
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @see Builder#call
|
|
47
|
+
def call(&context)
|
|
48
|
+
instance_eval(&context)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Defines custom predicate
|
|
52
|
+
#
|
|
53
|
+
# @name [Symbol] Name of predicate
|
|
54
|
+
# @Context [Proc]
|
|
55
|
+
def predicate(name, &context)
|
|
56
|
+
if singleton_class.method_defined?(name)
|
|
57
|
+
singleton_class.undef_method(name)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
prerdicate = Rule::Predicate.new(context)
|
|
61
|
+
|
|
62
|
+
define_singleton_method(name) do |*args|
|
|
63
|
+
prerdicate.curry(*args)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Defines methods for operations and predicates
|
|
68
|
+
def initialize
|
|
69
|
+
Operations.constants(false).each do |name|
|
|
70
|
+
next if IGNORED_OPERATIONS.include?(name)
|
|
71
|
+
|
|
72
|
+
operation = Operations.const_get(name)
|
|
73
|
+
|
|
74
|
+
define_singleton_method(name.downcase) do |*args, **kwargs, &block|
|
|
75
|
+
operation.new(*call(&block), *args, **kwargs)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
Predicates::Methods.instance_methods(false).each do |name|
|
|
80
|
+
unless IGNORED_PREDICATES.include?(name)
|
|
81
|
+
predicate(name, &Predicates[name])
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
data/lib/dry/logic/evaluator.rb
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "dry/logic/operations/abstract"
|
|
4
|
-
require "dry/logic/result"
|
|
5
|
-
|
|
6
3
|
module Dry
|
|
7
4
|
module Logic
|
|
8
5
|
module Operations
|
|
@@ -16,7 +13,7 @@ module Dry
|
|
|
16
13
|
success = results.all?(&:success?)
|
|
17
14
|
|
|
18
15
|
Result.new(success, id) do
|
|
19
|
-
[type, results.select(&:failure?).map
|
|
16
|
+
[type, results.select(&:failure?).map(&:to_ast)]
|
|
20
17
|
end
|
|
21
18
|
end
|
|
22
19
|
|
data/lib/dry/logic/predicates.rb
CHANGED
|
@@ -7,7 +7,24 @@ require "date"
|
|
|
7
7
|
module Dry
|
|
8
8
|
module Logic
|
|
9
9
|
module Predicates
|
|
10
|
+
# rubocop:disable Metrics/ModuleLength
|
|
10
11
|
module Methods
|
|
12
|
+
def self.uuid_format(version)
|
|
13
|
+
::Regexp.new(<<~FORMAT.chomp, ::Regexp::IGNORECASE)
|
|
14
|
+
\\A[0-9A-F]{8}-[0-9A-F]{4}-#{version}[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}\\z
|
|
15
|
+
FORMAT
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
UUIDv1 = uuid_format(1)
|
|
19
|
+
|
|
20
|
+
UUIDv2 = uuid_format(2)
|
|
21
|
+
|
|
22
|
+
UUIDv3 = uuid_format(3)
|
|
23
|
+
|
|
24
|
+
UUIDv4 = uuid_format(4)
|
|
25
|
+
|
|
26
|
+
UUIDv5 = uuid_format(5)
|
|
27
|
+
|
|
11
28
|
def [](name)
|
|
12
29
|
method(name)
|
|
13
30
|
end
|
|
@@ -203,32 +220,29 @@ module Dry
|
|
|
203
220
|
end
|
|
204
221
|
|
|
205
222
|
def case?(pattern, input)
|
|
223
|
+
# rubocop:disable Style/CaseEquality
|
|
206
224
|
pattern === input
|
|
225
|
+
# rubocop:enable Style/CaseEquality
|
|
207
226
|
end
|
|
208
227
|
|
|
209
228
|
def uuid_v1?(input)
|
|
210
|
-
|
|
211
|
-
format?(uuid_v1_format, input)
|
|
229
|
+
format?(UUIDv1, input)
|
|
212
230
|
end
|
|
213
231
|
|
|
214
232
|
def uuid_v2?(input)
|
|
215
|
-
|
|
216
|
-
format?(uuid_v2_format, input)
|
|
233
|
+
format?(UUIDv2, input)
|
|
217
234
|
end
|
|
218
235
|
|
|
219
236
|
def uuid_v3?(input)
|
|
220
|
-
|
|
221
|
-
format?(uuid_v3_format, input)
|
|
237
|
+
format?(UUIDv3, input)
|
|
222
238
|
end
|
|
223
239
|
|
|
224
240
|
def uuid_v4?(input)
|
|
225
|
-
|
|
226
|
-
format?(uuid_v4_format, input)
|
|
241
|
+
format?(UUIDv4, input)
|
|
227
242
|
end
|
|
228
243
|
|
|
229
244
|
def uuid_v5?(input)
|
|
230
|
-
|
|
231
|
-
format?(uuid_v5_format, input)
|
|
245
|
+
format?(UUIDv5, input)
|
|
232
246
|
end
|
|
233
247
|
|
|
234
248
|
def uri?(schemes, input)
|
|
@@ -236,6 +250,10 @@ module Dry
|
|
|
236
250
|
format?(uri_format, input)
|
|
237
251
|
end
|
|
238
252
|
|
|
253
|
+
def uri_rfc3986?(input)
|
|
254
|
+
format?(URI::RFC3986_Parser::RFC3986_URI, input)
|
|
255
|
+
end
|
|
256
|
+
|
|
239
257
|
def respond_to?(method, input)
|
|
240
258
|
input.respond_to?(method)
|
|
241
259
|
end
|
|
@@ -252,5 +270,6 @@ module Dry
|
|
|
252
270
|
other.extend(Methods)
|
|
253
271
|
end
|
|
254
272
|
end
|
|
273
|
+
# rubocop:enable Metrics/ModuleLength
|
|
255
274
|
end
|
|
256
275
|
end
|
data/lib/dry/logic/result.rb
CHANGED
|
@@ -11,6 +11,8 @@ module Dry
|
|
|
11
11
|
attr_reader :curried
|
|
12
12
|
|
|
13
13
|
def initialize(arity, curried)
|
|
14
|
+
super()
|
|
15
|
+
|
|
14
16
|
@arity = arity
|
|
15
17
|
@curried = curried
|
|
16
18
|
|
|
@@ -84,11 +86,11 @@ module Dry
|
|
|
84
86
|
end
|
|
85
87
|
|
|
86
88
|
module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
|
|
87
|
-
def initialize(*)
|
|
88
|
-
super
|
|
89
|
-
|
|
90
|
-
#{assignment}
|
|
91
|
-
end
|
|
89
|
+
def initialize(*) # def initialize(*)
|
|
90
|
+
super # super
|
|
91
|
+
#
|
|
92
|
+
#{assignment} # @arg0 = @args[0]
|
|
93
|
+
end # end
|
|
92
94
|
RUBY
|
|
93
95
|
end
|
|
94
96
|
|
|
@@ -114,17 +116,17 @@ module Dry
|
|
|
114
116
|
application = "@predicate[#{(curried_args + unapplied_args + splat).join(", ")}]"
|
|
115
117
|
|
|
116
118
|
module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
|
|
117
|
-
def call(#{parameters})
|
|
118
|
-
if #{application}
|
|
119
|
-
Result::SUCCESS
|
|
120
|
-
else
|
|
121
|
-
Result.new(false, id) { ast(#{parameters}) }
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
def [](#{parameters})
|
|
126
|
-
#{application}
|
|
127
|
-
end
|
|
119
|
+
def call(#{parameters}) # def call(input0, input1, *rest)
|
|
120
|
+
if #{application} # if @predicate[@arg0, @arg1, input0, input1, *rest]
|
|
121
|
+
Result::SUCCESS # ::Dry::Logic::Result::Success
|
|
122
|
+
else # else
|
|
123
|
+
Result.new(false, id) { ast(#{parameters}) } # ::Dry::Logic::Result.new(false, id) { ast(input0, input1, *rest) }
|
|
124
|
+
end # end
|
|
125
|
+
end # end
|
|
126
|
+
#
|
|
127
|
+
def [](#{parameters}) # def [](@arg0, @arg1, input0, input1, *rest)
|
|
128
|
+
#{application} # @predicate[@arg0, @arg1, input0, input1, *rest]
|
|
129
|
+
end # end
|
|
128
130
|
RUBY
|
|
129
131
|
end
|
|
130
132
|
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "dry/logic/rule"
|
|
4
|
-
|
|
5
3
|
module Dry
|
|
6
4
|
module Logic
|
|
7
|
-
class Rule
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
class Rule
|
|
6
|
+
class Predicate < Rule
|
|
7
|
+
def self.specialize(arity, curried, base = Predicate)
|
|
8
|
+
super
|
|
9
|
+
end
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
def type
|
|
12
|
+
:predicate
|
|
13
|
+
end
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
def name
|
|
16
|
+
predicate.name
|
|
17
|
+
end
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
def to_s
|
|
20
|
+
if args.empty?
|
|
21
|
+
name.to_s
|
|
22
|
+
else
|
|
23
|
+
"#{name}(#{args.map(&:inspect).join(", ")})"
|
|
24
|
+
end
|
|
25
25
|
end
|
|
26
|
-
end
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
def ast(input = Undefined)
|
|
28
|
+
[type, [name, args_with_names(input)]]
|
|
29
|
+
end
|
|
30
|
+
alias_method :to_ast, :ast
|
|
30
31
|
end
|
|
31
|
-
alias_method :to_ast, :ast
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
end
|
data/lib/dry/logic/rule.rb
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "concurrent/map"
|
|
4
|
-
require "dry/core/constants"
|
|
5
|
-
require "dry/core/equalizer"
|
|
6
|
-
require "dry/logic/operations"
|
|
7
|
-
require "dry/logic/result"
|
|
8
|
-
require "dry/logic/rule/interface"
|
|
9
4
|
|
|
10
5
|
module Dry
|
|
11
6
|
module Logic
|
|
@@ -78,7 +73,7 @@ module Dry
|
|
|
78
73
|
end
|
|
79
74
|
|
|
80
75
|
def eval_args(object)
|
|
81
|
-
with(args: args.map { |arg| UnboundMethod
|
|
76
|
+
with(args: args.map { |arg| arg.is_a?(UnboundMethod) ? arg.bind(object).() : arg })
|
|
82
77
|
end
|
|
83
78
|
|
|
84
79
|
def with(new_opts)
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "dry/core/constants"
|
|
4
|
-
|
|
5
|
-
require "dry/logic/rule"
|
|
6
|
-
require "dry/logic/rule/predicate"
|
|
7
|
-
|
|
8
3
|
module Dry
|
|
9
4
|
module Logic
|
|
10
5
|
class RuleCompiler
|
|
11
|
-
include Core::Constants
|
|
12
|
-
|
|
13
6
|
attr_reader :predicates
|
|
14
7
|
|
|
15
8
|
def initialize(predicates)
|
data/lib/dry/logic/version.rb
CHANGED
data/lib/dry/logic.rb
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
require "zeitwerk"
|
|
4
|
+
require "dry/core"
|
|
5
|
+
|
|
5
6
|
module Dry
|
|
6
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
|
|
7
24
|
end
|
|
8
25
|
end
|
|
9
|
-
|
|
10
|
-
require "dry/logic/rule/predicate"
|
|
11
|
-
require "dry/logic/operations"
|
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: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Piotr Solnica
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-10-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|
|
@@ -30,20 +30,34 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0.
|
|
33
|
+
version: '0.9'
|
|
34
34
|
- - ">="
|
|
35
35
|
- !ruby/object:Gem::Version
|
|
36
|
-
version: '0.
|
|
36
|
+
version: '0.9'
|
|
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.
|
|
43
|
+
version: '0.9'
|
|
44
44
|
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '0.
|
|
46
|
+
version: '0.9'
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: zeitwerk
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '2.6'
|
|
54
|
+
type: :runtime
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '2.6'
|
|
47
61
|
- !ruby/object:Gem::Dependency
|
|
48
62
|
name: bundler
|
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -100,8 +114,8 @@ files:
|
|
|
100
114
|
- lib/dry-logic.rb
|
|
101
115
|
- lib/dry/logic.rb
|
|
102
116
|
- lib/dry/logic/appliable.rb
|
|
117
|
+
- lib/dry/logic/builder.rb
|
|
103
118
|
- lib/dry/logic/evaluator.rb
|
|
104
|
-
- lib/dry/logic/operations.rb
|
|
105
119
|
- lib/dry/logic/operations/abstract.rb
|
|
106
120
|
- lib/dry/logic/operations/and.rb
|
|
107
121
|
- lib/dry/logic/operations/attr.rb
|
|
@@ -128,10 +142,10 @@ licenses:
|
|
|
128
142
|
- MIT
|
|
129
143
|
metadata:
|
|
130
144
|
allowed_push_host: https://rubygems.org
|
|
131
|
-
changelog_uri: https://github.com/dry-rb/dry-logic/blob/
|
|
145
|
+
changelog_uri: https://github.com/dry-rb/dry-logic/blob/main/CHANGELOG.md
|
|
132
146
|
source_code_uri: https://github.com/dry-rb/dry-logic
|
|
133
147
|
bug_tracker_uri: https://github.com/dry-rb/dry-logic/issues
|
|
134
|
-
post_install_message:
|
|
148
|
+
post_install_message:
|
|
135
149
|
rdoc_options: []
|
|
136
150
|
require_paths:
|
|
137
151
|
- lib
|
|
@@ -139,15 +153,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
139
153
|
requirements:
|
|
140
154
|
- - ">="
|
|
141
155
|
- !ruby/object:Gem::Version
|
|
142
|
-
version: 2.
|
|
156
|
+
version: 2.7.0
|
|
143
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
158
|
requirements:
|
|
145
159
|
- - ">="
|
|
146
160
|
- !ruby/object:Gem::Version
|
|
147
161
|
version: '0'
|
|
148
162
|
requirements: []
|
|
149
|
-
rubygems_version: 3.
|
|
150
|
-
signing_key:
|
|
163
|
+
rubygems_version: 3.3.7
|
|
164
|
+
signing_key:
|
|
151
165
|
specification_version: 4
|
|
152
166
|
summary: Predicate logic with rule composition
|
|
153
167
|
test_files: []
|
data/lib/dry/logic/operations.rb
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "dry/logic/operations/and"
|
|
4
|
-
require "dry/logic/operations/or"
|
|
5
|
-
require "dry/logic/operations/xor"
|
|
6
|
-
require "dry/logic/operations/implication"
|
|
7
|
-
require "dry/logic/operations/negation"
|
|
8
|
-
|
|
9
|
-
require "dry/logic/operations/key"
|
|
10
|
-
require "dry/logic/operations/attr"
|
|
11
|
-
require "dry/logic/operations/each"
|
|
12
|
-
require "dry/logic/operations/set"
|
|
13
|
-
require "dry/logic/operations/check"
|
|
14
|
-
|
|
15
|
-
require "dry/logic/operators"
|