ruby-prolog 2.3.0 → 2.4.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: 05106f067ff5d0aba8c772e92f83bc1b1f51fdda323ba2a9e823915fd3cc8511
4
- data.tar.gz: 8342ee2d5da3785315ee5db800ac603e986aa29d65d9d5c199578a0af5395fed
3
+ metadata.gz: ab3d732c3908fa0c86f2a0b55cbdb658bf21d31d98e21a99a746f4e4af56f430
4
+ data.tar.gz: bce2c7ef00bd9f0a5669c36b0b33fa4575f4a53fb5b16c3296f305ff9332cbfe
5
5
  SHA512:
6
- metadata.gz: 9901482b866a7dd9039556ffae9a3f2239df49c6ef1411f8382b13d2167d558deab4dc23be51bac22ecf7cdbfc220ad51e47239f44d218ff18f4cd90bc0b6df4
7
- data.tar.gz: 284d6a69c48b7444e74c171087e501e7f1b482696b27b00c8fc64ee7c1f526bbd9bf672a74d14a8ad48255dc3f6b74f452013ef3fb825b4fae71841fed893d66
6
+ metadata.gz: 890ac961705c57540dc491af73ea6c57671a9f0c59ed3d4829ffccb2a91728b1e7d443d7802b6a2a06dabafc1e229dffc2cad1fc2d0d1b9f71d0aa8a3c0d522a
7
+ data.tar.gz: 1c034b79ea8a40fb8588804529783c20218c040c61e2a918ebb10e0ef29e011fd8d588ac6231007436d80580bc99bd3b25d44391b8e5a7263fcca8a59d6247bc
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
- ruby '~> 2.0'
2
+ ruby '3.1.2'
3
3
 
4
4
  gemspec
5
5
 
data/README.md CHANGED
@@ -1,8 +1,13 @@
1
- ruby-prolog
2
- ====
1
+ # ruby-prolog :: The Prolog-like DSL for Ruby
2
+
3
3
 
4
4
  ruby-prolog allows you to solve complex logic problems on the fly using a dynamic, Prolog-like DSL inline with your normal Ruby code. Basic use is encompassed by stating basic facts using your data, defining rules, and then asking questions. Why is this cool? Because ruby-prolog allows you to leave your normal object-oriented vortex on demand and step into the alternate reality of declarative languages.
5
5
 
6
+ ruby-prolog has been used in projects ranging from complex realtime access control authorization in Rails apps, to headless 3D layout engines, and many other use cases.
7
+
8
+ * Example: [Dynamic Access Control for IAM](bin/ruby-prolog-acls)
9
+ * Example: [Towers of Hanoi solution](bin/ruby-prolog-hanoi)
10
+
6
11
  With ruby-prolog:
7
12
 
8
13
  * There are no classes.
@@ -10,9 +15,9 @@ With ruby-prolog:
10
15
  * There are no variables.
11
16
  * There are no control flow statements.
12
17
 
13
- You *can* use all these wonder things -- it’s still Ruby after all -- but they’re not needed, and mainly useful for getting data and results into/out of the interpreter. Prolog still tends to be favored heavily in artificial intelligence and theorem proving applications and is still relevant to computer science curricula as well, so I hope this updated release proves useful for your logic evaluation needs!
18
+ You *can* use all these wonder things -- it’s still Ruby after all -- but they’re not needed, and mainly useful for getting data and results into/out of the interpreter. Declarative langugaes like Prolog are often favored heavily in artificial intelligence and theorem proving applications and is also taught in computer science curricula, so I hope this updated release proves useful for your logic evaluation needs!
14
19
 
15
- ruby-prolog is written using object-oriented-ish pure Ruby, and should work under all most popular Ruby interpreters. Please report compatibility problems. The core engine is largely based on tiny_prolog, though numerous additional enhancements have been made such as object-oriented refactorings and integration of ideas from the interwebs. Unfortunately I cannot read Japanese and cannot give proper attribution to the original tiny_prolog author. (If *you* can, let me know and I'll update this document!)
20
+ ruby-prolog is written using object-oriented-ish pure Ruby, and should work under all modern Ruby interpreters. Please report compatibility problems. The core engine is largely based on tiny_prolog, though numerous additional enhancements have been made such as object-oriented refactorings and integration of ideas from the interwebs. Unfortunately I cannot read Japanese and cannot give proper attribution to the original tiny_prolog author. (If *you* can, let me know and I'll update this document!)
16
21
 
17
22
  Usage
18
23
  ----
@@ -162,4 +167,4 @@ $ rake test
162
167
  License
163
168
  ----
164
169
 
165
- Released under the Apache 2 license. Copyright (c) 2013 Preston Lee. All rights reserved. http://prestonlee.com
170
+ Released under the Apache 2.0 license. Copyright (c) 2013-2022 Preston Lee. All rights reserved. https://prestonlee.com
data/bin/ruby-prolog-acls CHANGED
@@ -60,26 +60,26 @@ c.instance_eval do
60
60
  # , noteq[:P1, :P2]
61
61
 
62
62
  puts 'Who does QA?'
63
- p query(assigned[:U, :P, 'qa'])
63
+ p query{assigned[:U, :P, 'qa']}
64
64
 
65
65
  puts "Who can access the 'vista' project?"
66
- p query(can_on_project[:U, 'read', 'vista'])
66
+ p query{(can_on_project[:U, 'read', 'vista'])}
67
67
 
68
68
  puts "Does Alice have delete privileges on Vista?"
69
- puts query(can_on_project['alice', 'delete', 'vista']).empty? ? "Yes" : "No"
69
+ puts query{can_on_project['alice', 'delete', 'vista']}.empty? ? "Yes" : "No"
70
70
 
71
71
  puts "Does Bob have delete privileges on Vista?"
72
- puts query(can_on_project['bob', 'delete', 'vista']).empty? ? "Yes" : "No"
72
+ puts query{can_on_project['bob', 'delete', 'vista']}.empty? ? "Yes" : "No"
73
73
 
74
74
  puts "Who is an admin on multiple projects?"
75
- # p query(is_role_on_multiple_projects[:U, 'admin'])
75
+ # puts query{is_role_on_multiple_projects[:U, 'admin']}
76
76
 
77
+ require 'JSON'
77
78
  s = Array.new
78
- query(is_role_on_multiple_projects[:U, 'admin']).each do |r|
79
- s |= [r[0].args[0]] # Put each result into the array, if not already present.
79
+ query{is_role_on_multiple_projects[:U, 'admin']}.each do |r|
80
+ # puts r[:U].to_json
81
+ s |= [r[:U]] # Put each result into the array, if not already present.
80
82
  end
81
- s.each do |n| puts n end # Print all unique results!
82
-
83
-
83
+ s.each do |n| puts n end # Print all unique results!
84
84
 
85
85
  end
@@ -28,10 +28,10 @@ c.instance_eval do
28
28
  hanoi[:N] << move[:N,"left","right","center"]
29
29
 
30
30
  puts "\nWhat's the solution for a single disc?"
31
- query(hanoi[1])
31
+ query{hanoi[1]}
32
32
 
33
33
  puts "\n\nWhat's the solution for 5 discs?"
34
- query(hanoi[5])
34
+ query{hanoi[5]}
35
35
 
36
36
  # do_stuff[:STUFF].calls{|env| print env[:STUFF]; true}
37
37
 
@@ -1,5 +1,5 @@
1
1
  module RubyProlog
2
2
 
3
- VERSION = '2.3.0'
3
+ VERSION = '2.4.0'
4
4
 
5
5
  end
data/ruby-prolog.gemspec CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 2"
21
+ spec.add_development_dependency "bundler", '~> 2.3.7'
22
22
  spec.add_development_dependency "rake", "~> 13"
23
- spec.add_development_dependency "minitest", "~> 5.14.0"
24
- spec.add_development_dependency "minitest-focus", "~> 1.1.2"
23
+ spec.add_development_dependency "minitest", "~> 5.16.3"
24
+ spec.add_development_dependency "minitest-focus", "~> 1.3.1"
25
25
  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.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Preston Lee
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-03 00:00:00.000000000 Z
11
+ date: 2022-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2'
19
+ version: 2.3.7
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2'
26
+ version: 2.3.7
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 5.14.0
47
+ version: 5.16.3
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 5.14.0
54
+ version: 5.16.3
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest-focus
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.1.2
61
+ version: 1.3.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.1.2
68
+ version: 1.3.1
69
69
  description: A pure Ruby implementation of a useful subset of Prolog.
70
70
  email:
71
71
  - preston.lee@prestonlee.com
@@ -77,7 +77,6 @@ extra_rdoc_files: []
77
77
  files:
78
78
  - ".gitignore"
79
79
  - Gemfile
80
- - NOTICE
81
80
  - README.md
82
81
  - Rakefile
83
82
  - bin/ruby-prolog-acls
@@ -92,7 +91,7 @@ homepage: http://github.com/preston/ruby-prolog
92
91
  licenses:
93
92
  - Apache-2.0
94
93
  metadata: {}
95
- post_install_message:
94
+ post_install_message:
96
95
  rdoc_options: []
97
96
  require_paths:
98
97
  - lib
@@ -107,8 +106,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
106
  - !ruby/object:Gem::Version
108
107
  version: '0'
109
108
  requirements: []
110
- rubygems_version: 3.1.2
111
- signing_key:
109
+ rubygems_version: 3.3.7
110
+ signing_key:
112
111
  specification_version: 4
113
112
  summary: A Prolog-ish Ruby DSL.
114
113
  test_files:
data/NOTICE DELETED
@@ -1,5 +0,0 @@
1
- ruby-prolog
2
- Copyright 2013 Preston Lee. All rights reserved.
3
-
4
- This product includes software developed by Preston Lee.
5
- For further information, see http://www.prestonlee.com.