fbe 0.28.0 → 0.28.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: 22c7a8e786ff71b8449f19751665bc82f32ba777248218bcac806b76b8be3fa2
4
- data.tar.gz: 361d1413b6649089e1ba3e8b499d60540b25261da616b94ac56687fe1af1b7fe
3
+ metadata.gz: 61a57de71b1c292ec12e6f990c09be1b71b271ca5b91df227042f853b96772f8
4
+ data.tar.gz: 55f9f3384299ef325505c2ac1721fdaa166fd346ad0d9b2759d88df1dfeeedba
5
5
  SHA512:
6
- metadata.gz: 04b8c247dda95f931519f496cab03d02c8d912eafc0d2114e1dd21d507a9b81ed156d26accd2f5be50394cc3dec1fe4c86d4c0415f4f0a8a5c4d1eccef3510b8
7
- data.tar.gz: 75f0f3ca32b28aee6d1206975bb066b7da7c022f9bee785c723d2a88585cce70ec6e7c5da201418676c0b56bda9db385f8af2ddd0557d157137e5dc3241c3563
6
+ metadata.gz: bc243fbc22b222834b791ffa62ba115fac2c938fad223d8c3ae4a06a42a1233d02d1953a8537451fa0c6e1dd9b2f33bfae49d37baf36c469718c9734a94510ff
7
+ data.tar.gz: 981cfa09101bb45b7951bd11b8c95757fde0b95361995cace2c60a59e48bd69adc2b3aa2d679df25c78dd54cb16c0ae4d11fc89aae5a44399ea3b06a9db5d9d1
data/Gemfile.lock CHANGED
@@ -74,7 +74,7 @@ GEM
74
74
  loog (~> 0.6)
75
75
  tago (~> 0.1)
76
76
  ellipsized (0.3.0)
77
- ethon (0.17.0)
77
+ ethon (0.15.0)
78
78
  ffi (>= 1.15.0)
79
79
  factbase (0.15.6)
80
80
  backtrace (~> 0.4)
@@ -189,7 +189,7 @@ GEM
189
189
  regexp_parser (2.11.2)
190
190
  retries (0.0.5)
191
191
  rexml (3.4.2)
192
- rubocop (1.80.0)
192
+ rubocop (1.80.1)
193
193
  json (~> 2.3)
194
194
  language_server-protocol (~> 3.17.0.2)
195
195
  lint_roller (~> 1.1.0)
@@ -236,8 +236,8 @@ GEM
236
236
  tago (0.1.0)
237
237
  timeout (0.4.3)
238
238
  total (0.4.1)
239
- typhoeus (1.4.1)
240
- ethon (>= 0.9.0)
239
+ typhoeus (1.5.0)
240
+ ethon (>= 0.9.0, < 0.16.0)
241
241
  tzinfo (2.0.6)
242
242
  concurrent-ruby (~> 1.0)
243
243
  unicode-display_width (3.1.5)
data/lib/fbe/tombstone.rb CHANGED
@@ -22,17 +22,22 @@ class Fbe::Tombstone
22
22
  end
23
23
 
24
24
  # Put it there.
25
+ # @param [String] where The place, e.g. "github"
25
26
  # @param [Integer] repo ID of repository
26
- # @param [Integer] issue ID of issue
27
- def bury!(repo, issue)
27
+ # @param [Integer] issue ID of issue (or array of them)
28
+ def bury!(where, repo, issue)
28
29
  f =
29
30
  Fbe.if_absent(fb: @fb, always: true) do |n|
30
31
  n.what = 'tombstone'
31
- n.repository = repo
32
+ n.where = where
33
+ n.repo = repo
32
34
  end
33
35
  f.send(:"#{@fid}=", SecureRandom.random_number(99_999)) if f[@fid].nil?
34
36
  nn = f['issues']&.map { |ii| ii.split('-').map(&:to_i) } || []
35
- nn << [issue, issue]
37
+ issue = [issue] unless issue.is_a?(Array)
38
+ issue.each do |i|
39
+ nn << [i, i]
40
+ end
36
41
  nn = nn.sort_by(&:first)
37
42
  merged = []
38
43
  nn.each do |a, b|
@@ -51,17 +56,21 @@ class Fbe::Tombstone
51
56
  end
52
57
 
53
58
  # Is it there?
59
+ # @param [String] where The place, e.g. "github"
54
60
  # @param [Integer] repo ID of repository
55
- # @param [Integer] issue ID of issue
61
+ # @param [Integer] issue ID of issue (or array of them)
56
62
  # @return [Boolean] True if it's there
57
- def has?(repo, issue)
63
+ def has?(where, repo, issue)
58
64
  f = @fb.query(
59
- "(and (eq what 'tombstone') (eq repository #{repo}) (exists issues))"
65
+ "(and (eq where '#{where}') (eq what 'tombstone') (eq repo #{repo}) (exists issues))"
60
66
  ).each.first
61
67
  return false if f.nil?
62
- f['issues'].any? do |ii|
63
- a, b = ii.split('-').map(&:to_i)
64
- (a..b).cover?(issue)
68
+ issue = [issue] unless issue.is_a?(Array)
69
+ issue.all? do |i|
70
+ f['issues'].any? do |ii|
71
+ a, b = ii.split('-').map(&:to_i)
72
+ (a..b).cover?(i)
73
+ end
65
74
  end
66
75
  end
67
76
  end
data/lib/fbe.rb CHANGED
@@ -10,5 +10,5 @@
10
10
  # License:: MIT
11
11
  module Fbe
12
12
  # Current version of the gem (changed by +.rultor.yml+ on every release)
13
- VERSION = '0.28.0' unless const_defined?(:VERSION)
13
+ VERSION = '0.28.2' unless const_defined?(:VERSION)
14
14
  end
@@ -15,32 +15,42 @@ class TestTombstone < Fbe::Test
15
15
  def test_simple
16
16
  fb = Factbase.new
17
17
  ts = Fbe::Tombstone.new(fb:)
18
- ts.bury!(41, 13)
19
- ts.bury!(42, 13)
20
- ts.bury!(42, 999)
21
- assert(ts.has?(41, 13))
22
- assert(ts.has?(42, 999))
23
- refute(ts.has?(8, 7))
24
- refute(ts.has?(43, 999))
25
- refute(ts.has?(43, 990))
18
+ where = 'github'
19
+ ts.bury!(where, 41, 13)
20
+ ts.bury!(where, 42, 13)
21
+ ts.bury!(where, 42, 999)
22
+ assert(ts.has?(where, 41, 13))
23
+ assert(ts.has?(where, 42, 999))
24
+ refute(ts.has?(where, 8, 7))
25
+ refute(ts.has?(where, 43, 999))
26
+ refute(ts.has?(where, 43, 990))
26
27
  end
27
28
 
28
29
  def test_on_empty
29
30
  fb = Factbase.new
30
31
  ts = Fbe::Tombstone.new(fb:)
31
- refute(ts.has?(8, 7))
32
+ where = 'github'
33
+ refute(ts.has?(where, 8, 7))
34
+ end
35
+
36
+ def test_bury_twice
37
+ fb = Factbase.new
38
+ ts = Fbe::Tombstone.new(fb:)
39
+ where = 'github'
40
+ 2.times { ts.bury!(where, 42, 7) }
41
+ assert(ts.has?(where, 42, 7))
32
42
  end
33
43
 
34
44
  def test_merges_them
35
45
  fb = Factbase.new
36
46
  ts = Fbe::Tombstone.new(fb:)
37
- ts.bury!(42, 13)
38
- ts.bury!(42, 18)
39
- ts.bury!(42, 14)
40
- ts.bury!(42, 17)
41
- ts.bury!(42, 15)
42
- ts.bury!(42, 16)
43
- assert(ts.has?(42, 16))
44
- refute(ts.has?(42, 22))
47
+ where = 'github'
48
+ ts.bury!(where, 42, 13)
49
+ ts.bury!(where, 42, 18)
50
+ ts.bury!(where, 42, 14)
51
+ ts.bury!(where, 42, [17, 15, 16])
52
+ assert(ts.has?(where, 42, 16))
53
+ assert(ts.has?(where, 42, [16, 18]))
54
+ refute(ts.has?(where, 42, 22))
45
55
  end
46
56
  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.28.0
4
+ version: 0.28.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko