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 +4 -4
- data/Gemfile +1 -1
- data/README.md +10 -5
- data/bin/ruby-prolog-acls +10 -10
- data/bin/ruby-prolog-hanoi +2 -2
- data/lib/ruby-prolog/version.rb +1 -1
- data/ruby-prolog.gemspec +3 -3
- metadata +12 -13
- data/NOTICE +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab3d732c3908fa0c86f2a0b55cbdb658bf21d31d98e21a99a746f4e4af56f430
|
4
|
+
data.tar.gz: bce2c7ef00bd9f0a5669c36b0b33fa4575f4a53fb5b16c3296f305ff9332cbfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 890ac961705c57540dc491af73ea6c57671a9f0c59ed3d4829ffccb2a91728b1e7d443d7802b6a2a06dabafc1e229dffc2cad1fc2d0d1b9f71d0aa8a3c0d522a
|
7
|
+
data.tar.gz: 1c034b79ea8a40fb8588804529783c20218c040c61e2a918ebb10e0ef29e011fd8d588ac6231007436d80580bc99bd3b25d44391b8e5a7263fcca8a59d6247bc
|
data/Gemfile
CHANGED
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.
|
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
|
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.
|
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
|
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
|
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
|
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
|
-
#
|
75
|
+
# puts query{is_role_on_multiple_projects[:U, 'admin']}
|
76
76
|
|
77
|
+
require 'JSON'
|
77
78
|
s = Array.new
|
78
|
-
query
|
79
|
-
|
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
|
data/bin/ruby-prolog-hanoi
CHANGED
@@ -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
|
31
|
+
query{hanoi[1]}
|
32
32
|
|
33
33
|
puts "\n\nWhat's the solution for 5 discs?"
|
34
|
-
query
|
34
|
+
query{hanoi[5]}
|
35
35
|
|
36
36
|
# do_stuff[:STUFF].calls{|env| print env[:STUFF]; true}
|
37
37
|
|
data/lib/ruby-prolog/version.rb
CHANGED
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",
|
21
|
+
spec.add_development_dependency "bundler", '~> 2.3.7'
|
22
22
|
spec.add_development_dependency "rake", "~> 13"
|
23
|
-
spec.add_development_dependency "minitest", "~> 5.
|
24
|
-
spec.add_development_dependency "minitest-focus", "~> 1.1
|
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.
|
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:
|
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:
|
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:
|
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.
|
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.
|
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
|
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
|
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.
|
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:
|