wongi-engine 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b61e762202c7ce3d0abda3c806736d35ff540fdc
4
- data.tar.gz: 1661ab89b84bff2380fd7514be8380066fc92358
3
+ metadata.gz: 238a6f83b8af5a38b48e0e06b8a1a4b34472dcc4
4
+ data.tar.gz: a1826dcf7db1926d949c71a4aa8e68d916a0640e
5
5
  SHA512:
6
- metadata.gz: aaf20be03f915512942d39b2b12863d581a9875c481c7321e2e515504b9c20d93a5be66abbeec84be600b6c8c6766c2615c2fc43eed8764d7ca8464796ffa434
7
- data.tar.gz: eda9d3711b0b62331cb195989159352b96d0a5eaaf0d6366292971e81264a990949fb076109bb0d6fc402d9e2fd15714f83c51387763613453defe663825e0a7
6
+ metadata.gz: 20f72033efe83f6244077dc6c21beee64c97d0789189dfb2242b310e9bda364477d12dc225e38bd6536b58ed659d354812b569332ff0c17ea6b6bfeb23f0ee4f
7
+ data.tar.gz: 46092efbaac6f4d1fbb7ff1c1f84d49af172be4593a11620ea911183498f420cded7ddc584e2c54624fe92b8aadb109fe322af196f02055cb1d0416339f7a785
data/.hgignore CHANGED
@@ -4,3 +4,4 @@ Gemfile.lock
4
4
  .rspec
5
5
  .ruby-version
6
6
 
7
+ pkg/*
data/.hgtags CHANGED
@@ -12,3 +12,4 @@ a2f9d52603db027baced51f673daf46b8fe8745a v0.2.9
12
12
  a2f9d52603db027baced51f673daf46b8fe8745a v0.2.9
13
13
  da4529420721bdd153839261e624b3738e7355e9 v0.2.9
14
14
  6db5e2b3978269c475ec03f45bdfb477ca70b427 v0.3.0
15
+ b5c5b166f6a7375da3a3702667be6e16d43862bd v0.3.1
data/README.md CHANGED
@@ -1,19 +1,20 @@
1
1
  # Wongi::Engine
2
2
 
3
- [![Join the chat at https://gitter.im/ulfurinn/wongi-engine](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ulfurinn/wongi-engine?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
3
+ [![Gem](https://img.shields.io/gem/v/wongi-engine.svg)](https://rubygems.org/gems/wongi-engine/)
4
+ [![Build Status](https://travis-ci.org/ulfurinn/wongi-engine.svg?branch=master)](https://travis-ci.org/ulfurinn/wongi-engine)
4
5
 
5
- [![Build Status](https://travis-ci.org/ulfurinn/wongi-engine.svg?branch=master)](https://travis-ci.org/ulfurinn/wongi-engine) (MRI 1.9.3 to 2.3, Rubinius, JRuby)
6
+ Ruby >= 2.1 and JRuby are supported. Rubinius should work but isn't actively supported.
6
7
 
7
- [Feature annoucements](https://github.com/ulfurinn/wongi-engine/issues?q=is%3Aopen+is%3Aissue+label%3Aannoucement)
8
-
9
- [Open discussions](https://github.com/ulfurinn/wongi-engine/issues?q=is%3Aopen+is%3Aissue+label%3Adiscussion)
10
-
11
- [Tutorial](http://ulfurinn.github.io/wongi-engine/)
8
+ ## [Documentation](http://ulfurinn.github.io/wongi-engine/)
12
9
 
13
10
  This library contains a rule engine written in Ruby. It's based on the [Rete algorithm](http://en.wikipedia.org/wiki/Rete_algorithm) and uses a DSL to express rules in a readable way.
14
11
 
15
12
  **Word of caution**: this is complex and fragile machinery, and there may be subtle bugs that are only revealed with nontrivial usage. Be conservative with upgrades, test your rules extensively, and please report any behaviour that is not consistent with your expectations.
16
13
 
14
+ [Feature annoucements](https://github.com/ulfurinn/wongi-engine/issues?q=is%3Aopen+is%3Aissue+label%3Aannoucement)
15
+
16
+ [Open discussions](https://github.com/ulfurinn/wongi-engine/issues?q=is%3Aopen+is%3Aissue+label%3Adiscussion)
17
+
17
18
  ## Acknowledgements
18
19
 
19
20
  The Rete implementation in this library largely follows the outline presented in [\[Doorenbos, 1995\]](http://reports-archive.adm.cs.cmu.edu/anon/1995/CMU-CS-95-113.pdf).
@@ -26,7 +26,7 @@ module Wongi
26
26
  assignment = token[ self.variable ]
27
27
  field = wme.send( self.field )
28
28
  #field.nil? ||
29
- assignment && field == assignment
29
+ !token.has_var?(self.variable) || field == assignment
30
30
  end
31
31
 
32
32
  def equivalent? other
@@ -1,5 +1,5 @@
1
1
  module Wongi
2
2
  module Engine
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe "ANY rule" do
4
+
5
+ include Wongi::Engine::DSL
6
+
7
+ before :each do
8
+ @engine = Wongi::Engine.create
9
+ end
10
+
11
+ def engine
12
+ @engine
13
+ end
14
+
15
+ context 'with two options' do
16
+
17
+ let :production do
18
+ engine << rule do
19
+ forall {
20
+ any {
21
+ option {
22
+ has :A, :path1, :_
23
+ }
24
+ option {
25
+ has :A, :path2, :_
26
+ }
27
+ }
28
+ }
29
+ end
30
+ end
31
+
32
+ it 'should fire on the first path' do
33
+ engine << [:x, :path1, true]
34
+ expect(production.tokens).to have(1).item
35
+ end
36
+
37
+ it 'should fire on the second path' do
38
+ engine << [:x, :path2, true]
39
+ expect(production.tokens).to have(1).item
40
+ end
41
+
42
+ it 'should fire twice on both paths at once' do
43
+ engine << [:x, :path1, true]
44
+ engine << [:x, :path2, true]
45
+ expect(production.tokens).to have(2).items
46
+ end
47
+
48
+ end
49
+
50
+ 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.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valeri Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-24 00:00:00.000000000 Z
11
+ date: 2017-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -160,6 +160,7 @@ files:
160
160
  - spec/rule_specs/maybe_rule_spec.rb
161
161
  - spec/rule_specs/ncc_spec.rb
162
162
  - spec/rule_specs/negative_rule_spec.rb
163
+ - spec/rule_specs/or_rule_spec.rb
163
164
  - spec/ruleset_spec.rb
164
165
  - spec/simple_action_spec.rb
165
166
  - spec/spec_helper.rb
@@ -206,6 +207,7 @@ test_files:
206
207
  - spec/rule_specs/maybe_rule_spec.rb
207
208
  - spec/rule_specs/ncc_spec.rb
208
209
  - spec/rule_specs/negative_rule_spec.rb
210
+ - spec/rule_specs/or_rule_spec.rb
209
211
  - spec/ruleset_spec.rb
210
212
  - spec/simple_action_spec.rb
211
213
  - spec/spec_helper.rb