fbe 0.0.6 → 0.0.7

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: fab7625b074b08c9833722e095ed311608a4a327c4c0b3388ec498675f7547d3
4
- data.tar.gz: 25ae45a82dd59a4a1a98b6bf4850e073839371eed3fd3b1a23b94698151e0354
3
+ metadata.gz: a0081d0ed95bf4d88cc396b55651521cf252d5a7894c93e5942a4f44f902a3bd
4
+ data.tar.gz: b9624f277446d361ac46b2e89d04e4b8b4a20c93adfa8c2f5b0452febde43b7b
5
5
  SHA512:
6
- metadata.gz: c9a4b21c1f88fa90307424b15b61f54143e8e044483907fea9fa3b697be95ea9dff8cec442aec4bd4c90887da7f9d6559d0fd766f9217034da95d4c2d3cf72ba
7
- data.tar.gz: b6a9fbf625b2874080fe8edb81adc4377e6f9a7b17e3600c890d5e1336b4c5a8c47b97ef04bb39426a46b572dc10cc1962be14f68a3a0850bddda2fc2fcc6bdb
6
+ metadata.gz: 92fd51fff1c6f6347bfe1a89caa2e94bca3277c963ccaf4cce54b33144e1a38f6e060f771e8cab07503d064f1a1c4cbae47cbd5faca2ac338b6240e8308d3aff
7
+ data.tar.gz: 3e03f00ef4d1c127aa021c89a72ec3f8b273b43fe2bef85bc944063e52ae0fb77a4f93d8883b6c4855852b5f67c067ffd37be04bc7b1b73cc70b454d8e295a94
data/.rubocop.yml CHANGED
@@ -40,10 +40,10 @@ Style/ClassAndModuleChildren:
40
40
  Enabled: false
41
41
  Layout/MultilineMethodCallIndentation:
42
42
  Enabled: false
43
+ Metrics/BlockLength:
44
+ Enabled: false
43
45
  Metrics/AbcSize:
44
46
  Enabled: false
45
- Metrics/BlockLength:
46
- Max: 30
47
47
  Metrics/CyclomaticComplexity:
48
48
  Max: 25
49
49
  Metrics/PerceivedComplexity:
data/Gemfile CHANGED
@@ -28,7 +28,7 @@ gem 'rake', '13.2.1', require: false
28
28
  gem 'rspec-rails', '6.1.3', require: false
29
29
  gem 'rubocop', '1.64.1', require: false
30
30
  gem 'rubocop-performance', '1.21.1', require: false
31
- gem 'rubocop-rspec', '3.0.1', require: false
31
+ gem 'rubocop-rspec', '3.0.2', require: false
32
32
  gem 'simplecov', '0.22.0', require: false
33
33
  gem 'simplecov-cobertura', '2.1.0', require: false
34
34
  gem 'yard', '0.9.36', require: false
data/Gemfile.lock CHANGED
@@ -62,7 +62,7 @@ GEM
62
62
  erubi (1.13.0)
63
63
  ethon (0.16.0)
64
64
  ffi (>= 1.15.0)
65
- factbase (0.0.58)
65
+ factbase (0.0.60)
66
66
  backtrace (~> 0.3)
67
67
  decoor (~> 0.0)
68
68
  json (~> 2.7)
@@ -94,7 +94,7 @@ GEM
94
94
  reline (>= 0.4.2)
95
95
  iri (0.8.0)
96
96
  json (2.7.2)
97
- judges (0.15.0)
97
+ judges (0.15.3)
98
98
  backtrace (~> 0.3)
99
99
  concurrent-ruby (~> 1.2)
100
100
  factbase (~> 0.0)
@@ -139,7 +139,7 @@ GEM
139
139
  stringio
140
140
  public_suffix (6.0.0)
141
141
  racc (1.8.0)
142
- rack (3.1.5)
142
+ rack (3.1.6)
143
143
  rack-session (2.0.0)
144
144
  rack (>= 3.0.0)
145
145
  rack-test (2.1.0)
@@ -205,7 +205,7 @@ GEM
205
205
  rubocop-performance (1.21.1)
206
206
  rubocop (>= 1.48.1, < 2.0)
207
207
  rubocop-ast (>= 1.31.1, < 2.0)
208
- rubocop-rspec (3.0.1)
208
+ rubocop-rspec (3.0.2)
209
209
  rubocop (~> 1.61)
210
210
  ruby-progressbar (1.13.0)
211
211
  sawyer (0.9.2)
@@ -251,7 +251,7 @@ DEPENDENCIES
251
251
  rspec-rails (= 6.1.3)
252
252
  rubocop (= 1.64.1)
253
253
  rubocop-performance (= 1.21.1)
254
- rubocop-rspec (= 3.0.1)
254
+ rubocop-rspec (= 3.0.2)
255
255
  simplecov (= 0.22.0)
256
256
  simplecov-cobertura (= 2.1.0)
257
257
  yard (= 0.9.36)
data/lib/fbe/conclude.rb CHANGED
@@ -44,7 +44,6 @@ class Fbe::Conclude
44
44
  @loog = loog
45
45
  @query = nil
46
46
  @follows = []
47
- @threshold = 9999
48
47
  @quota_aware = false
49
48
  end
50
49
 
@@ -57,10 +56,6 @@ class Fbe::Conclude
57
56
  @query = query
58
57
  end
59
58
 
60
- def threshold(max)
61
- @threshold = max
62
- end
63
-
64
59
  def follow(props)
65
60
  @follows = props.split
66
61
  end
@@ -96,7 +91,6 @@ class Fbe::Conclude
96
91
  @fb.txn do |fbt|
97
92
  fbt.query(@query).each do |a|
98
93
  throw :stop if @quota_aware && Fbe.octo(loog: @loog).off_quota
99
- throw :stop if passed >= @threshold
100
94
  n = yield fbt, a
101
95
  @loog.info("#{n.what}: #{n.details}") unless n.nil?
102
96
  passed += 1
data/lib/fbe/fb.rb CHANGED
@@ -29,18 +29,20 @@ require 'factbase/pre'
29
29
  require 'factbase/rules'
30
30
  require_relative '../fbe'
31
31
 
32
- def Fbe.fb
33
- rules = Dir.glob(File.join('rules', '*.fe')).map { |f| File.read(f) }
34
- fb = Factbase::Rules.new(
35
- $fb,
36
- "(and \n#{rules.join("\n")}\n)",
37
- uid: '_id'
38
- )
39
- fb = Factbase::Pre.new(fb) do |f|
40
- max = $fb.query('(eq _id (max _id))').each.to_a.first
41
- f._id = (max.nil? ? 0 : max._id) + 1
42
- f._time = Time.now
43
- f._version = "#{Factbase::VERSION}/#{Judges::VERSION}/#{$options.judges_action_version}"
32
+ def Fbe.fb(global: $global)
33
+ global[:fb] ||= begin
34
+ rules = Dir.glob(File.join('rules', '*.fe')).map { |f| File.read(f) }
35
+ fb = Factbase::Rules.new(
36
+ $fb,
37
+ "(and \n#{rules.join("\n")}\n)",
38
+ uid: '_id'
39
+ )
40
+ fb = Factbase::Pre.new(fb) do |f|
41
+ max = $fb.query('(eq _id (max _id))').each.to_a.first
42
+ f._id = (max.nil? ? 0 : max._id) + 1
43
+ f._time = Time.now
44
+ f._version = "#{Factbase::VERSION}/#{Judges::VERSION}/#{$options.judges_action_version}"
45
+ end
46
+ Factbase::Looged.new(fb, Loog::NULL)
44
47
  end
45
- Factbase::Looged.new(fb, Loog::NULL)
46
48
  end
data/lib/fbe/iterate.rb CHANGED
@@ -78,7 +78,10 @@ class Fbe::Iterate
78
78
  loop do
79
79
  repos.each do |repo|
80
80
  seen[repo] = 0 if seen[repo].nil?
81
- next if seen[repo] > @limit
81
+ if seen[repo] > @limit
82
+ @loog.debug("We've seen too many in the #{repo} repo, time to move to the next one")
83
+ next
84
+ end
82
85
  rid = oct.repo_id_by_name(repo)
83
86
  before = Fbe.fb.query(
84
87
  "(agg (and (eq what '#{@label}') (eq where 'github') (eq repository #{rid})) (first latest))"
@@ -86,21 +89,42 @@ class Fbe::Iterate
86
89
  Fbe.fb.query("(and (eq what '#{@label}') (eq where 'github') (eq repository #{rid}))").delete!
87
90
  before = before.nil? ? @since : before[0]
88
91
  nxt = Fbe.fb.query(@query).one(before:, repository: rid)
89
- after = nxt.nil? ? @since : yield(rid, nxt)
92
+ after =
93
+ if nxt.nil?
94
+ @loog.debug("Next is nil, starting from the beginning at #{@since}")
95
+ @since
96
+ else
97
+ @loog.debug("Next is #{nxt}, starting from it...")
98
+ yield(rid, nxt)
99
+ end
90
100
  raise "Iterator must return an Integer, while #{after.class} returned" unless after.is_a?(Integer)
91
101
  f = Fbe.fb.insert
92
102
  f.where = 'github'
93
103
  f.repository = rid
94
- f.latest = after.nil? ? nxt : after
104
+ f.latest =
105
+ if after.nil?
106
+ @loog.debug("After is nil, setting the `latest` to nxt: #{nxt}")
107
+ nxt
108
+ else
109
+ @loog.debug("After is #{after}, setting the `latest` to it")
110
+ after
111
+ end
95
112
  f.what = @label
96
113
  seen[repo] += 1
97
- break if oct.off_quota
114
+ if oct.off_quota
115
+ @loog.debug('We are off GitHub quota, time to stop')
116
+ break
117
+ end
118
+ end
119
+ if oct.off_quota
120
+ @loog.debug('We are off GitHub quota, time to stop')
121
+ break
98
122
  end
99
- break if oct.off_quota
100
123
  unless seen.values.any? { |v| v < @limit }
101
- @loog.debug("Finished scanning #{repos.size} repos: #{seen.map { |k, v| "#{k}:#{v}" }.join(', ')}")
124
+ @loog.debug('No more repos to scan, quitting')
102
125
  break
103
126
  end
104
127
  end
128
+ @loog.debug("Finished scanning #{repos.size} repos: #{seen.map { |k, v| "#{k}:#{v}" }.join(', ')}")
105
129
  end
106
130
  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.6'
30
+ VERSION = '0.0.7'
31
31
  end
@@ -37,6 +37,7 @@ require_relative '../../lib/fbe/fb'
37
37
  class TestConclude < Minitest::Test
38
38
  def test_with_defaults
39
39
  $fb = Factbase.new
40
+ $global = {}
40
41
  $options = Judges::Options.new
41
42
  $loog = Loog::NULL
42
43
  Fbe.conclude do
@@ -63,6 +64,7 @@ class TestConclude < Minitest::Test
63
64
 
64
65
  def test_maybe
65
66
  $fb = Factbase.new
67
+ $global = {}
66
68
  $options = Judges::Options.new
67
69
  $loog = Loog::NULL
68
70
  Fbe.fb.insert.foo = 1
@@ -84,6 +86,7 @@ class TestConclude < Minitest::Test
84
86
 
85
87
  def test_consider
86
88
  $fb = Factbase.new
89
+ $global = {}
87
90
  $options = Judges::Options.new
88
91
  $loog = Loog::NULL
89
92
  Fbe.fb.insert.foo = 1
data/test/fbe/test_fb.rb CHANGED
@@ -35,6 +35,7 @@ require_relative '../../lib/fbe/fb'
35
35
  class TestFb < Minitest::Test
36
36
  def test_simple
37
37
  $fb = Factbase.new
38
+ $global = {}
38
39
  $options = Judges::Options.new
39
40
  Fbe.fb.insert.foo = 1
40
41
  Fbe.fb.insert.bar = 2
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-02 00:00:00.000000000 Z
11
+ date: 2024-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace