fbe 0.38.2 → 0.39.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: 84ae98aaec66eaacc0865c0be05fc5490305a5e723c402c66eabc65d9d5490f2
4
- data.tar.gz: 4d3922a6dbfd4b04d8ac2eda2a155fda33ddc3e2c71886c0b99d61558830ff26
3
+ metadata.gz: bcdd3a7dc6452b707cd14157c1009b9b7a1f551f9ea66c5cc31c08849e87a2d3
4
+ data.tar.gz: 2d1b97f86162a5e853df3a19e8ba6c4f96f398c51c19aa5a2bab0ee036cba1b4
5
5
  SHA512:
6
- metadata.gz: 15d6d7d1b03ebe56d06fef55c9981ccd6a97c5c072bbf54a81e87c9841323659af82124b6e968e2a4d9d1495672830249c8b66a7273f8411b56a7d6b85f9b0a5
7
- data.tar.gz: 79b5bd15396e2bed6317b1f202cd07f302c8a0db674165fafa1796da2119c0e22e2d218211106f4d6438b1aaa7012f1f102f80f59250908481876a00ebc6b956
6
+ metadata.gz: a8e6f7be8faebeaa3aa2ad93f809988ef7fba01265faa67da6bf0c292cf088f1a655305820b1a72570dcd2282a065a1f6570daa349c0ea26458beed96a3d0845
7
+ data.tar.gz: 4c2747bdf3bee54e7ecdf667db8d55f93323fc4448f1398753200b963404d5723e094f34064461787999456fa1316a551f470890dc7c6569310f28ccd8338c68
@@ -16,6 +16,6 @@ jobs:
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
18
  - uses: actions/checkout@v5
19
- - uses: crate-ci/typos@v1.36.2
19
+ - uses: crate-ci/typos@v1.36.3
20
20
  with:
21
21
  config: .github/.typos.toml
data/Gemfile.lock CHANGED
@@ -87,7 +87,7 @@ GEM
87
87
  others (~> 0.1)
88
88
  tago (~> 0.1)
89
89
  yaml (~> 0.3)
90
- faraday (2.13.4)
90
+ faraday (2.14.0)
91
91
  faraday-net_http (>= 2.0, < 3.5)
92
92
  json
93
93
  logger
@@ -189,7 +189,7 @@ GEM
189
189
  regexp_parser (2.11.3)
190
190
  retries (0.0.5)
191
191
  rexml (3.4.4)
192
- rubocop (1.80.2)
192
+ rubocop (1.81.1)
193
193
  json (~> 2.3)
194
194
  language_server-protocol (~> 3.17.0.2)
195
195
  lint_roller (~> 1.1.0)
@@ -197,7 +197,7 @@ GEM
197
197
  parser (>= 3.3.0.2)
198
198
  rainbow (>= 2.2.2, < 4.0)
199
199
  regexp_parser (>= 2.9.3, < 3.0)
200
- rubocop-ast (>= 1.46.0, < 2.0)
200
+ rubocop-ast (>= 1.47.1, < 2.0)
201
201
  ruby-progressbar (~> 1.7)
202
202
  unicode-display_width (>= 2.4.0, < 4.0)
203
203
  rubocop-ast (1.47.1)
data/lib/fbe/iterate.rb CHANGED
@@ -97,6 +97,7 @@ class Fbe::Iterate
97
97
  @label = nil
98
98
  @since = 0
99
99
  @query = nil
100
+ @sort_by = nil
100
101
  @repeats = 1
101
102
  @quota_aware = true
102
103
  @lifetime_aware = true
@@ -164,6 +165,24 @@ class Fbe::Iterate
164
165
  @query = query
165
166
  end
166
167
 
168
+ # Sets the field to sort results by in ascending order.
169
+ #
170
+ # When set, all matching results will be fetched, sorted by the specified
171
+ # field, and iterated in order. This executes the query once per repository
172
+ # instead of calling one() repeatedly.
173
+ #
174
+ # @param [String] prop The fact attribute to sort by
175
+ # @return [nil] Nothing is returned
176
+ # @raise [RuntimeError] If prop is nil, already set, or not a valid field name
177
+ # @example Sort issues by number
178
+ # iterator.sort_by('issue')
179
+ def sort_by(prop)
180
+ raise 'Sort field is already set' unless @sort_by.nil?
181
+ raise 'Cannot set sort field to nil' if prop.nil?
182
+ raise 'Sort field must be a String' unless prop.is_a?(String)
183
+ @sort_by = prop
184
+ end
185
+
167
186
  # Sets the label for tracking iteration state.
168
187
  #
169
188
  # The label is used to create marker facts in the factbase that track
@@ -245,6 +264,7 @@ class Fbe::Iterate
245
264
  ]
246
265
  end
247
266
  starts = before.dup
267
+ values = {}
248
268
  loop do
249
269
  if @quota_aware && oct.off_quota?
250
270
  @loog.info("We are off GitHub quota, time to stop after #{started.ago}")
@@ -277,11 +297,24 @@ class Fbe::Iterate
277
297
  @loog.debug("We've seen too many (#{seen[repo]}) in #{repo}, let's see next one")
278
298
  next
279
299
  end
280
- nxt = @fb.query(@query).one(@fb, before: before[repo], repository: repo)
300
+ nxt =
301
+ if @sort_by
302
+ values[repo] ||= @fb.query(@query).each(
303
+ @fb, before: before[repo], repository: repo
304
+ ).map { _1[@sort_by]&.first }.compact.sort.each
305
+ begin
306
+ values[repo].next
307
+ rescue StopIteration
308
+ nil
309
+ end
310
+ else
311
+ @fb.query(@query).one(@fb, before: before[repo], repository: repo)
312
+ end
281
313
  before[repo] =
282
314
  if nxt.nil?
283
315
  @loog.debug("Next element after ##{before[repo]} not suggested, re-starting from ##{@since}: #{@query}")
284
316
  restarted << repo
317
+ values.delete(repo) if @sort_by
285
318
  @since
286
319
  else
287
320
  @loog.debug("Next is ##{nxt}, starting from it")
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.38.2' unless const_defined?(:VERSION)
13
+ VERSION = '0.39.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.38.2
4
+ version: 0.39.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko