wongi-engine 0.2.6 → 0.2.7

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: 046a3edb6e6950fdf204e986680485e598115937
4
- data.tar.gz: c5c71da579f11287bf316ee0ecabfc3af6affa47
3
+ metadata.gz: 51fa3bdb2ee8d509f179b467564af30d9922b13a
4
+ data.tar.gz: 1736ff23ea8708629ef21ed3eb877fa39116f250
5
5
  SHA512:
6
- metadata.gz: 1e0b329d153820ae40118ae0cbb4ee393b2bf5ba719ca52b48240e8e3d0ddfd3c2e32ba22ece4596097f8d96d4c037a38dc429f970993aea3c15d7c277335ae6
7
- data.tar.gz: 45eda6aca07f7a5e7afb8bce48ed27515eab42879319908f00860bea61a4183dd901363f77895a822c865dd5a9cd9d32064f40d3e7f8d849746966fc3b4dd55d
6
+ metadata.gz: 40b30715a6e2b89e9a2a6ea4ce52a40ce48f3fc78860bd2ada3431ad45228c953590b8be25d3cdff66280bdd201837da8eaeb48934da0111a315d6fe7f6b6f91
7
+ data.tar.gz: bfc4f7e1d7e2b22cb8dac7d1845fcabdf069b3f0ba4786a2f9d8a9df5738d154b82cedb2f1ec1868690ecc12c1675bd46cfb46c54408d48ea9b1879e99df0e77
@@ -6,6 +6,7 @@ rvm:
6
6
  - 2.2
7
7
  - 2.3.0
8
8
  - rbx-2.5.8
9
+ - rbx-3.14
9
10
  - jruby-9.0
10
11
  sudo: false
11
12
  notifications:
@@ -42,16 +42,12 @@ module Wongi
42
42
  end
43
43
 
44
44
  def ncc_activate token
45
- token.deleted = false
46
- token.overlay.add_token(token, self)
47
45
  children.each do |child|
48
46
  child.beta_activate Token.new( child, token, nil, { } )
49
47
  end
50
48
  end
51
49
 
52
50
  def ncc_deactivate token
53
- token.overlay.remove_token(token, self)
54
- token.deleted!
55
51
  children.each do |beta|
56
52
  beta.tokens.select { |t| t.parent == token }.each do |t|
57
53
  beta.beta_deactivate t
@@ -21,9 +21,11 @@ module Wongi
21
21
  token = tokens.find { |tok| tok.parent == t }
22
22
  return unless token
23
23
  token.overlay.remove_token(token, self)
24
- token.owner.ncc_results.delete token
25
- if token.owner.ncc_results.empty?
26
- ncc.ncc_activate token.owner
24
+ if owner = token.owner
25
+ owner.ncc_results.delete token
26
+ if owner.ncc_results.empty?
27
+ ncc.ncc_activate owner
28
+ end
27
29
  end
28
30
  end
29
31
 
@@ -1,5 +1,5 @@
1
1
  module Wongi
2
2
  module Engine
3
- VERSION = "0.2.6"
3
+ VERSION = "0.2.7"
4
4
  end
5
5
  end
@@ -57,7 +57,7 @@ describe "issue 4" do
57
57
  end
58
58
 
59
59
  # cascaded processing affects this
60
- it "should not retract later items from within a rule", :debug do
60
+ it "should not retract later items from within a rule" do
61
61
 
62
62
  engine = Wongi::Engine.create
63
63
 
@@ -47,7 +47,7 @@ describe Wongi::Engine::DSL::Action::StatementGenerator do
47
47
  engine << %w( Claire relative Dwight )
48
48
  end
49
49
 
50
- it 'should be created', :debug do
50
+ it 'should be created' do
51
51
  expect( production ).to have(2).tokens
52
52
  expect( engine.find *%w( Alice relative Dwight ) ).not_to be_nil
53
53
  end
@@ -34,7 +34,7 @@ describe "ASSIGN rule" do
34
34
 
35
35
  end
36
36
 
37
- it 'should be deactivatable', :debug do
37
+ it 'should be deactivatable' do
38
38
 
39
39
  prod = engine << rule {
40
40
  forall {
@@ -52,7 +52,7 @@ describe "MAYBE rule" do
52
52
 
53
53
  end
54
54
 
55
- it 'should pass with retracted facts', :debug do
55
+ it 'should pass with retracted facts' do
56
56
 
57
57
  prod = engine << maybe_rule
58
58
 
@@ -209,4 +209,55 @@ describe Wongi::Engine::NccNode do
209
209
 
210
210
  end
211
211
 
212
+ it 'should ncc-deactivate without destroying tokens' do
213
+ engine << rule {
214
+ forall {
215
+ has :Student, :is_a, :student
216
+ has :Course, :is_a, :course
217
+ none {
218
+ has :Requirement, :is_a, :requirement
219
+ has :Course, :Requirement, :RequiredGrade
220
+ any {
221
+ option {
222
+ neg :Student, :Requirement, :_
223
+ }
224
+ option {
225
+ has :Student, :Requirement, :ReceivedGrade
226
+ less :ReceivedGrade, :RequiredGrade
227
+ }
228
+ }
229
+ }
230
+ }
231
+ make {
232
+ gen :Student, :passes_for, :Course
233
+ }
234
+ }
235
+
236
+ File.open "rete.dot", "w" do |io|
237
+ Wongi::Engine::Graph.new( engine ).dot( io )
238
+ end
239
+
240
+
241
+ %w( math science english bio ).each { |req| engine << [ req, :is_a, :requirement ] }
242
+ %w( CourseA CourseB CourseC ).each { |course| engine << [ course, :is_a, :course ] }
243
+ engine << [ "StudentA", :is_a, :student ]
244
+
245
+ engine << ["CourseA", "math", 50]
246
+ engine << ["CourseA", "science", 50]
247
+
248
+ engine << ["CourseB", "math", 50]
249
+ engine << ["CourseB", "english", 50]
250
+
251
+ engine << ["CourseC", "math", 50]
252
+ engine << ["CourseC", "bio", 50]
253
+
254
+ engine << ["StudentA", "math", 60]
255
+ engine << ["StudentA", "science", 60]
256
+ engine << ["StudentA", "bio", 40]
257
+
258
+ expect(engine.find "StudentA", :passes_for, "CourseA").not_to be_nil
259
+ expect(engine.find "StudentA", :passes_for, "CourseB").to be_nil
260
+ expect(engine.find "StudentA", :passes_for, "CourseC").to be_nil
261
+ end
262
+
212
263
  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.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valeri Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-12 00:00:00.000000000 Z
11
+ date: 2016-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  requirements: []
186
186
  rubyforge_project:
187
- rubygems_version: 2.4.8
187
+ rubygems_version: 2.5.1
188
188
  signing_key:
189
189
  specification_version: 4
190
190
  summary: A forward-chaining rule engine in pure Ruby.