wongi-engine 0.4.1 → 0.4.3

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
  SHA256:
3
- metadata.gz: e4882eda1c68ecfe584c5792c5ee1e450915f32835528b24879fa7152e76823f
4
- data.tar.gz: 1cf31f0ef359346d7701aa65a7a0ab8b6143cad21528abe4fe5687d0482dbbbf
3
+ metadata.gz: 50a09c260719428841f2e5608174b0858c6395dcb08590d7c4ee5adbd8ac0870
4
+ data.tar.gz: b31cf13a77e4737f7970d1cca666d5307d7deca8bc3b19260c0b2a0022924973
5
5
  SHA512:
6
- metadata.gz: f2682f0a522ec363e3efaa4029ced8b0a95120baf58975f8e9d83a90be5795dc073ccdd82e0340cd89262b1d0f6a302e915d4cbe42175c94c40d2109fe149193
7
- data.tar.gz: 61b9e9b4945726a2a2cde1d16b72adcde1032b165d52bc1d824a7c2c9970466ccd11eed539e669e00af87014395988cde474e1cb59c22d7cb5ef39abecec286b
6
+ metadata.gz: 8e37e29b39fdb64049d50df909da0c08b069f125de785e76af4227baddb96823a940a9919db0afa84826de10118e383ef8cc51ec795ed1b6f99c684c3f5cf685
7
+ data.tar.gz: '096ad134e4971b5aa1f73a0d7f3d7e471b9f9fbeb34ac176f2629d3e108cc65409b64eb8240cbb6eec7e8d12ad21c72cd758c97a40a91c1c7b38f1b307fc2297'
data/examples/ex01.rb CHANGED
@@ -1,23 +1,21 @@
1
- include Wongi::Engine
1
+ engine = Wongi::Engine.create
2
2
 
3
- ds = Network.new
4
-
5
- ds << WME.new("Alice", "friend", "Bob")
3
+ engine << ["Alice", "friend", "Bob"]
6
4
 
7
5
  puts "Enumerate all:"
8
6
 
9
- ds.each do |wme|
7
+ engine.each do |wme|
10
8
  puts wme
11
9
  end
12
10
 
13
11
  puts "Enumerate by pattern:"
14
12
 
15
- ds.each :_, "friend", :_ do |wme|
13
+ engine.each :_, "friend", :_ do |wme|
16
14
  puts wme
17
15
  end
18
16
 
19
17
  puts "Mismatching pattern:"
20
18
 
21
- ds.each :_, "foe", :_ do |wme|
19
+ engine.each :_, "foe", :_ do |wme|
22
20
  puts wme
23
21
  end
@@ -27,7 +27,7 @@ module Wongi::Engine
27
27
  end
28
28
 
29
29
  def ==(other)
30
- super && x == other.x && y == other.y
30
+ self.class == other.class && x == other.x && y == other.y
31
31
  end
32
32
  end
33
33
  end
@@ -29,7 +29,7 @@ module Wongi::Engine
29
29
  end
30
30
 
31
31
  def ==(other)
32
- super && x == other.x && y == other.y
32
+ self.class == other.class && x == other.x && y == other.y
33
33
  end
34
34
  end
35
35
  end
@@ -27,7 +27,7 @@ module Wongi::Engine
27
27
  end
28
28
 
29
29
  def ==(other)
30
- super && x == other.x && y == other.y
30
+ self.class == other.class && x == other.x && y == other.y
31
31
  end
32
32
  end
33
33
  end
@@ -27,7 +27,7 @@ module Wongi::Engine
27
27
  end
28
28
 
29
29
  def ==(other)
30
- super && x == other.x && y == other.y
30
+ self.class == other.class && x == other.x && y == other.y
31
31
  end
32
32
  end
33
33
  end
@@ -27,7 +27,7 @@ module Wongi::Engine
27
27
  end
28
28
 
29
29
  def ==(other)
30
- super && x == other.x && y == other.y
30
+ self.class == other.class && x == other.x && y == other.y
31
31
  end
32
32
  end
33
33
  end
@@ -29,7 +29,7 @@ module Wongi::Engine
29
29
  end
30
30
 
31
31
  def ==(other)
32
- super && x == other.x && y == other.y
32
+ self.class == other.class && x == other.x && y == other.y
33
33
  end
34
34
  end
35
35
  end
@@ -27,7 +27,7 @@ module Wongi::Engine
27
27
  end
28
28
 
29
29
  def ==(other)
30
- super && x == other.x && y == other.y
30
+ self.class == other.class && x == other.x && y == other.y
31
31
  end
32
32
  end
33
33
  end
@@ -27,7 +27,7 @@ module Wongi::Engine
27
27
  end
28
28
 
29
29
  def ==(other)
30
- super && x == other.x && y == other.y
30
+ self.class == other.class && x == other.x && y == other.y
31
31
  end
32
32
  end
33
33
  end
@@ -155,7 +155,7 @@ module Wongi::Engine
155
155
  raise ArgumentError
156
156
  end
157
157
 
158
- each_by_template(template, &block)
158
+ each_by_template(template).each(&block)
159
159
  end
160
160
 
161
161
  def entity(subject)
@@ -1,5 +1,5 @@
1
1
  module Wongi
2
2
  module Engine
3
- VERSION = "0.4.1".freeze
3
+ VERSION = "0.4.3".freeze
4
4
  end
5
5
  end
data/spec/overlay_spec.rb CHANGED
@@ -68,6 +68,29 @@ describe Wongi::Engine::Overlay do
68
68
  expect(overlay.each(1, 11, 111)).to have(1).items
69
69
  expect(overlay.each(1, 11, 111).first).to eq(wmes.first)
70
70
  end
71
+
72
+ it 'iterates with a block' do
73
+ wmes = [
74
+ Wongi::Engine::WME.new(1, 11, 111),
75
+ Wongi::Engine::WME.new(1, 11, 112),
76
+ Wongi::Engine::WME.new(1, 11, 113),
77
+ Wongi::Engine::WME.new(1, 12, 121),
78
+ Wongi::Engine::WME.new(1, 12, 122),
79
+ Wongi::Engine::WME.new(2, 11, 111),
80
+ Wongi::Engine::WME.new(2, 11, 222),
81
+ Wongi::Engine::WME.new(2, 22, 222),
82
+ Wongi::Engine::WME.new(2, 22, 223),
83
+ Wongi::Engine::WME.new(3, 33, 113),
84
+ Wongi::Engine::WME.new(3, 33, 333),
85
+ Wongi::Engine::WME.new(3, 34, 333),
86
+ ]
87
+ wmes.each { overlay.assert(_1) }
88
+
89
+ returned = []
90
+ overlay.each { |wme| returned << wme }
91
+
92
+ expect(returned).to eq wmes
93
+ end
71
94
  end
72
95
 
73
96
  context "retracting facts" do
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.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valeri Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-08 00:00:00.000000000 Z
11
+ date: 2023-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -204,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
204
  - !ruby/object:Gem::Version
205
205
  version: '0'
206
206
  requirements: []
207
- rubygems_version: 3.3.7
207
+ rubygems_version: 3.4.1
208
208
  signing_key:
209
209
  specification_version: 4
210
210
  summary: A forward-chaining rule engine in pure Ruby.