fbe 0.0.46 → 0.0.48

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: 2431cb14f0a8b96e3c7c1478004756c89c736c41e30a83908955883f677f223f
4
- data.tar.gz: a60cfd3c3083d2e9b89de82992981737ab6d375c920fa10de7413ba584ec36f0
3
+ metadata.gz: 996eb38d3f323f055a2ea039e1d6079b7d3c93b45f89fc98c59a9fee5f2de496
4
+ data.tar.gz: 7f0e93d769434e73f322f0fc4e7307e65eab8b78fed7572493706deba7114256
5
5
  SHA512:
6
- metadata.gz: ae5a89b06a88acfbde4e41601faad9df89d3155f09f545e8564d2944a18da7c1dfb27a928edfb79beaee51b357cc433bd4fb404542d3e3592305441c2e01a676
7
- data.tar.gz: ffc6494268796dbe1edb4da92163bf107e84e422944000e233f419adc59842ddf0842012da4b43cd2a7ad6080fa1f0150bcde81c894c78e6fc0188bba80458e7
6
+ metadata.gz: a61ca5c4187a0ad95525df5159b2b57ce31e78fec1553933e8798223dba1de968298fb54bfaae5c865a335bd7cd22f6557477937a4ce3002a25b4e72271b162e
7
+ data.tar.gz: cc0c9b96673b4861404ac65985fbf11b3fda7acc6f7bbc1ac8d04d69ad40adce46d78baddd6297cfae353b9b0f3115344bc7a967bf7c19cd173c8b890d1c32d7
data/Gemfile.lock CHANGED
@@ -79,7 +79,7 @@ GEM
79
79
  erubi (1.13.0)
80
80
  ethon (0.16.0)
81
81
  ffi (>= 1.15.0)
82
- factbase (0.3.0)
82
+ factbase (0.4.0)
83
83
  backtrace (> 0)
84
84
  decoor (> 0)
85
85
  json (~> 2.7)
data/lib/fbe/fb.rb CHANGED
@@ -40,11 +40,12 @@ def Fbe.fb(fb: $fb, global: $global, options: $options, loog: $loog)
40
40
  uid: '_id'
41
41
  )
42
42
  fbe =
43
- Factbase::Pre.new(fbe) do |f|
44
- max = fb.query('(eq _id (max _id))').each.to_a.first
43
+ Factbase::Pre.new(fbe) do |f, fbt|
44
+ max = fbt.query('(eq _id (max _id))').each.to_a.first
45
45
  f._id = (max.nil? ? 0 : max._id) + 1
46
46
  f._time = Time.now
47
- f._version = "#{Factbase::VERSION}/#{Judges::VERSION}/#{options.judges_action_version}"
47
+ f._version = "#{Factbase::VERSION}/#{Judges::VERSION}/#{options.action_version}"
48
+ f._job = options.job_id unless options.job_id.nil?
48
49
  end
49
50
  Factbase::Looged.new(fbe, loog)
50
51
  end
@@ -24,6 +24,7 @@
24
24
 
25
25
  require_relative '../fbe'
26
26
  require_relative 'fb'
27
+ require_relative 'overwrite'
27
28
 
28
29
  # Run the block provided every X hours.
29
30
  #
@@ -46,5 +47,5 @@ def Fbe.repeatedly(area, p_every_hours, fb: Fbe.fb, judge: $judge, loog: $loog,
46
47
  f.what = judge
47
48
  end
48
49
  Fbe.overwrite(f, 'when', Time.now)
49
- yield f
50
+ yield fb.query("(and (eq what '#{judge}'))").each.to_a.first
50
51
  end
data/lib/fbe.rb CHANGED
@@ -27,5 +27,5 @@
27
27
  # License:: MIT
28
28
  module Fbe
29
29
  # Current version of the gem (changed by .rultor.yml on every release)
30
- VERSION = '0.0.46'
30
+ VERSION = '0.0.48'
31
31
  end
data/test/fbe/test_fb.rb CHANGED
@@ -46,4 +46,31 @@ class TestFb < Minitest::Test
46
46
  stdout = $loog.to_s
47
47
  assert(stdout.include?('Inserted new fact #1'), stdout)
48
48
  end
49
+
50
+ def test_increment_id_in_transaction
51
+ $fb = Factbase.new
52
+ $global = {}
53
+ $options = Judges::Options.new
54
+ $loog = Loog::Buffer.new
55
+ Fbe.fb.txn do |fbt|
56
+ fbt.insert
57
+ fbt.insert
58
+ end
59
+ arr = Fbe.fb.query('(always)').each.to_a
60
+ assert_equal(1, arr[0]._id)
61
+ assert_equal(2, arr[1]._id)
62
+ end
63
+
64
+ def test_adds_meta_properties
65
+ $fb = Factbase.new
66
+ $global = {}
67
+ $options = Judges::Options.new('JOB_ID' => 42)
68
+ $loog = Loog::Buffer.new
69
+ Fbe.fb.insert
70
+ f = Fbe.fb.query('(always)').each.to_a.first
71
+ assert(!f._id.nil?)
72
+ assert(!f._time.nil?)
73
+ assert(!f._version.nil?)
74
+ assert(!f._job.nil?)
75
+ end
49
76
  end
@@ -25,6 +25,7 @@
25
25
  require 'minitest/autorun'
26
26
  require 'loog'
27
27
  require 'factbase'
28
+ require 'judges/options'
28
29
  require_relative '../test__helper'
29
30
  require_relative '../../lib/fbe/repeatedly'
30
31
 
@@ -35,14 +36,16 @@ require_relative '../../lib/fbe/repeatedly'
35
36
  class TestRepeatedly < Minitest::Test
36
37
  def test_simple
37
38
  $fb = Factbase.new
38
- loog = Loog::NULL
39
+ $loog = Loog::NULL
40
+ $options = Judges::Options.new
39
41
  judge = 'test'
40
42
  $global = {}
41
43
  3.times do
42
- Fbe.repeatedly('pmp', 'every_x_hours', loog:, judge:) do |f|
44
+ Fbe.repeatedly('pmp', 'every_x_hours', judge:) do |f|
43
45
  f.foo = 42
44
46
  end
45
47
  end
46
48
  assert_equal(1, $fb.size)
49
+ assert_equal(42, $fb.query('(always)').each.to_a.first.foo)
47
50
  end
48
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.46
4
+ version: 0.0.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko