ruby-prolog 2.2.0 → 2.3.0
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 +4 -4
- data/lib/ruby-prolog/ruby-prolog.rb +9 -2
- data/lib/ruby-prolog/version.rb +1 -1
- data/test/lib/ruby-prolog/ruby-prolog_test.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05106f067ff5d0aba8c772e92f83bc1b1f51fdda323ba2a9e823915fd3cc8511
|
4
|
+
data.tar.gz: 8342ee2d5da3785315ee5db800ac603e986aa29d65d9d5c199578a0af5395fed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9901482b866a7dd9039556ffae9a3f2239df49c6ef1411f8382b13d2167d558deab4dc23be51bac22ecf7cdbfc220ad51e47239f44d218ff18f4cd90bc0b6df4
|
7
|
+
data.tar.gz: 284d6a69c48b7444e74c171087e501e7f1b482696b27b00c8fc64ee7c1f526bbd9bf672a74d14a8ad48255dc3f6b74f452013ef3fb825b4fae71841fed893d66
|
@@ -22,11 +22,11 @@ module RubyProlog
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def inspect
|
25
|
-
|
25
|
+
@name.to_s
|
26
26
|
end
|
27
27
|
|
28
28
|
def [](*args)
|
29
|
-
|
29
|
+
TempClause.new(@db, self, args)
|
30
30
|
end
|
31
31
|
|
32
32
|
def to_prolog
|
@@ -41,6 +41,13 @@ module RubyProlog
|
|
41
41
|
dupe.clauses = dupe.clauses.dup
|
42
42
|
dupe
|
43
43
|
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# DSL for 0-arity predicates
|
47
|
+
#
|
48
|
+
def <<(goals); TempClause.new(@db, self, []) << goals; end
|
49
|
+
def to_goal; TempClause.new(@db, self, []).to_goal; end
|
50
|
+
def fact; TempClause.new(@db, self, []).fact; end
|
44
51
|
end
|
45
52
|
|
46
53
|
class TempClause
|
data/lib/ruby-prolog/version.rb
CHANGED
@@ -320,4 +320,21 @@ describe RubyProlog do
|
|
320
320
|
_( db.query{_= implies['a', 'd'] } ).must_equal [{}]
|
321
321
|
_( db.query{_= implies['a', 'idontexist'] } ).must_equal []
|
322
322
|
end
|
323
|
+
|
324
|
+
it 'supports zero-arity predicates' do
|
325
|
+
db = RubyProlog.new do
|
326
|
+
data['a'].fact
|
327
|
+
foo_1[] << data['a']
|
328
|
+
bar_1[].fact
|
329
|
+
|
330
|
+
foo_2 << data['b']
|
331
|
+
bar_2.fact
|
332
|
+
end
|
333
|
+
|
334
|
+
_( db.query{ foo_1[] } ).must_equal [{}]
|
335
|
+
_( db.query{ bar_1[] } ).must_equal [{}]
|
336
|
+
|
337
|
+
_( db.query{ foo_2 } ).must_equal []
|
338
|
+
_( db.query{ bar_2 } ).must_equal [{}]
|
339
|
+
end
|
323
340
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-prolog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Preston Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|