wongi-engine 0.3.5 → 0.3.6
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/.travis.yml +8 -5
- data/lib/wongi-engine/compiler.rb +1 -1
- data/lib/wongi-engine/version.rb +1 -1
- data/spec/rule_specs/any_rule_spec.rb +69 -0
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d9f803da98de1a0ec47f26a1adc83940f6ef2d3e8dbfc3dbfb9527c9efe4daf
|
4
|
+
data.tar.gz: 3d1ace03974a04999b3e4f969c64d0bad2b4da99dc11606db06b1723d056b881
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7d0c9d09716e02cb60256f048b97d04742733e8587c110a8e3b80b0f641e0bc213f8a3baea543f89a3f4f454a7f9f987321b66b0ed6decd530d7ec568cdbe11
|
7
|
+
data.tar.gz: e5e3f2158f9975ad23aa7c4115886c17c4b92529967d97395f39c7a28d608dcf2adc7827cecdc9b6bcb1dd8200699c9ad61c8997e638c07cb15534bdbaa61701
|
data/.travis.yml
CHANGED
@@ -49,7 +49,7 @@ module Wongi::Engine
|
|
49
49
|
def join_node(condition, tests, assignment)
|
50
50
|
alpha = rete.compile_alpha(condition)
|
51
51
|
beta_memory
|
52
|
-
self.node = if existing = node.children.find { |n| n.is_a?(JoinNode) && n.equivalent?(alpha, tests, assignment) }
|
52
|
+
self.node = if existing = node.children.find { |n| n.is_a?(JoinNode) && n.equivalent?(alpha, tests, assignment) && !n.children.map(&:class).include?(Wongi::Engine::OrNode) }
|
53
53
|
existing
|
54
54
|
else
|
55
55
|
JoinNode.new(node, tests, assignment).tap do |join|
|
data/lib/wongi-engine/version.rb
CHANGED
@@ -106,4 +106,73 @@ describe "ANY rule" do
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
+
describe "ordering rules" do
|
110
|
+
let :any_stale_pastry_rule do
|
111
|
+
rule do
|
112
|
+
forall {
|
113
|
+
# has :A, :name, :Name # uncomment this line will make test pass
|
114
|
+
any {
|
115
|
+
option {
|
116
|
+
has :A, :name, 'Donut'
|
117
|
+
}
|
118
|
+
option {
|
119
|
+
has :A, :name, 'Cookie'
|
120
|
+
}
|
121
|
+
}
|
122
|
+
has :A, :condition, 'stale' # moving this line above 'any' will make test pass
|
123
|
+
}
|
124
|
+
make {
|
125
|
+
collect :A, :stale_pastries
|
126
|
+
}
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
let :fresh_donut_rule do
|
131
|
+
rule do
|
132
|
+
forall {
|
133
|
+
has :A, :name, 'Donut'
|
134
|
+
has :A, :condition, 'fresh'
|
135
|
+
}
|
136
|
+
make {
|
137
|
+
collect :A, :fresh_donuts
|
138
|
+
}
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
let :fresh_cookie_rule do
|
143
|
+
rule do
|
144
|
+
forall {
|
145
|
+
# swapping the following lines will make test pass
|
146
|
+
has :A, :name, 'Cookie'
|
147
|
+
has :A, :condition, 'fresh'
|
148
|
+
}
|
149
|
+
make {
|
150
|
+
collect :A, :fresh_cookies
|
151
|
+
}
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
before do
|
156
|
+
engine << any_stale_pastry_rule # commenting this rule, or moving it to end of rules will make test pass
|
157
|
+
|
158
|
+
engine << fresh_donut_rule
|
159
|
+
engine << fresh_cookie_rule # commenting this rule will make test pass
|
160
|
+
|
161
|
+
engine << [:donut, :name, 'Donut']
|
162
|
+
engine << [:donut, :condition, 'fresh']
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'has no fresh cookies' do
|
166
|
+
# this expectation fails; the collection contains [:donut]!
|
167
|
+
expect(engine.collection(:fresh_cookies)).to match_array([])
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'has one fresh donut' do
|
171
|
+
expect(engine.collection(:fresh_donuts)).to match_array([:donut])
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'has no stale pastries' do
|
175
|
+
expect(engine.collection(:stale_pastries)).to match_array([])
|
176
|
+
end
|
177
|
+
end
|
109
178
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wongi-engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valeri Sokolov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -175,7 +175,7 @@ homepage: https://github.com/ulfurinn/wongi-engine
|
|
175
175
|
licenses:
|
176
176
|
- MIT
|
177
177
|
metadata: {}
|
178
|
-
post_install_message:
|
178
|
+
post_install_message:
|
179
179
|
rdoc_options: []
|
180
180
|
require_paths:
|
181
181
|
- lib
|
@@ -190,9 +190,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
190
|
- !ruby/object:Gem::Version
|
191
191
|
version: '0'
|
192
192
|
requirements: []
|
193
|
-
|
194
|
-
|
195
|
-
signing_key:
|
193
|
+
rubygems_version: 3.1.4
|
194
|
+
signing_key:
|
196
195
|
specification_version: 4
|
197
196
|
summary: A forward-chaining rule engine in pure Ruby.
|
198
197
|
test_files:
|