wongi-engine 0.2.5 → 0.2.6

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: 75b1a6b44b359535d99db9e482a8998664e3a1a7
4
- data.tar.gz: e2f317eb93bb265d7c2e9b4c2562b3125bd8c806
3
+ metadata.gz: 046a3edb6e6950fdf204e986680485e598115937
4
+ data.tar.gz: c5c71da579f11287bf316ee0ecabfc3af6affa47
5
5
  SHA512:
6
- metadata.gz: f8be02f55015cc7cf669a7793635701a3bf23ba211189550f8b0ecc2038c321abcdd752cb8cec065b376002cd675c933a513f4a04d954f6008323dddf5494a91
7
- data.tar.gz: 3f45314a22d991abc32dc99b43e001769a0ef1de7a0147b05e85125db809bc41fc7896bb9941d3022deff04ab5cc1e63f9c1c4ca821f31c3213f49e5dfbaa8a3
6
+ metadata.gz: 1e0b329d153820ae40118ae0cbb4ee393b2bf5ba719ca52b48240e8e3d0ddfd3c2e32ba22ece4596097f8d96d4c037a38dc429f970993aea3c15d7c277335ae6
7
+ data.tar.gz: 45eda6aca07f7a5e7afb8bce48ed27515eab42879319908f00860bea61a4183dd901363f77895a822c865dd5a9cd9d32064f40d3e7f8d849746966fc3b4dd55d
data/.hgtags CHANGED
@@ -4,5 +4,3 @@ accab6252d5746dafe847935ad55f8500594d0cc v0.1.1
4
4
  0000000000000000000000000000000000000000 v0.1.1
5
5
  80964eb067a8445980b27e871731ff1274bd7be2 v0.2.1
6
6
  808537c4e3a2defd382fd8f0a662f8850c70aa1f v0.2.2
7
- 716eb2e4a77f3caae8557591f5c53b9bc2fb3a26 v0.2.5
8
- 9da0b0c9c3a82804345e9b7f97867e5df2f4d848 v0.2.5
data/CHANGELOG.md ADDED
@@ -0,0 +1,94 @@
1
+ # Changelog
2
+
3
+ ## 0.2.6
4
+
5
+ * fixed `Network#each`
6
+
7
+ ## 0.2.5
8
+
9
+ * fixed some overlay-related memory leaks
10
+
11
+ ## 0.2.3
12
+
13
+ * fixed the error collector
14
+
15
+ ## 0.2.2
16
+
17
+ * fixed retention of WMEs added to an overlay
18
+
19
+ ## 0.2.1
20
+
21
+ * data overlay fixes
22
+
23
+ ## 0.2.0
24
+
25
+ * refactored compilation code
26
+ * [data overlays](https://github.com/ulfurinn/wongi-engine/issues/45)
27
+ * DSL methods are removed from `Object` and are available by including `Wongi::Engine::DSL` instead
28
+
29
+ ## 0.1.4
30
+
31
+ * fixed a bug in evaluation of `assign` nodes
32
+
33
+ ## 0.1.0
34
+
35
+ * massively rewritten rule activation; this simplifies development and debugging and opens the road for useful features such as fully reversible custom actions
36
+ * **treat this as a major upgrade and test thoroughly**
37
+
38
+ ## 0.0.17
39
+
40
+ * introduced the `assuming` matcher
41
+
42
+ ## 0.0.13
43
+
44
+ * fixed a bug with recursive generations of multiple facts
45
+
46
+ ## 0.0.12
47
+
48
+ * fixed another NCC bug
49
+
50
+ ## 0.0.11
51
+
52
+ * fixed cleanup of invalidated NCC branches
53
+
54
+ ## 0.0.10
55
+
56
+ * fixed interaction of filters and optional nodes
57
+
58
+ ## 0.0.9
59
+
60
+ * fixed the definition of `asserted` (#16)
61
+
62
+ ## 0.0.8
63
+
64
+ * preventing the feedback loop introduced in 0.0.7; experimental
65
+
66
+ ## 0.0.7
67
+
68
+ * added a guard against introducing variables in neg clauses
69
+ * fixed execution context of simple action block (#7)
70
+ * fixed #4 once more, better
71
+ * fixed a bug with OptionalNode (#12)
72
+ * fixed behaviour of neg nodes; this will cause feedback loops when a gen action creates a fact that invalidates the action's condition
73
+
74
+ ## 0.0.6
75
+
76
+ * fixed a bug caused by retracting facts from within a rule action (#4)
77
+
78
+ ## 0.0.5
79
+
80
+ * fixed a bug with multiple `assert` tests following the same node (#2)
81
+
82
+ ## 0.0.4
83
+
84
+ * reintegrated RDF support
85
+ * collapsible filter matchers
86
+
87
+ ## 0.0.3
88
+
89
+ * bug fixes
90
+ * `assert`, `assign`
91
+
92
+ ## 0.0.1
93
+
94
+ * initial repackaged release
data/README.md CHANGED
@@ -8,111 +8,16 @@
8
8
 
9
9
  [Open discussions](https://github.com/ulfurinn/wongi-engine/issues?q=is%3Aopen+is%3Aissue+label%3Adiscussion)
10
10
 
11
- 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.
12
-
13
- ## Word of caution
14
-
15
- 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.
11
+ [Tutorial](http://ulfurinn.github.io/wongi-engine/)
16
12
 
17
- ## How to use this thing?
13
+ 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.
18
14
 
19
- [The tutorial](http://ulfurinn.github.io/wongi-engine/) should get you started nicely.
15
+ **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.
20
16
 
21
17
  ## Acknowledgements
22
18
 
23
19
  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).
24
20
 
25
- ## Changelog
26
-
27
- ### 0.2.5
28
-
29
- * fixed some overlay-related memory leaks
30
-
31
- ### 0.2.3
32
-
33
- * fixed the error collector
34
-
35
- ### 0.2.2
36
-
37
- * fixed retention of WMEs added to an overlay
38
-
39
- ### 0.2.1
40
-
41
- * data overlay fixes
42
-
43
- ### 0.2.0
44
-
45
- * refactored compilation code
46
- * [data overlays](https://github.com/ulfurinn/wongi-engine/issues/45)
47
- * DSL methods are removed from `Object` and are available by including `Wongi::Engine::DSL` instead
48
-
49
- ### 0.1.4
50
-
51
- * fixed a bug in evaluation of `assign` nodes
52
-
53
- ### 0.1.0
54
-
55
- * massively rewritten rule activation; this simplifies development and debugging and opens the road for useful features such as fully reversible custom actions
56
- * **treat this as a major upgrade and test thoroughly**
57
-
58
- ### 0.0.17
59
-
60
- * introduced the `assuming` matcher
61
-
62
- ### 0.0.13
63
-
64
- * fixed a bug with recursive generations of multiple facts
65
-
66
- ### 0.0.12
67
-
68
- * fixed another NCC bug
69
-
70
- ### 0.0.11
71
-
72
- * fixed cleanup of invalidated NCC branches
73
-
74
- ### 0.0.10
75
-
76
- * fixed interaction of filters and optional nodes
77
-
78
- ### 0.0.9
79
-
80
- * fixed the definition of `asserted` (#16)
81
-
82
- ### 0.0.8
83
-
84
- * preventing the feedback loop introduced in 0.0.7; experimental
85
-
86
- ### 0.0.7
87
-
88
- * added a guard against introducing variables in neg clauses
89
- * fixed execution context of simple action block (#7)
90
- * fixed #4 once more, better
91
- * fixed a bug with OptionalNode (#12)
92
- * fixed behaviour of neg nodes; this will cause feedback loops when a gen action creates a fact that invalidates the action's condition
93
-
94
- ### 0.0.6
95
-
96
- * fixed a bug caused by retracting facts from within a rule action (#4)
97
-
98
- ### 0.0.5
99
-
100
- * fixed a bug with multiple `assert` tests following the same node (#2)
101
-
102
- ### 0.0.4
103
-
104
- * reintegrated RDF support
105
- * collapsible filter matchers
106
-
107
- ### 0.0.3
108
-
109
- * bug fixes
110
- * `assert`, `assign`
111
-
112
- ### 0.0.1
113
-
114
- * initial repackaged release
115
-
116
21
  ## Contributing
117
22
 
118
23
  1. Fork it
@@ -299,21 +299,21 @@ module Wongi::Engine
299
299
  find(wme.subject, wme.predicate, wme.object)
300
300
  end
301
301
 
302
- def each *args
303
- return unless block_given?
304
- unless args.length == 0 || args.length == 3
305
- raise Error, "Network#each expects a pattern or nothing at all"
306
- end
307
- s, p, o = if args.empty?
308
- [:_, :_, :_]
302
+ def each *args, &block
303
+ template = case args.length
304
+ when 0
305
+ Template.new(:_, :_, :_)
306
+ when 3
307
+ Template.new(*args)
309
308
  else
310
- args
309
+ raise Error, "Network#each expect a template or nothing at all"
311
310
  end
312
- no_check = s == :_ && p == :_ && o == :_
313
- template = Template.new(s, p, o).import_into self
314
311
  source = best_alpha(template)
315
- current_overlay.wmes(source).each do |wme|
316
- yield wme if (no_check || wme =~ template)
312
+ matching = current_overlay.wmes(source).select { |wme| wme =~ template }
313
+ if block_given?
314
+ matching.each(&block)
315
+ else
316
+ matching.each
317
317
  end
318
318
  end
319
319
 
@@ -1,5 +1,5 @@
1
1
  module Wongi
2
2
  module Engine
3
- VERSION = "0.2.5"
3
+ VERSION = "0.2.6"
4
4
  end
5
5
  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.5
4
+ version: 0.2.6
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-11 00:00:00.000000000 Z
11
+ date: 2016-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -78,6 +78,7 @@ files:
78
78
  - ".hgtags"
79
79
  - ".ruby-gemset"
80
80
  - ".travis.yml"
81
+ - CHANGELOG.md
81
82
  - Gemfile
82
83
  - LICENSE
83
84
  - README.md