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 +4 -4
- data/.github/workflows/typos.yml +1 -1
- data/Gemfile.lock +3 -3
- data/lib/fbe/iterate.rb +34 -1
- data/lib/fbe.rb +1 -1
- 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: bcdd3a7dc6452b707cd14157c1009b9b7a1f551f9ea66c5cc31c08849e87a2d3
|
4
|
+
data.tar.gz: 2d1b97f86162a5e853df3a19e8ba6c4f96f398c51c19aa5a2bab0ee036cba1b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8e6f7be8faebeaa3aa2ad93f809988ef7fba01265faa67da6bf0c292cf088f1a655305820b1a72570dcd2282a065a1f6570daa349c0ea26458beed96a3d0845
|
7
|
+
data.tar.gz: 4c2747bdf3bee54e7ecdf667db8d55f93323fc4448f1398753200b963404d5723e094f34064461787999456fa1316a551f470890dc7c6569310f28ccd8338c68
|
data/.github/workflows/typos.yml
CHANGED
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.
|
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.
|
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.
|
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 =
|
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