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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa378221e9a155214e277debd0451dc3ee7f0aa16c35f71ed838151824371c56
4
- data.tar.gz: ecf227095d069fdde0639b5e685f7e000cd272358daea498910eca648cfb42b5
3
+ metadata.gz: '098024c977917fd375c9743595fbee2063227946d6c2df8110ca5a7d76dd7cca'
4
+ data.tar.gz: b3a4df0143e5847a303fbef5dbbdb0f639c5270cb577c1bff932b5e15ed52c2d
5
5
  SHA512:
6
- metadata.gz: e7f9508863c480a8597cd6b35e343429ca1b9afcf4751116b4ea1694d6b260da05067128eefae21bc8873f816a8f85a4da9bef128ff873f25fe16f8ad1e4a3ab
7
- data.tar.gz: 5e319c993b59af76d23f29a52f8cb70dcdc22b33f5110cc96e5608aed214ff0fdff61068e97a1e6d2e04190350861cd2bb701ebf95f1af93a8bbe105eae8ce24
6
+ metadata.gz: 21f5784f9b8c8699c75728cff0f57bf66f6eec802d613fb5018d224d4376d57702b570a7eb1210218bfd828f954e283a265f3885474eb1cd4c1a8c9599270936
7
+ data.tar.gz: 25ad0f5cfa693432e3ceee531eefa7d8ebde8f587ae8d7b80eacc57fb68b7baab72c21491e45a27c98c886bd458193d1c71627b4c6a7c038c548d853a47393d5
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.2.1
2
+ * Query map_blk for transforms
3
+ * frames for Query reuse
4
+
1
5
  == 0.2.0
2
6
  * add Upl::Query class for nicer api
3
7
  * faster term parsing
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.each &blk
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
- fid_t and Extern.PL_close_foreign_frame fid_t
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
@@ -1,3 +1,3 @@
1
1
  module Upl
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
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.0
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-15 00:00:00.000000000 Z
11
+ date: 2020-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler