wongi-engine 0.2.8 → 0.2.9

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: 350acce859cab23d251cb069c921a9497f0b955b
4
- data.tar.gz: 0edb71d4019b1864b64b490d0acddc14544252e9
3
+ metadata.gz: 0fdcab85b1479a151cff39d50b422743ba3555ec
4
+ data.tar.gz: 5d7cbe8c7a6280b45a16945d38ab99d192821a76
5
5
  SHA512:
6
- metadata.gz: b4fb91a49af2f799deca113472cfc1de004eeeb580f2f56464a9c3c87dda451bf6f872f68ead62bb6e164d58383d340a9d22ce2f7a37a002a7f0cb266f0e6a4a
7
- data.tar.gz: f3aec20c0bcca40506138cc7fef15783c2f98a0af1370c10cb3eb248f29be7d235db606a701752267d859c0076cbb40abb07ba2cfa485483919f7bcd3be77faf
6
+ metadata.gz: 37d9260e2109b969b58770c15931e9cfb72a4a0c52c8051a16000f6fb5ce2b3b98f3d0c8c969d08ca6d1ad3172343f554e74dd001230c904e668548e6585f3a6
7
+ data.tar.gz: d6ec3764500423d2b36997f08f6db4aa2adb55be4cd4c28283e1c1a73bb13dad1194a457081a51a58cedba71742bd09fbd4734d109bf2affac4b2d31dab01473
data/.hgtags CHANGED
@@ -8,3 +8,6 @@ b8b5d5ac7b39ce11d9bb86e61fcb04b227aca02d v0.2.7
8
8
  2b0925ffd7d5c9acc48ffd873abff9a3b6ed66c3 v0.2.8
9
9
  2b0925ffd7d5c9acc48ffd873abff9a3b6ed66c3 v0.2.8
10
10
  5692396d6db5ab9a9b1d26a0f41686124f87de62 v0.2.8
11
+ a2f9d52603db027baced51f673daf46b8fe8745a v0.2.9
12
+ a2f9d52603db027baced51f673daf46b8fe8745a v0.2.9
13
+ da4529420721bdd153839261e624b3738e7355e9 v0.2.9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.9
4
+
5
+ * fixed a bug preventing variables being bound to `false` and `nil`
6
+
3
7
  ## 0.2.8
4
8
 
5
9
  * fixed a namespacing bug affecting code not including the DSL module
@@ -54,17 +54,20 @@ module Wongi::Engine
54
54
 
55
55
  def resolve!(token)
56
56
  s = if Template.variable?(subject)
57
- token[subject].tap { |x| raise DefinitionError, "unbound variable #{subject} in token #{token}" unless x}
57
+ raise DefinitionError, "unbound variable #{subject} in token #{token}" unless token.has_var?(subject)
58
+ token[subject]
58
59
  else
59
60
  subject
60
61
  end
61
62
  p = if Template.variable?(predicate)
62
- token[predicate].tap { |x| raise DefinitionError, "unbound variable #{predicate} in token #{token}" unless x}
63
+ raise DefinitionError, "unbound variable #{predicate} in token #{token}" unless token.has_var?(predicate)
64
+ token[predicate]
63
65
  else
64
66
  predicate
65
67
  end
66
68
  o = if Template.variable?(object)
67
- token[object].tap { |x| raise DefinitionError, "unbound variable #{object} in token #{token}" unless x}
69
+ raise DefinitionError, "unbound variable #{object} in token #{token}" unless token.has_var?(object)
70
+ token[object]
68
71
  else
69
72
  object
70
73
  end
@@ -53,6 +53,10 @@ module Wongi::Engine
53
53
  end
54
54
  end
55
55
 
56
+ def has_var? x
57
+ assignments.has_key? x
58
+ end
59
+
56
60
  # TODO ignore assignments?
57
61
  def duplicate? other
58
62
  self.parent.equal?(other.parent) && @wme.equal?(other.wme) && self.assignments == other.assignments
@@ -1,5 +1,5 @@
1
1
  module Wongi
2
2
  module Engine
3
- VERSION = "0.2.8"
3
+ VERSION = "0.2.9"
4
4
  end
5
5
  end
@@ -70,4 +70,19 @@ describe "ASSIGN rule" do
70
70
  expect(x).to be == 1
71
71
  end
72
72
 
73
+ it 'should handle booleans' do
74
+ engine << rule do
75
+ for_all {
76
+ has :a, :b, :c
77
+ assign :X do |token|
78
+ false
79
+ end
80
+ }
81
+ make {
82
+ gen :d, :e, :X
83
+ }
84
+ end
85
+ engine << [:a, :b, :c]
86
+ end
87
+
73
88
  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.8
4
+ version: 0.2.9
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-05-31 00:00:00.000000000 Z
11
+ date: 2016-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake