fbe 0.26.10 → 0.27.0

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: 33191f9b5caa7d78adcc43470dce7ff68e065615b307771c5e9a3a654f04a685
4
- data.tar.gz: 6e45dcbc39ccb971d2ad3262873dbd78751c83b24e4ee6b80fe2a28321119ede
3
+ metadata.gz: adc685c3339da51fe5383adf29077dbd80f69119ee9b0586c2057a4306f5fdf8
4
+ data.tar.gz: d32fc6fa6429d9cd5496ccd9e3713eb58addb2a7d5c33e95110d862c190c2816
5
5
  SHA512:
6
- metadata.gz: 6e820a534570250582bbec0bd14db5fe0b436d2df6f5a00bb89f8b24b01850641f21c184909e1ed41c1cd3cd1d43cc3c65d64ff01405a9ebe13ea6be507aa02e
7
- data.tar.gz: cd81c87c21eaff9f4e23e96eb18a327d599555186fac0c4dc110129a4ca6797ded2ef9931aaa9dd1e346da5cf2caaf5f3ff4173b251bac07dd24e41d9b32e888
6
+ metadata.gz: d3adb34a8a544118f6d29ebf354714f2fea1dc8b402a81ecf0047d64abc009855c5acb909b7eba9fa9fe860531a053750a8e78c671019967da3178b8d147e5c8
7
+ data.tar.gz: 1d05a3074bc928d4eec38529866ef39e11f077f30c8906be3af99a124b89155bcd0ed2ab69a4bb258d2337fa85484c1c8d9b1ecf0e60169d1d81f0cc5e862037
@@ -15,7 +15,7 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v4
18
+ - uses: actions/checkout@v5
19
19
  - name: Download actionlint
20
20
  id: get_actionlint
21
21
  run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
@@ -12,7 +12,7 @@ jobs:
12
12
  timeout-minutes: 15
13
13
  runs-on: ubuntu-24.04
14
14
  steps:
15
- - uses: actions/checkout@v4
15
+ - uses: actions/checkout@v5
16
16
  - uses: ruby/setup-ruby@v1
17
17
  with:
18
18
  ruby-version: 3.3
@@ -11,5 +11,5 @@ jobs:
11
11
  timeout-minutes: 15
12
12
  runs-on: ubuntu-24.04
13
13
  steps:
14
- - uses: actions/checkout@v4
14
+ - uses: actions/checkout@v5
15
15
  - uses: yegor256/copyrights-action@0.0.12
@@ -19,5 +19,5 @@ jobs:
19
19
  timeout-minutes: 15
20
20
  runs-on: ubuntu-24.04
21
21
  steps:
22
- - uses: actions/checkout@v4
22
+ - uses: actions/checkout@v5
23
23
  - uses: DavidAnson/markdownlint-cli2-action@v20.0.0
@@ -15,5 +15,5 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v4
18
+ - uses: actions/checkout@v5
19
19
  - uses: volodya-lombrozo/pdd-action@master
@@ -18,7 +18,7 @@ jobs:
18
18
  ruby: [3.3]
19
19
  runs-on: ${{ matrix.os }}
20
20
  steps:
21
- - uses: actions/checkout@v4
21
+ - uses: actions/checkout@v5
22
22
  - uses: ruby/setup-ruby@v1
23
23
  with:
24
24
  ruby-version: ${{ matrix.ruby }}
@@ -15,5 +15,5 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v4
18
+ - uses: actions/checkout@v5
19
19
  - uses: fsfe/reuse-action@v5
@@ -15,7 +15,7 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v4
19
- - uses: crate-ci/typos@v1.35.3
18
+ - uses: actions/checkout@v5
19
+ - uses: crate-ci/typos@v1.35.5
20
20
  with:
21
21
  config: .github/.typos.toml
@@ -11,5 +11,5 @@ jobs:
11
11
  timeout-minutes: 15
12
12
  runs-on: ubuntu-24.04
13
13
  steps:
14
- - uses: actions/checkout@v4
14
+ - uses: actions/checkout@v5
15
15
  - uses: g4s8/xcop-action@master
@@ -15,7 +15,7 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v4
18
+ - uses: actions/checkout@v5
19
19
  - uses: ibiqlik/action-yamllint@v3
20
20
  with:
21
21
  config_file: .yamllint.yml
data/Gemfile.lock CHANGED
@@ -28,7 +28,7 @@ PATH
28
28
  GEM
29
29
  remote: https://rubygems.org/
30
30
  specs:
31
- activesupport (8.0.2)
31
+ activesupport (8.0.2.1)
32
32
  base64
33
33
  benchmark (>= 0.3)
34
34
  bigdecimal
@@ -47,7 +47,7 @@ GEM
47
47
  ast (2.4.3)
48
48
  backtrace (0.4.1)
49
49
  base64 (0.3.0)
50
- baza.rb (0.10.0)
50
+ baza.rb (0.10.1)
51
51
  backtrace (~> 0.4)
52
52
  elapsed (~> 0.0)
53
53
  faraday (~> 2.13)
@@ -74,18 +74,18 @@ GEM
74
74
  loog (~> 0.6)
75
75
  tago (~> 0.1)
76
76
  ellipsized (0.3.0)
77
- ethon (0.16.0)
77
+ ethon (0.17.0)
78
78
  ffi (>= 1.15.0)
79
- factbase (0.14.7)
79
+ factbase (0.15.6)
80
80
  backtrace (~> 0.4)
81
- decoor (~> 0.0)
81
+ decoor (~> 0.1)
82
82
  ellipsized (~> 0.3)
83
83
  json (~> 2.7)
84
84
  logger (~> 1.0)
85
85
  loog (~> 0.6)
86
86
  nokogiri (~> 1.10)
87
- others (~> 0.0)
88
- tago (~> 0.0)
87
+ others (~> 0.1)
88
+ tago (~> 0.1)
89
89
  yaml (~> 0.3)
90
90
  faraday (2.13.4)
91
91
  faraday-net_http (>= 2.0, < 3.5)
@@ -121,7 +121,7 @@ GEM
121
121
  iri (0.11.2)
122
122
  joined (0.4.0)
123
123
  json (2.13.2)
124
- judges (0.52.2)
124
+ judges (0.53.1)
125
125
  backtrace (~> 0.4)
126
126
  baza.rb (~> 0.5)
127
127
  concurrent-ruby (~> 1.2)
@@ -186,10 +186,10 @@ GEM
186
186
  racc (1.8.1)
187
187
  rainbow (3.1.1)
188
188
  rake (13.3.0)
189
- regexp_parser (2.11.1)
189
+ regexp_parser (2.11.2)
190
190
  retries (0.0.5)
191
191
  rexml (3.4.1)
192
- rubocop (1.79.2)
192
+ rubocop (1.80.0)
193
193
  json (~> 2.3)
194
194
  language_server-protocol (~> 3.17.0.2)
195
195
  lint_roller (~> 1.1.0)
@@ -240,12 +240,12 @@ GEM
240
240
  ethon (>= 0.9.0)
241
241
  tzinfo (2.0.6)
242
242
  concurrent-ruby (~> 1.0)
243
- unicode-display_width (3.1.4)
243
+ unicode-display_width (3.1.5)
244
244
  unicode-emoji (~> 4.0, >= 4.0.4)
245
245
  unicode-emoji (4.0.4)
246
246
  uri (1.0.3)
247
247
  veils (0.4.0)
248
- verbose (0.0.2)
248
+ verbose (0.1.0)
249
249
  loog (~> 0.2)
250
250
  tago (~> 0.0)
251
251
  webmock (3.25.1)
data/lib/fbe/delete.rb CHANGED
@@ -30,16 +30,17 @@ def Fbe.delete(fact, *props, fb: Fbe.fb, id: '_id')
30
30
  before = {}
31
31
  fact.all_properties.each do |k|
32
32
  next if props.include?(k)
33
- fact[k].each do |v|
34
- before[k] = v
35
- end
33
+ before[k] = fact[k]
36
34
  end
37
35
  before.delete(id)
38
36
  fb.query("(eq #{id} #{i})").delete!
39
37
  fb.txn do |fbt|
40
38
  c = fbt.insert
41
- before.each do |k, v|
42
- c.send(:"#{k}=", v) if c[k].nil?
39
+ before.each do |k, vv|
40
+ next unless c[k].nil?
41
+ vv.each do |v|
42
+ c.send(:"#{k}=", v)
43
+ end
43
44
  end
44
45
  end
45
46
  nil
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ require_relative '../fbe'
7
+ require_relative 'fb'
8
+
9
+ # Delete one value of a property.
10
+ #
11
+ # This method doesn't modify the original fact. Instead, it deletes the existing
12
+ # fact from the factbase and creates a new one with all properties except the one
13
+ # specified for deletion.
14
+ #
15
+ # @param [Factbase::Fact] fact The fact to delete properties from (must have an ID)
16
+ # @param [String] prop The property name
17
+ # @param [Any] value The value to delete
18
+ # @param [Factbase] fb The factbase to use (defaults to Fbe.fb)
19
+ # @param [String] id The property name used as unique identifier (defaults to '_id')
20
+ # @return [nil] Nothing
21
+ def Fbe.delete_one(fact, prop, value, fb: Fbe.fb, id: '_id')
22
+ raise 'The fact is nil' if fact.nil?
23
+ i = fact[id]
24
+ raise "There is no #{id.inspect} in the fact" if i.nil?
25
+ i = i.first
26
+ before = {}
27
+ fact.all_properties.each do |k|
28
+ before[k] = fact[k]
29
+ end
30
+ return unless before[prop]
31
+ before[prop] = before[prop] - [value]
32
+ before.delete(prop) if before[prop].empty?
33
+ fb.query("(eq #{id} #{i})").delete!
34
+ fb.txn do |fbt|
35
+ c = fbt.insert
36
+ before.each do |k, vv|
37
+ next unless c[k].nil?
38
+ vv.each do |v|
39
+ c.send(:"#{k}=", v)
40
+ end
41
+ end
42
+ end
43
+ nil
44
+ end
data/lib/fbe/iterate.rb CHANGED
@@ -204,16 +204,16 @@ class Fbe::Iterate
204
204
  @loog.debug('We are off GitHub quota, cannot even start, sorry')
205
205
  return
206
206
  end
207
- repos = Fbe.unmask_repos(loog: @loog, options: @options, global: @global)
207
+ repos = Fbe.unmask_repos(loog: @loog, options: @options, global: @global, quota_aware: @quota_aware)
208
208
  restarted = []
209
209
  start = Time.now
210
210
  loop do
211
- if oct.off_quota?
211
+ if @quota_aware && oct.off_quota?
212
212
  @loog.info("We are off GitHub quota, time to stop after #{start.ago}")
213
213
  break
214
214
  end
215
215
  repos.each do |repo|
216
- if oct.off_quota?
216
+ if @quota_aware && oct.off_quota?
217
217
  @loog.debug("We are off GitHub quota, we must skip #{repo}")
218
218
  break
219
219
  end
@@ -266,10 +266,6 @@ class Fbe::Iterate
266
266
  @loog.debug("All #{repos.size} repos restarted, quitting after #{start.ago}")
267
267
  break
268
268
  end
269
- if Time.now - start > timeout
270
- @loog.info("We are iterating for #{start.ago} already, time to give up")
271
- break
272
- end
273
269
  end
274
270
  @loog.debug("Finished scanning #{repos.size} repos in #{start.ago}: #{seen.map { |k, v| "#{k}:#{v}" }.joined}")
275
271
  end
@@ -52,7 +52,7 @@ class Fbe::Middleware::Trace < Faraday::Middleware
52
52
  @app.call(env).on_complete do |response_env|
53
53
  next if !@ignores.empty? &&
54
54
  response_env[:http_cache_trace] &&
55
- (response_env[:http_cache_trace] & @ignores).size.positive?
55
+ response_env[:http_cache_trace].intersect?(@ignores)
56
56
  finished = Time.now
57
57
  duration = finished - entry[:started_at]
58
58
  entry[:status] = response_env.status
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.26.10' unless const_defined?(:VERSION)
13
+ VERSION = '0.27.0' unless const_defined?(:VERSION)
14
14
  end
@@ -155,7 +155,6 @@ class SqliteStoreTest < Fbe::Test
155
155
  def test_shrink_cache_if_more_then_10_mb
156
156
  with_tmpfile('large.db') do |f|
157
157
  Fbe::Middleware::SqliteStore.new(f, '0.0.1', loog: fake_loog).then do |store|
158
- key = 'aaa'
159
158
  store.write('a', 'aa')
160
159
  Time.stub(:now, (Time.now - (5 * 60 * 60)).round) do
161
160
  store.write('b', 'bb')
@@ -163,8 +162,9 @@ class SqliteStoreTest < Fbe::Test
163
162
  end
164
163
  assert_equal('cc', store.read('c'))
165
164
  Time.stub(:now, rand((Time.now - (5 * 60 * 60))..Time.now).round) do
166
- value = SecureRandom.alphanumeric(2048)
167
- 10_240.times do
165
+ key = 'a' * 65_536
166
+ value = SecureRandom.alphanumeric(8_192)
167
+ 52.times do
168
168
  store.write(key, value)
169
169
  key = key.next
170
170
  end
@@ -27,6 +27,29 @@ class TestDelete < Fbe::Test
27
27
  assert_equal(4, fb.query('(exists hey)').each.first.hey)
28
28
  end
29
29
 
30
+ def test_deletes_when_many
31
+ fb = Factbase.new
32
+ f = fb.insert
33
+ f.foo = 42
34
+ f.foo = 'hello'
35
+ f.bar = 4
36
+ f._id = 555
37
+ Fbe.delete(f, 'bar', fb:)
38
+ assert_equal(1, fb.size)
39
+ assert_equal([42, 'hello'], fb.query('(exists foo)').each.first['foo'])
40
+ end
41
+
42
+ def test_deletes_nothing
43
+ fb = Factbase.new
44
+ f = fb.insert
45
+ f.foo = 42
46
+ f.foo = 'hello'
47
+ f._id = 555
48
+ Fbe.delete(f, 'bar', fb:)
49
+ assert_equal(1, fb.size)
50
+ assert_equal([42, 'hello'], fb.query('(exists foo)').each.first['foo'])
51
+ end
52
+
30
53
  def test_deletes_two_properties
31
54
  fb = Factbase.new
32
55
  f = fb.insert
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ require 'factbase'
7
+ require 'judges/options'
8
+ require 'loog'
9
+ require_relative '../../lib/fbe/delete_one'
10
+ require_relative '../../lib/fbe/fb'
11
+ require_relative '../test__helper'
12
+
13
+ # Test.
14
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
15
+ # Copyright:: Copyright (c) 2024-2025 Zerocracy
16
+ # License:: MIT
17
+ class TestDeleteOne < Fbe::Test
18
+ def test_deletes_one_value
19
+ fb = Factbase.new
20
+ f = fb.insert
21
+ f.foo = 42
22
+ f.foo = 'hello'
23
+ f._id = 555
24
+ Fbe.delete_one(f, 'foo', 42, fb:)
25
+ assert_equal(1, fb.size)
26
+ assert_equal(1, fb.query('(exists foo)').each.to_a.size)
27
+ assert_equal(0, fb.query('(eq foo 42)').each.to_a.size)
28
+ assert_equal(['hello'], fb.query('(exists foo)').each.first['foo'])
29
+ end
30
+
31
+ def test_deletes_when_many
32
+ fb = Factbase.new
33
+ f = fb.insert
34
+ f.foo = 42
35
+ f.foo = 'hello'
36
+ f.bar = 44
37
+ f._id = 555
38
+ Fbe.delete_one(f, 'bar', 44, fb:)
39
+ assert_equal(1, fb.size)
40
+ assert_equal(1, fb.query('(exists foo)').each.to_a.size)
41
+ assert_equal(1, fb.query('(eq foo 42)').each.to_a.size)
42
+ assert_equal([42, 'hello'], fb.query('(exists foo)').each.first['foo'])
43
+ end
44
+
45
+ def test_deletes_nothing
46
+ fb = Factbase.new
47
+ f = fb.insert
48
+ f.foo = 42
49
+ f.foo = 'hello'
50
+ f._id = 555
51
+ Fbe.delete_one(f, 'bar', 42, fb:)
52
+ assert_equal(1, fb.size)
53
+ assert_equal(1, fb.query('(exists foo)').each.to_a.size)
54
+ assert_equal(1, fb.query('(eq foo 42)').each.to_a.size)
55
+ end
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.26.10
4
+ version: 0.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -368,6 +368,7 @@ files:
368
368
  - lib/fbe/conclude.rb
369
369
  - lib/fbe/copy.rb
370
370
  - lib/fbe/delete.rb
371
+ - lib/fbe/delete_one.rb
371
372
  - lib/fbe/enter.rb
372
373
  - lib/fbe/fb.rb
373
374
  - lib/fbe/github_graph.rb
@@ -399,6 +400,7 @@ files:
399
400
  - test/fbe/test_conclude.rb
400
401
  - test/fbe/test_copy.rb
401
402
  - test/fbe/test_delete.rb
403
+ - test/fbe/test_delete_one.rb
402
404
  - test/fbe/test_enter.rb
403
405
  - test/fbe/test_fb.rb
404
406
  - test/fbe/test_github_graph.rb
@@ -436,7 +438,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
436
438
  - !ruby/object:Gem::Version
437
439
  version: '0'
438
440
  requirements: []
439
- rubygems_version: 3.6.7
441
+ rubygems_version: 3.6.9
440
442
  specification_version: 4
441
443
  summary: FactBase Extended (FBE), a collection of utility classes for Zerocracy judges
442
444
  test_files: []