upl 0.2.0 → 0.2.1
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/History.txt +4 -0
- data/lib/upl/query.rb +10 -2
- data/lib/upl/runtime.rb +4 -1
- data/lib/upl/version.rb +1 -1
- 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: '098024c977917fd375c9743595fbee2063227946d6c2df8110ca5a7d76dd7cca'
|
4
|
+
data.tar.gz: b3a4df0143e5847a303fbef5dbbdb0f639c5270cb577c1bff932b5e15ed52c2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21f5784f9b8c8699c75728cff0f57bf66f6eec802d613fb5018d224d4376d57702b570a7eb1210218bfd828f954e283a265f3885474eb1cd4c1a8c9599270936
|
7
|
+
data.tar.gz: 25ad0f5cfa693432e3ceee531eefa7d8ebde8f587ae8d7b80eacc57fb68b7baab72c21491e45a27c98c886bd458193d1c71627b4c6a7c038c548d853a47393d5
|
data/History.txt
CHANGED
data/lib/upl/query.rb
CHANGED
@@ -6,9 +6,10 @@ module Upl
|
|
6
6
|
# TODO can only be string at this point
|
7
7
|
# One-use only. If you want a new query, create another instance.
|
8
8
|
# Is an enumerable for the result set.
|
9
|
-
def initialize term_or_string
|
9
|
+
def initialize term_or_string, &map_blk
|
10
10
|
@source = term_or_string
|
11
11
|
@term, @vars = Upl::Runtime.term_vars term_or_string
|
12
|
+
@map_blk = map_blk
|
12
13
|
end
|
13
14
|
|
14
15
|
attr_reader :source, :term, :vars
|
@@ -43,7 +44,14 @@ module Upl
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def each &blk
|
46
|
-
call.
|
47
|
+
call.map do |row|
|
48
|
+
# TODO this assume the if statement is faster than a call to a default ->i{i}
|
49
|
+
if @map_blk
|
50
|
+
blk.call @map_blk[row]
|
51
|
+
else
|
52
|
+
blk.call row
|
53
|
+
end
|
54
|
+
end
|
47
55
|
end
|
48
56
|
|
49
57
|
include Enumerable
|
data/lib/upl/runtime.rb
CHANGED
@@ -91,7 +91,10 @@ module Upl
|
|
91
91
|
fid_t = Extern.PL_open_foreign_frame
|
92
92
|
yield fid_t
|
93
93
|
ensure
|
94
|
-
|
94
|
+
# discards term references, but keeps bindings
|
95
|
+
# fid_t and Extern.PL_close_foreign_frame fid_t
|
96
|
+
# same as close and also undo bindings
|
97
|
+
fid_t and Extern.PL_discard_foreign_frame fid_t
|
95
98
|
end
|
96
99
|
|
97
100
|
# Use prolog predicate to parse the string into a term (containing variables), along with its named
|
data/lib/upl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: upl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Anderson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|