wongi-engine 0.0.11 → 0.0.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ae5e5e3f2683835f9cc181b8c5edcf06245a61e
4
- data.tar.gz: c6fe8127c68c416904044459132476b06fef46f3
3
+ metadata.gz: f64f3af9dd931ad41bf4e2ec9b9da00d8a39b5d6
4
+ data.tar.gz: 3f447b1c151f3d353370c9437dcfdd578a15f4c7
5
5
  SHA512:
6
- metadata.gz: 8fc1bc5e6e5e85ee8a4282e4a56be5f2bd2c59e3d1c0dc23e60a85b5b97fe3d552798778f4cae4211a01fea1a400e4a0bac629cb11b34a3c0c586a7f37b34e8d
7
- data.tar.gz: 01ab14f7f0e0616b26afd687ba060938154f5408c87b1944ed9e888ebf646839a2536854d579219b9254d8c48946b548e98a52e77908058cdd94ad26229c3c62
6
+ metadata.gz: 59a07a77cefe0df4bc7785dcbd3da631f8560709c5ab4780198e8577c59f39ba95bc006c9c66dd21fdfd853d8e47ef4ed70101602462fc817a03ab08f3cbe0b9
7
+ data.tar.gz: dcc37f6dd8324b719bb79cf17a44f3e025bf287dfbc0e70decfb31c9815bd72a5bb82c523c1a9963be1d1706107af3d1f50b495d9659fec88fb8b6f0e958ec4c
data/README.md CHANGED
@@ -448,6 +448,10 @@ The Rete implementation in this library largely follows the outline presented in
448
448
 
449
449
  ## Changelog
450
450
 
451
+ ### 0.0.12
452
+
453
+ * fixed another NCC bug
454
+
451
455
  ### 0.0.11
452
456
 
453
457
  * fixed cleanup of invalidated NCC branches
@@ -33,6 +33,7 @@ module Wongi
33
33
  t.node = self
34
34
  tokens << t
35
35
  partner.tokens.each do |ncc_token|
36
+ next unless ncc_token.ancestors.find { |a| a.equal? token }
36
37
  t.ncc_results << ncc_token
37
38
  ncc_token.owner = t
38
39
  end
@@ -1,5 +1,5 @@
1
1
  module Wongi
2
2
  module Engine
3
- VERSION = "0.0.11"
3
+ VERSION = "0.0.12"
4
4
  end
5
5
  end
@@ -97,24 +97,78 @@ describe "NCC rule" do
97
97
  engine << [:poweruser, :priority, 3]
98
98
  engine << [:god, :priority, 4]
99
99
 
100
- puts "<- MANUAL"
101
100
  engine << [:user, :want_action_for, :light_bathroom]
102
101
  engine << [:user, :light_bathroom, :off]
103
102
  expect( engine.select(:light_bathroom, :value, :_) ).to be == [ Wongi::Engine::WME.new(:light_bathroom, :value, :off) ]
104
103
  expect( engine.select(:light_bathroom, :last_user, :_) ).to be == [ Wongi::Engine::WME.new(:light_bathroom, :last_user, :user) ]
105
104
 
106
- puts "\n<- AUTOMATIC"
107
105
  engine << [:light_kitchen, :value, :on]
108
106
  expect( engine.select(:light_bathroom, :value, :_) ).to be == [ Wongi::Engine::WME.new(:light_bathroom, :value, :on) ]
109
107
  expect( engine.select(:light_bathroom, :last_user, :_) ).to be == [ Wongi::Engine::WME.new(:light_bathroom, :last_user, :rule1) ]
110
108
 
111
- puts "\n<- POWER USER"
112
109
  engine << [:poweruser, :want_action_for, :light_bathroom]
113
110
  engine << [:poweruser, :light_bathroom, :super_on]
114
111
  expect( engine.select(:light_bathroom, :value, :_) ).to be == [ Wongi::Engine::WME.new(:light_bathroom, :value, :super_on) ]
115
112
  expect( engine.select(:light_bathroom, :last_user, :_) ).to be == [ Wongi::Engine::WME.new(:light_bathroom, :last_user, :poweruser) ]
116
113
 
117
- puts "\n<- GOD"
114
+ engine << [:god, :want_action_for, :light_bathroom]
115
+ engine << [:god, :light_bathroom, :let_there_be_light]
116
+ expect( engine.select(:light_bathroom, :value, :_) ).to be == [ Wongi::Engine::WME.new(:light_bathroom, :value, :let_there_be_light) ]
117
+ expect( engine.select(:light_bathroom, :last_user, :_) ).to be == [ Wongi::Engine::WME.new(:light_bathroom, :last_user, :god) ]
118
+
119
+ end
120
+
121
+ it 'should clean up correctly with a different activation order' do
122
+
123
+ engine.rule :rule1 do
124
+ forall {
125
+ has :light_kitchen, :value, :on
126
+ }
127
+ make {
128
+ #trace values: true, generation: true
129
+ gen self.name, :light_bathroom, :on
130
+ gen self.name, :want_action_for, :light_bathroom
131
+ }
132
+ end
133
+
134
+ prod = engine.rule "action" do
135
+ forall {
136
+ has :Requestor, :want_action_for, :Actor
137
+ has :Requestor, :Actor, :Value
138
+ has :Requestor, :priority, :Priority
139
+ ncc {
140
+ has :OtherRequestor, :want_action_for, :Actor
141
+ diff :OtherRequestor, :Requestor
142
+ has :OtherRequestor, :priority, :OtherPriority
143
+ greater :OtherPriority, :Priority
144
+ }
145
+ }
146
+ make {
147
+ #trace values: true, generation: true
148
+ gen :Actor, :value, :Value
149
+ gen :Actor, :last_user, :Requestor
150
+ }
151
+ end
152
+
153
+ engine << [:user, :priority, 2]
154
+ engine << [:rule1, :priority, 1]
155
+ engine << [:poweruser, :priority, 3]
156
+ engine << [:god, :priority, 4]
157
+
158
+ engine << [:user, :want_action_for, :light_bathroom]
159
+ engine << [:user, :light_bathroom, :off]
160
+ expect( engine.select(:light_bathroom, :value, :_) ).to be == [ Wongi::Engine::WME.new(:light_bathroom, :value, :off) ]
161
+ expect( engine.select(:light_bathroom, :last_user, :_) ).to be == [ Wongi::Engine::WME.new(:light_bathroom, :last_user, :user) ]
162
+
163
+ engine << [:light_kitchen, :value, :on]
164
+ expect( engine.select(:light_bathroom, :value, :_) ).to be == [ Wongi::Engine::WME.new(:light_bathroom, :value, :off) ]
165
+ expect( engine.select(:light_bathroom, :last_user, :_) ).to be == [ Wongi::Engine::WME.new(:light_bathroom, :last_user, :user) ]
166
+
167
+ engine << [:poweruser, :want_action_for, :light_bathroom]
168
+ engine << [:poweruser, :light_bathroom, :super_on]
169
+ expect( engine.select(:light_bathroom, :value, :_) ).to be == [ Wongi::Engine::WME.new(:light_bathroom, :value, :super_on) ]
170
+ expect( engine.select(:light_bathroom, :last_user, :_) ).to be == [ Wongi::Engine::WME.new(:light_bathroom, :last_user, :poweruser) ]
171
+
118
172
  engine << [:god, :want_action_for, :light_bathroom]
119
173
  engine << [:god, :light_bathroom, :let_there_be_light]
120
174
  expect( engine.select(:light_bathroom, :value, :_) ).to be == [ Wongi::Engine::WME.new(:light_bathroom, :value, :let_there_be_light) ]
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.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valeri Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-18 00:00:00.000000000 Z
11
+ date: 2013-10-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A rule engine.
14
14
  email: