ruby-prolog 2.2.0 → 2.3.0

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: 4dd70c2b7255275600ce03afa496196c08e1934e8c8a76d4300ea6a29ffa89f5
4
- data.tar.gz: 2d0aa3ed40c536a4d1f3d39d883640238f1aa569c80de4f16066b08fa7db82d9
3
+ metadata.gz: 05106f067ff5d0aba8c772e92f83bc1b1f51fdda323ba2a9e823915fd3cc8511
4
+ data.tar.gz: 8342ee2d5da3785315ee5db800ac603e986aa29d65d9d5c199578a0af5395fed
5
5
  SHA512:
6
- metadata.gz: ad4daa2df49daf2c182142148c67b54d81828eb953fc54be41f540a47e280afc735dc322d507201afbbdd9dbfb93badc9dc943abb3f019abf8cbf25efba0169b
7
- data.tar.gz: 06e32aac58dedaaa865be276203f4b3667447ca4e4c3a5ae855d2eaa0c94c14eb47900e59b4445e8f79665e83536edcd1b5d1cfff08af96b8e48c0d3116d1d10
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
- return @name.to_s
25
+ @name.to_s
26
26
  end
27
27
 
28
28
  def [](*args)
29
- return TempClause.new(@db, self, args)
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
@@ -1,5 +1,5 @@
1
1
  module RubyProlog
2
2
 
3
- VERSION = '2.2.0'
3
+ VERSION = '2.3.0'
4
4
 
5
5
  end
@@ -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.2.0
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-04-10 00:00:00.000000000 Z
11
+ date: 2020-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler