factbase 0.16.0 → 0.16.2

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: 96133055dc92095960ab4b258f4a144105393d2a86e11f96c3199ff24d35653a
4
- data.tar.gz: f93590d550bf7b54aaa235e43557173d57af37abdc9e0a37491cf68c654e2c1e
3
+ metadata.gz: 7ba34d6b5b9a1744ae6600684ad71297a340dced1caa385d85bc1f46790cf200
4
+ data.tar.gz: 2cb3a384559e9d7451adcef94891d97f4314532611a83d55b1bde2f124124930
5
5
  SHA512:
6
- metadata.gz: 2a532d7b59b0fa32d5662c420fb1d0de409d1c9cdf52fd6cf42c3020fd20a2008679019cf853a49e7ac1b0c9207d87134ffe1f23693f652a99188c8c6bd518f2
7
- data.tar.gz: 67df97f44bdfbbcdba5cb5b7cec6a2f62cf9b4049f0a3d643382d797d9ec2997160ac231e871a18642c8fbd903387412e6c741d367f4e4362019d3a45a4cf6e3
6
+ metadata.gz: 8399dd7490033d036d092121216f9d58c07bd402b40ea7014445c2f215f2e6a6db8e206461dc6ef0aee47225b81d77c792acdf88652d7f79016e596c457cf61c
7
+ data.tar.gz: 5cccc18f353a9a93866d624ac4b3f03b6a32b820f7c83d6179f23b6f72b0a5b791f94382f61546d7910cea85aafde7b6fe824c5ae92e58bbf02f2e97a6d4c458
data/Gemfile.lock CHANGED
@@ -90,10 +90,10 @@ GEM
90
90
  lint_roller (~> 1.1)
91
91
  rubocop (>= 1.75.0, < 2.0)
92
92
  rubocop-ast (>= 1.38.0, < 2.0)
93
- rubocop-performance (1.25.0)
93
+ rubocop-performance (1.26.0)
94
94
  lint_roller (~> 1.1)
95
95
  rubocop (>= 1.75.0, < 2.0)
96
- rubocop-ast (>= 1.38.0, < 2.0)
96
+ rubocop-ast (>= 1.44.0, < 2.0)
97
97
  rubocop-rake (0.7.1)
98
98
  lint_roller (~> 1.1)
99
99
  rubocop (>= 1.72.1)
@@ -20,6 +20,8 @@ module Factbase::IndexedTerm
20
20
  # @param [Hash] params Key/value params to use
21
21
  # @return [Array<Hash>|nil] Returns a new array, or NIL if the original array must be used
22
22
  def predict(maps, fb, params)
23
+ m = :"#{@op}_predict"
24
+ return send(m, maps, fb, params) if respond_to?(m)
23
25
  key = [maps.object_id, @operands.first, @op]
24
26
  case @op
25
27
  when :one
@@ -39,4 +39,19 @@ module Factbase::Lists
39
39
  .reverse
40
40
  .map { |m| m.all_properties.to_h { |k| [k, m[k]] } }
41
41
  end
42
+
43
+ def head(_fact, _maps, _fb)
44
+ true
45
+ end
46
+
47
+ def head_predict(maps, fb, params)
48
+ assert_args(2)
49
+ max = @operands[0]
50
+ raise "An integer is expected as first argument of 'sorted'" unless max.is_a?(Integer)
51
+ term = @operands[1]
52
+ raise "A term is expected, but '#{term}' provided" unless term.is_a?(Factbase::Term)
53
+ fb.query(term, maps).each(fb, params).to_a
54
+ .take(max)
55
+ .map { |m| m.all_properties.to_h { |k| [k, m[k]] } }
56
+ end
42
57
  end
@@ -31,12 +31,4 @@ module Factbase::Ordering
31
31
  end
32
32
  pass
33
33
  end
34
-
35
- def head(*)
36
- max = @operands[0]
37
- raise "An integer is expected as first argument of 'head'" unless max.is_a?(Integer)
38
- @passed = 0 if @passed.nil?
39
- @passed += 1
40
- @passed <= max
41
- end
42
34
  end
@@ -9,5 +9,5 @@
9
9
  # License:: MIT
10
10
  class Factbase
11
11
  # Current version of the gem (changed by .rultor.yml on every release)
12
- VERSION = '0.16.0' unless const_defined?(:VERSION)
12
+ VERSION = '0.16.2' unless const_defined?(:VERSION)
13
13
  end
data/lib/factbase.rb CHANGED
@@ -206,7 +206,7 @@ class Factbase
206
206
  garbage << pairs[oid]
207
207
  churn.append(0, 1, 0)
208
208
  end
209
- @maps.delete_if { |m| garbage.include?(m.object_id) }
209
+ @maps.delete_if { |m| garbage.include?(m.object_id) } unless garbage.empty?
210
210
  churn
211
211
  end
212
212
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.16.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko