fbe 0.32.0 → 0.33.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: e782b5b62b94f84bcd91047a11d9597ecfd038721e98717b6d0ca880d55276d6
4
- data.tar.gz: e6fce4664e48cf191f8bc36319c2b1da042932c9a1e2e1e56c96d3f9dee76ee6
3
+ metadata.gz: '05709f3a8b84855b1cb59a586eb4ae7a83f2f87bf0d8490d14a4b59659513cd6'
4
+ data.tar.gz: 54da9a5a7e9d638859cfdb0b7c9b192673fdb2ede19ae4e3afecdbcf1164db36
5
5
  SHA512:
6
- metadata.gz: f11e700c5230f040bc376f333cb7752af379acb06452977a89fb6ff0be34a4217c80d2f261d845be5fe9bb934e2e35c527480a757a4c4568b8c8742550571632
7
- data.tar.gz: 9df8ad3c5936aa7a0f4246e40684df7dd8408260b6561db8206827f17f6ee2963759b638da31d04443ace8759ce62a51786b023472b86df3ad35c877e2d0e76a
6
+ metadata.gz: ab66f21e8f0f80070e3a8908fade06c2088659660d6d9aa127f6bc86e555b3efc4d3542aae40cfd301e2caa0af80a9227b02aaac5ce7e562ec346dad85d06ecf
7
+ data.tar.gz: e381efafdacff36bf1119f0075c18f558af4531a17a4e2ad9d15663f330bca2da7cde3c0862d2d98db5ee6bbe28e12d41c8617bd923b334c5b833befbfe8dcbb
data/Gemfile.lock CHANGED
@@ -60,7 +60,7 @@ GEM
60
60
  tago (~> 0.0)
61
61
  typhoeus (~> 1.4)
62
62
  benchmark (0.4.1)
63
- bigdecimal (3.2.2)
63
+ bigdecimal (3.2.3)
64
64
  builder (3.3.0)
65
65
  concurrent-ruby (1.3.5)
66
66
  connection_pool (2.5.4)
@@ -76,7 +76,7 @@ GEM
76
76
  ellipsized (0.3.0)
77
77
  ethon (0.15.0)
78
78
  ffi (>= 1.15.0)
79
- factbase (0.15.7)
79
+ factbase (0.16.1)
80
80
  backtrace (~> 0.4)
81
81
  decoor (~> 0.1)
82
82
  ellipsized (~> 0.3)
@@ -114,7 +114,7 @@ GEM
114
114
  graphql-client (0.26.0)
115
115
  activesupport (>= 3.0)
116
116
  graphql (>= 1.13.0)
117
- hashdiff (1.2.0)
117
+ hashdiff (1.2.1)
118
118
  i18n (1.14.7)
119
119
  concurrent-ruby (~> 1.0)
120
120
  intercepted (0.2.0)
@@ -233,7 +233,7 @@ GEM
233
233
  sqlite3 (2.7.3-x86_64-darwin)
234
234
  sqlite3 (2.7.3-x86_64-linux-gnu)
235
235
  strscan (3.1.5)
236
- tago (0.1.0)
236
+ tago (0.2.0)
237
237
  timeout (0.4.3)
238
238
  total (0.4.1)
239
239
  typhoeus (1.5.0)
data/lib/fbe/conclude.rb CHANGED
@@ -19,14 +19,14 @@ require_relative 'octo'
19
19
  # @yield [Factbase::Fact] The fact
20
20
  def Fbe.conclude(
21
21
  fb: Fbe.fb, judge: $judge, loog: $loog, options: $options, global: $global,
22
- start: $start, time: Time, &
22
+ start: $start, &
23
23
  )
24
24
  raise 'The fb is nil' if fb.nil?
25
25
  raise 'The $judge is not set' if judge.nil?
26
26
  raise 'The $global is not set' if global.nil?
27
27
  raise 'The $options is not set' if options.nil?
28
28
  raise 'The $loog is not set' if loog.nil?
29
- c = Fbe::Conclude.new(fb:, judge:, loog:, options:, global:, start:, time:)
29
+ c = Fbe::Conclude.new(fb:, judge:, loog:, options:, global:, start:)
30
30
  c.instance_eval(&)
31
31
  end
32
32
 
@@ -61,8 +61,7 @@ class Fbe::Conclude
61
61
  # @param [Hash] global The hash for global caching
62
62
  # @param [Judges::Options] options The options coming from the +judges+ tool
63
63
  # @param [Loog] loog The logging facility
64
- # @param [Time] time The time
65
- def initialize(fb:, judge:, global:, options:, loog:, start:, time: Time)
64
+ def initialize(fb:, judge:, global:, options:, loog:, start:)
66
65
  @fb = fb
67
66
  @judge = judge
68
67
  @loog = loog
@@ -74,7 +73,6 @@ class Fbe::Conclude
74
73
  @lifetime_aware = true
75
74
  @quota_aware = true
76
75
  @timeout = 60
77
- @time = time
78
76
  end
79
77
 
80
78
  # Make this block not aware of GitHub API quota.
@@ -92,7 +90,7 @@ class Fbe::Conclude
92
90
  # When the lifetime is over, the loop will NOT gracefully stop.
93
91
  #
94
92
  # @return [nil] Nothing is returned
95
- def lifetime_aware
93
+ def lifetime_unaware
96
94
  @lifetime_aware = false
97
95
  end
98
96
 
@@ -195,7 +193,6 @@ class Fbe::Conclude
195
193
  # end
196
194
  def roll(&)
197
195
  passed = 0
198
- start = @time.now
199
196
  oct = Fbe.octo(loog: @loog, options: @options, global: @global)
200
197
  @fb.query(@query).each do |a|
201
198
  if @quota_aware && oct.off_quota?
@@ -206,9 +203,8 @@ class Fbe::Conclude
206
203
  @loog.debug('We ran out of lifetime, must stop here')
207
204
  break
208
205
  end
209
- now = @time.now
210
- if now > start + @timeout
211
- @loog.debug("We've spent more than #{start.ago}, must stop here")
206
+ if Time.now > @start + @timeout
207
+ @loog.debug("We've spent more than #{@start.ago}, must stop here")
212
208
  break
213
209
  end
214
210
  @fb.txn do |fbt|
data/lib/fbe/iterate.rb CHANGED
@@ -37,12 +37,12 @@ require_relative 'unmask_repos'
37
37
  # issue_id + 1
38
38
  # end
39
39
  # end
40
- def Fbe.iterate(fb: Fbe.fb, loog: $loog, options: $options, global: $global, &)
40
+ def Fbe.iterate(fb: Fbe.fb, loog: $loog, options: $options, global: $global, start: $start, &)
41
41
  raise 'The fb is nil' if fb.nil?
42
42
  raise 'The $global is not set' if global.nil?
43
43
  raise 'The $options is not set' if options.nil?
44
44
  raise 'The $loog is not set' if loog.nil?
45
- c = Fbe::Iterate.new(fb:, loog:, options:, global:)
45
+ c = Fbe::Iterate.new(fb:, loog:, options:, global:, start:)
46
46
  c.instance_eval(&)
47
47
  end
48
48
 
@@ -84,16 +84,18 @@ class Fbe::Iterate
84
84
  # @param [Loog] loog The logging facility for debug output
85
85
  # @param [Judges::Options] options The options containing repository configuration
86
86
  # @param [Hash] global The hash for global caching of API responses
87
- def initialize(fb:, loog:, options:, global:)
87
+ def initialize(fb:, loog:, options:, global:, start:)
88
88
  @fb = fb
89
89
  @loog = loog
90
90
  @options = options
91
91
  @global = global
92
+ @start = start
92
93
  @label = nil
93
94
  @since = 0
94
95
  @query = nil
95
96
  @repeats = 1
96
- @quota_aware = false
97
+ @quota_aware = true
98
+ @lifetime_aware = true
97
99
  end
98
100
 
99
101
  # Makes the iterator aware of GitHub API quota limits.
@@ -106,8 +108,15 @@ class Fbe::Iterate
106
108
  # @example Enable quota awareness
107
109
  # iterator.quota_aware
108
110
  # iterator.over { |repo, item| ... } # Will stop if quota exhausted
109
- def quota_aware
110
- @quota_aware = true
111
+ def quota_unaware
112
+ @quota_aware = false
113
+ end
114
+
115
+ # Makes the iterator aware of lifetime limits.
116
+ #
117
+ # @return [nil] Nothing is returned
118
+ def lifetime_unaware
119
+ @lifetime_aware = false
111
120
  end
112
121
 
113
122
  # Sets the maximum number of iterations per repository.
@@ -188,7 +197,6 @@ class Fbe::Iterate
188
197
  # 4. If query returns a value: call the block with (repo_id, query_result)
189
198
  # 5. Store the block's return value as the new "latest" for next iteration
190
199
  #
191
- # @param [Float] timeout Maximum seconds to run (default: 120)
192
200
  # @yield [Integer, Object] Repository ID and the result from query execution
193
201
  # @yieldreturn [Integer] The value to store as "latest" for next iteration
194
202
  # @return [nil] Nothing is returned
@@ -198,7 +206,7 @@ class Fbe::Iterate
198
206
  # fetch_and_process_issue(repo_id, issue_number)
199
207
  # issue_number + 1 # Return next issue number to process
200
208
  # end
201
- def over(timeout: 2 * 60, &)
209
+ def over
202
210
  raise 'Use "as" first' if @label.nil?
203
211
  raise 'Use "by" first' if @query.nil?
204
212
  seen = {}
@@ -211,7 +219,7 @@ class Fbe::Iterate
211
219
  loog: @loog, options: @options, global: @global, quota_aware: @quota_aware
212
220
  ).map { |n| oct.repo_id_by_name(n) }
213
221
  restarted = []
214
- start = Time.now
222
+ started = Time.now
215
223
  before =
216
224
  repos.to_h do |repo|
217
225
  [
@@ -228,10 +236,10 @@ class Fbe::Iterate
228
236
  starts = before.dup
229
237
  loop do
230
238
  if @quota_aware && oct.off_quota?
231
- @loog.info("We are off GitHub quota, time to stop after #{start.ago}")
239
+ @loog.info("We are off GitHub quota, time to stop after #{started.ago}")
232
240
  break
233
241
  end
234
- if Time.now - start > timeout
242
+ if @lifetime_aware && @options.lifetime && Time.now - @start > @options.lifetime - 10
235
243
  @loog.info('We are over time, it is time to stop')
236
244
  break
237
245
  end
@@ -240,8 +248,8 @@ class Fbe::Iterate
240
248
  @loog.info("We are off GitHub quota, we must skip #{repo}")
241
249
  break
242
250
  end
243
- if Time.now - start > timeout
244
- @loog.info("We are doing this for #{start.ago} already, won't check #{repo}")
251
+ if @lifetime_aware && @options.lifetime && Time.now - @start > @options.lifetime - 10
252
+ @loog.info("We are working for #{started.ago} already, won't check repository ##{repo}")
245
253
  next
246
254
  end
247
255
  next if restarted.include?(repo)
@@ -266,11 +274,11 @@ class Fbe::Iterate
266
274
  seen[repo] += 1
267
275
  end
268
276
  unless seen.any? { |r, v| v < @repeats && !restarted.include?(r) }
269
- @loog.debug("No more repos to scan (out of #{repos.size}), quitting after #{start.ago}")
277
+ @loog.debug("No more repos to scan (out of #{repos.size}), quitting after #{started.ago}")
270
278
  break
271
279
  end
272
280
  if restarted.size == repos.size
273
- @loog.debug("All #{repos.size} repos restarted, quitting after #{start.ago}")
281
+ @loog.debug("All #{repos.size} repos restarted, quitting after #{started.ago}")
274
282
  break
275
283
  end
276
284
  end
@@ -284,6 +292,6 @@ class Fbe::Iterate
284
292
  end
285
293
  Fbe.overwrite(f, @label, before[repo], fb: @fb)
286
294
  end
287
- @loog.debug("Finished scanning #{repos.size} repos in #{start.ago}: #{seen.map { |k, v| "#{k}:#{v}" }.joined}")
295
+ @loog.debug("Finished scanning #{repos.size} repos in #{started.ago}: #{seen.map { |k, v| "#{k}:#{v}" }.joined}")
288
296
  end
289
297
  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.32.0' unless const_defined?(:VERSION)
13
+ VERSION = '0.33.0' unless const_defined?(:VERSION)
14
14
  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.32.0
4
+ version: 0.33.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko