fbe 0.28.0 → 0.28.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/lib/fbe/tombstone.rb +12 -6
- data/lib/fbe.rb +1 -1
- data/test/fbe/test_tombstone.rb +9 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25b95f924ac73210555c91b1102ab632a0ad478b843a4c0e13d8aad5ea193d3a
|
4
|
+
data.tar.gz: 4b9c39ac83710018b43edb06963e1bf5bf27f9800b64a19bd51986d0611295d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9959047b9386598ba19232bc2101c97400bfee084c01d0cf5285f5ec84681cf2f1f39da10c7a88e09dcc705b87d45d03a38b9b529c64645fb6e8ba334727bf63
|
7
|
+
data.tar.gz: 31ce58af7e239460b310afd89aa8c719c8984f73087233fda8c1d1453b7a836d19f3dddfea9ea9592b4a5a0de616be380c8791e201e37377265a2cc9f65606c9
|
data/lib/fbe/tombstone.rb
CHANGED
@@ -23,7 +23,7 @@ class Fbe::Tombstone
|
|
23
23
|
|
24
24
|
# Put it there.
|
25
25
|
# @param [Integer] repo ID of repository
|
26
|
-
# @param [Integer] issue ID of issue
|
26
|
+
# @param [Integer] issue ID of issue (or array of them)
|
27
27
|
def bury!(repo, issue)
|
28
28
|
f =
|
29
29
|
Fbe.if_absent(fb: @fb, always: true) do |n|
|
@@ -32,7 +32,10 @@ class Fbe::Tombstone
|
|
32
32
|
end
|
33
33
|
f.send(:"#{@fid}=", SecureRandom.random_number(99_999)) if f[@fid].nil?
|
34
34
|
nn = f['issues']&.map { |ii| ii.split('-').map(&:to_i) } || []
|
35
|
-
|
35
|
+
issue = [issue] unless issue.is_a?(Array)
|
36
|
+
issue.each do |i|
|
37
|
+
nn << [i, i]
|
38
|
+
end
|
36
39
|
nn = nn.sort_by(&:first)
|
37
40
|
merged = []
|
38
41
|
nn.each do |a, b|
|
@@ -52,16 +55,19 @@ class Fbe::Tombstone
|
|
52
55
|
|
53
56
|
# Is it there?
|
54
57
|
# @param [Integer] repo ID of repository
|
55
|
-
# @param [Integer] issue ID of issue
|
58
|
+
# @param [Integer] issue ID of issue (or array of them)
|
56
59
|
# @return [Boolean] True if it's there
|
57
60
|
def has?(repo, issue)
|
58
61
|
f = @fb.query(
|
59
62
|
"(and (eq what 'tombstone') (eq repository #{repo}) (exists issues))"
|
60
63
|
).each.first
|
61
64
|
return false if f.nil?
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
+
issue = [issue] unless issue.is_a?(Array)
|
66
|
+
issue.all? do |i|
|
67
|
+
f['issues'].any? do |ii|
|
68
|
+
a, b = ii.split('-').map(&:to_i)
|
69
|
+
(a..b).cover?(i)
|
70
|
+
end
|
65
71
|
end
|
66
72
|
end
|
67
73
|
end
|
data/lib/fbe.rb
CHANGED
data/test/fbe/test_tombstone.rb
CHANGED
@@ -31,16 +31,22 @@ class TestTombstone < Fbe::Test
|
|
31
31
|
refute(ts.has?(8, 7))
|
32
32
|
end
|
33
33
|
|
34
|
+
def test_bury_twice
|
35
|
+
fb = Factbase.new
|
36
|
+
ts = Fbe::Tombstone.new(fb:)
|
37
|
+
2.times { ts.bury!(42, 7) }
|
38
|
+
assert(ts.has?(42, 7))
|
39
|
+
end
|
40
|
+
|
34
41
|
def test_merges_them
|
35
42
|
fb = Factbase.new
|
36
43
|
ts = Fbe::Tombstone.new(fb:)
|
37
44
|
ts.bury!(42, 13)
|
38
45
|
ts.bury!(42, 18)
|
39
46
|
ts.bury!(42, 14)
|
40
|
-
ts.bury!(42, 17)
|
41
|
-
ts.bury!(42, 15)
|
42
|
-
ts.bury!(42, 16)
|
47
|
+
ts.bury!(42, [17, 15, 16])
|
43
48
|
assert(ts.has?(42, 16))
|
49
|
+
assert(ts.has?(42, [16, 18]))
|
44
50
|
refute(ts.has?(42, 22))
|
45
51
|
end
|
46
52
|
end
|