fbe 0.2.3 → 0.3.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/.rubocop.yml +1 -0
- data/Gemfile +6 -7
- data/Gemfile.lock +24 -105
- data/Rakefile +3 -11
- data/lib/fbe/award.rb +4 -1
- data/lib/fbe/conclude.rb +7 -5
- data/lib/fbe/copy.rb +1 -1
- data/lib/fbe/if_absent.rb +1 -1
- data/lib/fbe/issue.rb +1 -1
- data/lib/fbe/iterate.rb +14 -12
- data/lib/fbe/middleware/formatter.rb +1 -1
- data/lib/fbe/middleware/quota.rb +15 -0
- data/lib/fbe/overwrite.rb +2 -2
- data/lib/fbe/pmp.rb +7 -3
- data/lib/fbe/repeatedly.rb +1 -1
- data/lib/fbe/sec.rb +1 -1
- data/lib/fbe/unmask_repos.rb +2 -2
- data/lib/fbe/who.rb +1 -1
- data/lib/fbe.rb +1 -1
- data/test/fbe/test_enter.rb +4 -1
- data/test/test__helper.rb +14 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dff1d56c36768072e8e672002eefa283724df96d4db1e262ff145d34d1153dce
|
4
|
+
data.tar.gz: e1b28cf129ff6e857ada51074289433c4089dd017d63d95819cf05974e44018b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc6ac0aacf0bf3c3f75cc4634018724c7dd1a7704c67507893fd97a9ec76866a24a83bd4727b11cbdc2fbcc662bde1eda4ee45d0e17b0fbbda25df6c578161c1
|
7
|
+
data.tar.gz: 45671fe422b0ae541ce4782e7f012dcf5dfef257a67ab1f943f6b59c4d458753bd5809fa6972f207e6ae9c297cb98ae1821da2a52a47fb59b5e3eea5f99f0b03
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
@@ -6,17 +6,16 @@
|
|
6
6
|
source 'https://rubygems.org'
|
7
7
|
gemspec
|
8
8
|
|
9
|
-
gem 'minitest', '5.25
|
9
|
+
gem 'minitest', '~>5.25', require: false
|
10
10
|
gem 'minitest-reporters', '>=1.7', require: false
|
11
11
|
gem 'qbash', '>0', require: false
|
12
12
|
gem 'rake', '>=13', require: false
|
13
|
-
gem '
|
14
|
-
gem 'rubocop', '1.74.0', require: false
|
13
|
+
gem 'rubocop', '~>1.75', require: false
|
15
14
|
gem 'rubocop-minitest', '>0', require: false
|
16
15
|
gem 'rubocop-performance', '>0', require: false
|
17
16
|
gem 'rubocop-rake', '>0', require: false
|
18
17
|
gem 'rubocop-rspec', '>0', require: false
|
19
|
-
gem 'simplecov', '0.22
|
20
|
-
gem 'simplecov-cobertura', '2.1
|
21
|
-
gem 'webmock', '3.25
|
22
|
-
gem 'yard', '0.9
|
18
|
+
gem 'simplecov', '~>0.22', require: false
|
19
|
+
gem 'simplecov-cobertura', '~>2.1', require: false
|
20
|
+
gem 'webmock', '~>3.25', require: false
|
21
|
+
gem 'yard', '~>0.9', require: false
|
data/Gemfile.lock
CHANGED
@@ -22,22 +22,6 @@ PATH
|
|
22
22
|
GEM
|
23
23
|
remote: https://rubygems.org/
|
24
24
|
specs:
|
25
|
-
actionpack (8.0.2)
|
26
|
-
actionview (= 8.0.2)
|
27
|
-
activesupport (= 8.0.2)
|
28
|
-
nokogiri (>= 1.8.5)
|
29
|
-
rack (>= 2.2.4)
|
30
|
-
rack-session (>= 1.0.1)
|
31
|
-
rack-test (>= 0.6.3)
|
32
|
-
rails-dom-testing (~> 2.2)
|
33
|
-
rails-html-sanitizer (~> 1.6)
|
34
|
-
useragent (~> 0.16)
|
35
|
-
actionview (8.0.2)
|
36
|
-
activesupport (= 8.0.2)
|
37
|
-
builder (~> 3.1)
|
38
|
-
erubi (~> 1.11)
|
39
|
-
rails-dom-testing (~> 2.2)
|
40
|
-
rails-html-sanitizer (~> 1.6)
|
41
25
|
activesupport (8.0.2)
|
42
26
|
base64
|
43
27
|
benchmark (>= 0.3)
|
@@ -54,10 +38,10 @@ GEM
|
|
54
38
|
addressable (2.8.7)
|
55
39
|
public_suffix (>= 2.0.2, < 7.0)
|
56
40
|
ansi (1.5.0)
|
57
|
-
ast (2.4.
|
41
|
+
ast (2.4.3)
|
58
42
|
backtrace (0.4.0)
|
59
43
|
base64 (0.2.0)
|
60
|
-
baza.rb (0.0.
|
44
|
+
baza.rb (0.0.11)
|
61
45
|
backtrace (> 0)
|
62
46
|
elapsed (> 0)
|
63
47
|
faraday (> 0)
|
@@ -77,19 +61,15 @@ GEM
|
|
77
61
|
crack (1.0.0)
|
78
62
|
bigdecimal
|
79
63
|
rexml
|
80
|
-
crass (1.0.6)
|
81
|
-
date (3.4.1)
|
82
64
|
decoor (0.0.1)
|
83
|
-
diff-lcs (1.6.0)
|
84
65
|
docile (1.4.1)
|
85
66
|
drb (2.2.1)
|
86
67
|
elapsed (0.0.1)
|
87
68
|
loog (> 0)
|
88
69
|
tago (> 0)
|
89
|
-
erubi (1.13.1)
|
90
70
|
ethon (0.16.0)
|
91
71
|
ffi (>= 1.15.0)
|
92
|
-
factbase (0.9.
|
72
|
+
factbase (0.9.5)
|
93
73
|
backtrace (>= 0.4.0)
|
94
74
|
decoor (>= 0.0.1)
|
95
75
|
json (~> 2.7)
|
@@ -117,7 +97,7 @@ GEM
|
|
117
97
|
fiber-storage (1.0.0)
|
118
98
|
gli (2.22.2)
|
119
99
|
ostruct
|
120
|
-
graphql (2.4.
|
100
|
+
graphql (2.4.15)
|
121
101
|
base64
|
122
102
|
fiber-storage
|
123
103
|
logger
|
@@ -127,14 +107,9 @@ GEM
|
|
127
107
|
hashdiff (1.1.2)
|
128
108
|
i18n (1.14.7)
|
129
109
|
concurrent-ruby (~> 1.0)
|
130
|
-
io-console (0.8.0)
|
131
|
-
irb (1.15.1)
|
132
|
-
pp (>= 0.6.0)
|
133
|
-
rdoc (>= 4.0.0)
|
134
|
-
reline (>= 0.4.2)
|
135
110
|
iri (0.10.0)
|
136
111
|
json (2.10.2)
|
137
|
-
judges (0.
|
112
|
+
judges (0.38.1)
|
138
113
|
backtrace (~> 0)
|
139
114
|
baza.rb (~> 0)
|
140
115
|
concurrent-ruby (~> 1.2)
|
@@ -154,10 +129,7 @@ GEM
|
|
154
129
|
language_server-protocol (3.17.0.4)
|
155
130
|
lint_roller (1.1.0)
|
156
131
|
liquid (5.5.1)
|
157
|
-
logger (1.
|
158
|
-
loofah (2.24.0)
|
159
|
-
crass (~> 1.0.2)
|
160
|
-
nokogiri (>= 1.12.0)
|
132
|
+
logger (1.7.0)
|
161
133
|
loog (0.6.0)
|
162
134
|
minitest (5.25.5)
|
163
135
|
minitest-reporters (1.7.1)
|
@@ -169,13 +141,13 @@ GEM
|
|
169
141
|
multipart-post (2.4.1)
|
170
142
|
net-http (0.6.0)
|
171
143
|
uri
|
172
|
-
nokogiri (1.18.
|
144
|
+
nokogiri (1.18.6-arm64-darwin)
|
173
145
|
racc (~> 1.4)
|
174
|
-
nokogiri (1.18.
|
146
|
+
nokogiri (1.18.6-x64-mingw-ucrt)
|
175
147
|
racc (~> 1.4)
|
176
|
-
nokogiri (1.18.
|
148
|
+
nokogiri (1.18.6-x86_64-darwin)
|
177
149
|
racc (~> 1.4)
|
178
|
-
nokogiri (1.18.
|
150
|
+
nokogiri (1.18.6-x86_64-linux-gnu)
|
179
151
|
racc (~> 1.4)
|
180
152
|
obk (0.3.1)
|
181
153
|
octokit (9.2.0)
|
@@ -184,15 +156,10 @@ GEM
|
|
184
156
|
ostruct (0.6.1)
|
185
157
|
others (0.0.3)
|
186
158
|
parallel (1.26.3)
|
187
|
-
parser (3.3.7.
|
159
|
+
parser (3.3.7.3)
|
188
160
|
ast (~> 2.4.1)
|
189
161
|
racc
|
190
|
-
|
191
|
-
prettyprint
|
192
|
-
prettyprint (0.2.0)
|
193
|
-
psych (5.2.3)
|
194
|
-
date
|
195
|
-
stringio
|
162
|
+
prism (1.4.0)
|
196
163
|
public_suffix (6.0.1)
|
197
164
|
qbash (0.4.0)
|
198
165
|
backtrace (> 0)
|
@@ -200,56 +167,12 @@ GEM
|
|
200
167
|
loog (> 0)
|
201
168
|
tago (> 0)
|
202
169
|
racc (1.8.1)
|
203
|
-
rack (3.1.12)
|
204
|
-
rack-session (2.1.0)
|
205
|
-
base64 (>= 0.1.0)
|
206
|
-
rack (>= 3.0.0)
|
207
|
-
rack-test (2.2.0)
|
208
|
-
rack (>= 1.3)
|
209
|
-
rackup (2.2.1)
|
210
|
-
rack (>= 3)
|
211
|
-
rails-dom-testing (2.2.0)
|
212
|
-
activesupport (>= 5.0.0)
|
213
|
-
minitest
|
214
|
-
nokogiri (>= 1.6)
|
215
|
-
rails-html-sanitizer (1.6.2)
|
216
|
-
loofah (~> 2.21)
|
217
|
-
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
218
|
-
railties (8.0.2)
|
219
|
-
actionpack (= 8.0.2)
|
220
|
-
activesupport (= 8.0.2)
|
221
|
-
irb (~> 1.13)
|
222
|
-
rackup (>= 1.0.0)
|
223
|
-
rake (>= 12.2)
|
224
|
-
thor (~> 1.0, >= 1.2.2)
|
225
|
-
zeitwerk (~> 2.6)
|
226
170
|
rainbow (3.1.1)
|
227
171
|
rake (13.2.1)
|
228
|
-
rdoc (6.12.0)
|
229
|
-
psych (>= 4.0.0)
|
230
172
|
regexp_parser (2.10.0)
|
231
|
-
reline (0.6.0)
|
232
|
-
io-console (~> 0.5)
|
233
173
|
retries (0.0.5)
|
234
174
|
rexml (3.4.1)
|
235
|
-
|
236
|
-
rspec-support (~> 3.13.0)
|
237
|
-
rspec-expectations (3.13.3)
|
238
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
239
|
-
rspec-support (~> 3.13.0)
|
240
|
-
rspec-mocks (3.13.2)
|
241
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
242
|
-
rspec-support (~> 3.13.0)
|
243
|
-
rspec-rails (7.1.1)
|
244
|
-
actionpack (>= 7.0)
|
245
|
-
activesupport (>= 7.0)
|
246
|
-
railties (>= 7.0)
|
247
|
-
rspec-core (~> 3.13)
|
248
|
-
rspec-expectations (~> 3.13)
|
249
|
-
rspec-mocks (~> 3.13)
|
250
|
-
rspec-support (~> 3.13)
|
251
|
-
rspec-support (3.13.2)
|
252
|
-
rubocop (1.74.0)
|
175
|
+
rubocop (1.75.1)
|
253
176
|
json (~> 2.3)
|
254
177
|
language_server-protocol (~> 3.17.0.2)
|
255
178
|
lint_roller (~> 1.1.0)
|
@@ -257,11 +180,12 @@ GEM
|
|
257
180
|
parser (>= 3.3.0.2)
|
258
181
|
rainbow (>= 2.2.2, < 4.0)
|
259
182
|
regexp_parser (>= 2.9.3, < 3.0)
|
260
|
-
rubocop-ast (>= 1.
|
183
|
+
rubocop-ast (>= 1.43.0, < 2.0)
|
261
184
|
ruby-progressbar (~> 1.7)
|
262
185
|
unicode-display_width (>= 2.4.0, < 4.0)
|
263
|
-
rubocop-ast (1.
|
264
|
-
parser (>= 3.3.
|
186
|
+
rubocop-ast (1.43.0)
|
187
|
+
parser (>= 3.3.7.2)
|
188
|
+
prism (~> 1.4)
|
265
189
|
rubocop-minitest (0.37.1)
|
266
190
|
lint_roller (~> 1.1)
|
267
191
|
rubocop (>= 1.72.1, < 2.0)
|
@@ -290,9 +214,7 @@ GEM
|
|
290
214
|
simplecov (~> 0.19)
|
291
215
|
simplecov-html (0.13.1)
|
292
216
|
simplecov_json_formatter (0.1.4)
|
293
|
-
|
294
|
-
tago (0.0.2)
|
295
|
-
thor (1.3.2)
|
217
|
+
tago (0.1.0)
|
296
218
|
timeout (0.4.3)
|
297
219
|
total (0.4.1)
|
298
220
|
typhoeus (1.4.1)
|
@@ -303,7 +225,6 @@ GEM
|
|
303
225
|
unicode-emoji (~> 4.0, >= 4.0.4)
|
304
226
|
unicode-emoji (4.0.4)
|
305
227
|
uri (1.0.3)
|
306
|
-
useragent (0.16.11)
|
307
228
|
verbose (0.0.2)
|
308
229
|
loog (~> 0.2)
|
309
230
|
tago (~> 0.0)
|
@@ -313,7 +234,6 @@ GEM
|
|
313
234
|
hashdiff (>= 0.4.0, < 2.0.0)
|
314
235
|
yaml (0.4.0)
|
315
236
|
yard (0.9.37)
|
316
|
-
zeitwerk (2.7.2)
|
317
237
|
|
318
238
|
PLATFORMS
|
319
239
|
arm64-darwin-22
|
@@ -326,20 +246,19 @@ PLATFORMS
|
|
326
246
|
|
327
247
|
DEPENDENCIES
|
328
248
|
fbe!
|
329
|
-
minitest (
|
249
|
+
minitest (~> 5.25)
|
330
250
|
minitest-reporters (>= 1.7)
|
331
251
|
qbash (> 0)
|
332
252
|
rake (>= 13)
|
333
|
-
|
334
|
-
rubocop (= 1.74.0)
|
253
|
+
rubocop (~> 1.75)
|
335
254
|
rubocop-minitest (> 0)
|
336
255
|
rubocop-performance (> 0)
|
337
256
|
rubocop-rake (> 0)
|
338
257
|
rubocop-rspec (> 0)
|
339
|
-
simplecov (
|
340
|
-
simplecov-cobertura (
|
341
|
-
webmock (
|
342
|
-
yard (
|
258
|
+
simplecov (~> 0.22)
|
259
|
+
simplecov-cobertura (~> 2.1)
|
260
|
+
webmock (~> 3.25)
|
261
|
+
yard (~> 0.9)
|
343
262
|
|
344
263
|
BUNDLED WITH
|
345
264
|
2.5.16
|
data/Rakefile
CHANGED
@@ -18,7 +18,7 @@ end
|
|
18
18
|
|
19
19
|
ENV['RACK_ENV'] = 'test'
|
20
20
|
|
21
|
-
task default: %i[clean test picks
|
21
|
+
task default: %i[clean test picks rubocop yard]
|
22
22
|
|
23
23
|
require 'rake/testtask'
|
24
24
|
desc 'Run all unit tests'
|
@@ -32,15 +32,8 @@ end
|
|
32
32
|
|
33
33
|
desc 'Run them via Ruby, one by one'
|
34
34
|
task :picks do
|
35
|
-
Dir['test/**/*.rb'].each do |f|
|
36
|
-
qbash("bundle exec ruby #{Shellwords.escape(f)}", log: $stdout)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
desc 'Require them via Ruby, one by one'
|
41
|
-
task :reqs do
|
42
|
-
Dir['lib/**/*.rb'].each do |f|
|
43
|
-
qbash("bundle exec ruby #{Shellwords.escape(f)}", log: $stdout)
|
35
|
+
(Dir['test/**/*.rb'] + Dir['lib/**/*.rb']).each do |f|
|
36
|
+
qbash("bundle exec ruby #{Shellwords.escape(f)}", log: $stdout, env: { 'RACK_ENV' => 'picks' })
|
44
37
|
end
|
45
38
|
end
|
46
39
|
|
@@ -54,5 +47,4 @@ require 'rubocop/rake_task'
|
|
54
47
|
desc 'Run RuboCop on all directories'
|
55
48
|
RuboCop::RakeTask.new(:rubocop) do |task|
|
56
49
|
task.fail_on_error = true
|
57
|
-
task.requires << 'rubocop-rspec'
|
58
50
|
end
|
data/lib/fbe/award.rb
CHANGED
@@ -30,8 +30,11 @@ require_relative 'fb'
|
|
30
30
|
# License:: MIT
|
31
31
|
class Fbe::Award
|
32
32
|
# Ctor.
|
33
|
-
# @param [String] query The query with the bylaw
|
33
|
+
# @param [String, nil] query The query with the bylaw
|
34
34
|
# @param [String] judge The name of the judge
|
35
|
+
# @param [Hash] global The hash for global caching
|
36
|
+
# @param [Judges::Options] options The options coming from the +judges+ tool
|
37
|
+
# @param [Loog] loog The logging facility
|
35
38
|
def initialize(query = nil, judge: $judge, global: $global, options: $options, loog: $loog)
|
36
39
|
query = Fbe.pmp(fb: Fbe.fb, global:, options:, loog:).hr.send(judge.tr('-', '_')) if query.nil?
|
37
40
|
@query = query
|
data/lib/fbe/conclude.rb
CHANGED
@@ -65,17 +65,19 @@ class Fbe::Conclude
|
|
65
65
|
|
66
66
|
# Make this block aware of GitHub API quota.
|
67
67
|
#
|
68
|
-
# When the quota is reached, the loop will gracefully stop
|
68
|
+
# When the quota is reached, the loop will gracefully stop to avoid
|
69
|
+
# hitting GitHub API rate limits. This helps prevent interruptions
|
70
|
+
# in long-running operations.
|
69
71
|
#
|
70
|
-
# @return [nil] Nothing
|
72
|
+
# @return [nil] Nothing is returned
|
71
73
|
def quota_aware
|
72
74
|
@quota_aware = true
|
73
75
|
end
|
74
76
|
|
75
77
|
# Set the query that should find the facts in the factbase.
|
76
78
|
#
|
77
|
-
# @param [String] query The query
|
78
|
-
# @return [nil] Nothing
|
79
|
+
# @param [String] query The query to execute
|
80
|
+
# @return [nil] Nothing is returned
|
79
81
|
def on(query)
|
80
82
|
raise 'Query is already set' unless @query.nil?
|
81
83
|
@query = query
|
@@ -83,7 +85,7 @@ class Fbe::Conclude
|
|
83
85
|
|
84
86
|
# Set the list of properties to copy from the facts found to new facts.
|
85
87
|
#
|
86
|
-
# @param [
|
88
|
+
# @param [Array<String>] props List of property names
|
87
89
|
# @return [nil] Nothing
|
88
90
|
def follow(props)
|
89
91
|
@follows = props.strip.split.compact
|
data/lib/fbe/copy.rb
CHANGED
@@ -12,7 +12,7 @@ require_relative 'fb'
|
|
12
12
|
# listed in the +except+.
|
13
13
|
#
|
14
14
|
# @param [Factbase::Fact] source The source
|
15
|
-
# @param [Factbase::Fact] target The
|
15
|
+
# @param [Factbase::Fact] target The target
|
16
16
|
# @param [Array<String>] except List of properties to NOT copy
|
17
17
|
# @return [Integer] How many properties were copied
|
18
18
|
def Fbe.copy(source, target, except: [])
|
data/lib/fbe/if_absent.rb
CHANGED
@@ -8,7 +8,7 @@ require 'time'
|
|
8
8
|
require_relative '../fbe'
|
9
9
|
require_relative 'fb'
|
10
10
|
|
11
|
-
# Injects a fact if it's absent in the factbase, otherwise (it is already
|
11
|
+
# Injects a fact if it's absent in the factbase, otherwise (if it is already
|
12
12
|
# there) returns NIL.
|
13
13
|
#
|
14
14
|
# Here is what you do when you want to add a fact to the factbase, but
|
data/lib/fbe/issue.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
require_relative '../fbe'
|
7
7
|
require_relative 'octo'
|
8
8
|
|
9
|
-
# Converts an ID of GitHub issue into a nicely
|
9
|
+
# Converts an ID of GitHub issue into a nicely formatted string.
|
10
10
|
#
|
11
11
|
# The function takes the +repository+ property of the provided +fact+,
|
12
12
|
# goes to the GitHub API in order to find the full name of the repository,
|
data/lib/fbe/iterate.rb
CHANGED
@@ -54,17 +54,19 @@ class Fbe::Iterate
|
|
54
54
|
|
55
55
|
# Make this block aware of GitHub API quota.
|
56
56
|
#
|
57
|
-
# When the quota is reached, the loop will gracefully stop
|
57
|
+
# When the quota is reached, the loop will gracefully stop to avoid
|
58
|
+
# hitting GitHub API rate limits. This helps prevent interruptions
|
59
|
+
# in long-running operations.
|
58
60
|
#
|
59
|
-
# @return [nil] Nothing
|
61
|
+
# @return [nil] Nothing is returned
|
60
62
|
def quota_aware
|
61
63
|
@quota_aware = true
|
62
64
|
end
|
63
65
|
|
64
66
|
# Sets the total counter of repeats to make.
|
65
67
|
#
|
66
|
-
# @param [Integer] repeats The total count of
|
67
|
-
# @return [nil] Nothing
|
68
|
+
# @param [Integer] repeats The total count of repeats to execute
|
69
|
+
# @return [nil] Nothing is returned
|
68
70
|
def repeats(repeats)
|
69
71
|
raise 'Cannot set "repeats" to nil' if repeats.nil?
|
70
72
|
raise 'The "repeats" must be a positive integer' unless repeats.positive?
|
@@ -73,8 +75,8 @@ class Fbe::Iterate
|
|
73
75
|
|
74
76
|
# Sets the query to run.
|
75
77
|
#
|
76
|
-
# @param [String] query The query
|
77
|
-
# @return [nil] Nothing
|
78
|
+
# @param [String] query The query to execute
|
79
|
+
# @return [nil] Nothing is returned
|
78
80
|
def by(query)
|
79
81
|
raise 'Query is already set' unless @query.nil?
|
80
82
|
raise 'Cannot set query to nil' if query.nil?
|
@@ -83,8 +85,8 @@ class Fbe::Iterate
|
|
83
85
|
|
84
86
|
# Sets the label to use in the "marker" fact.
|
85
87
|
#
|
86
|
-
# @param [String] label The label
|
87
|
-
# @return [nil] Nothing
|
88
|
+
# @param [String] label The label identifier
|
89
|
+
# @return [nil] Nothing is returned
|
88
90
|
def as(label)
|
89
91
|
raise 'Label is already set' unless @label.nil?
|
90
92
|
raise 'Cannot set "label" to nil' if label.nil?
|
@@ -94,12 +96,12 @@ class Fbe::Iterate
|
|
94
96
|
# It makes a number of repeats of going through all repositories
|
95
97
|
# provided by the +repositories+ configuration option. In each "repeat"
|
96
98
|
# it yields the repository ID and a number that is retrieved by the
|
97
|
-
# +query+. The query is supplied with two
|
98
|
-
# +$before+ the value from the previous repeat and +$repository+ (GitHub repo ID).
|
99
|
+
# +query+. The query is supplied with two parameters:
|
100
|
+
# +$before+ (the value from the previous repeat) and +$repository+ (GitHub repo ID).
|
99
101
|
#
|
100
102
|
# @param [Float] timeout How many seconds to spend as a maximum
|
101
|
-
# @yield [
|
102
|
-
# @return [nil] Nothing
|
103
|
+
# @yield [Integer, Integer] Repository ID and the next number to be considered
|
104
|
+
# @return [nil] Nothing is returned
|
103
105
|
def over(timeout: 2 * 60, &)
|
104
106
|
raise 'Use "as" first' if @label.nil?
|
105
107
|
raise 'Use "by" first' if @query.nil?
|
@@ -8,7 +8,7 @@ require 'faraday/logging/formatter'
|
|
8
8
|
require_relative '../../fbe'
|
9
9
|
require_relative '../../fbe/middleware'
|
10
10
|
|
11
|
-
# Faraday logging formatter
|
11
|
+
# Faraday logging formatter shows verbose logs for error responses only
|
12
12
|
#
|
13
13
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
14
14
|
# Copyright:: Copyright (c) 2024-2025 Zerocracy
|
data/lib/fbe/middleware/quota.rb
CHANGED
@@ -12,6 +12,13 @@ require_relative '../middleware'
|
|
12
12
|
# Copyright:: Copyright (c) 2024-2025 Zerocracy
|
13
13
|
# License:: MIT
|
14
14
|
class Fbe::Middleware::Quota < Faraday::Middleware
|
15
|
+
# Constructor.
|
16
|
+
#
|
17
|
+
# @param [Object] app The Faraday app
|
18
|
+
# @param [Loog] loog The logging facility
|
19
|
+
# @param [Integer] pause Seconds to pause when rate limit is reached
|
20
|
+
# @param [Integer] limit Maximum number of requests before checking rate limit
|
21
|
+
# @param [Integer] rate Minimum remaining requests threshold
|
15
22
|
def initialize(app, loog: Loog::NULL, pause: 60, limit: 100, rate: 5)
|
16
23
|
super(app)
|
17
24
|
@requests = 0
|
@@ -29,6 +36,10 @@ class Fbe::Middleware::Quota < Faraday::Middleware
|
|
29
36
|
@rate = rate
|
30
37
|
end
|
31
38
|
|
39
|
+
# Process the request and handle rate limiting.
|
40
|
+
#
|
41
|
+
# @param [Faraday::Env] env The environment
|
42
|
+
# @return [Faraday::Response] The response
|
32
43
|
def call(env)
|
33
44
|
@requests += 1
|
34
45
|
response = @app.call(env)
|
@@ -42,6 +53,10 @@ class Fbe::Middleware::Quota < Faraday::Middleware
|
|
42
53
|
|
43
54
|
private
|
44
55
|
|
56
|
+
# Check if we're approaching the rate limit.
|
57
|
+
#
|
58
|
+
# @param [Faraday::Env] env The environment
|
59
|
+
# @return [Boolean] True if we should pause to avoid hitting rate limits
|
45
60
|
def out_of_limit?(env)
|
46
61
|
remaining = env.response_headers['x-ratelimit-remaining'].to_i
|
47
62
|
(@requests % @limit).zero? && remaining < @rate
|
data/lib/fbe/overwrite.rb
CHANGED
@@ -9,8 +9,8 @@ require_relative 'fb'
|
|
9
9
|
# Overwrites a property in the fact.
|
10
10
|
#
|
11
11
|
# If the property doesn't exist in the fact, it will be added. If it does
|
12
|
-
# exist, it will be re-set (the entire fact will be destroyed, new fact
|
13
|
-
# created, and property set with the new value).
|
12
|
+
# exist, it will be re-set (the entire fact will be destroyed, a new fact
|
13
|
+
# created, and the property set with the new value).
|
14
14
|
#
|
15
15
|
# It is important that the fact has the +_id+ property. If it doesn't,
|
16
16
|
# an exception will be raised.
|
data/lib/fbe/pmp.rb
CHANGED
@@ -9,11 +9,15 @@ require_relative 'fb'
|
|
9
9
|
|
10
10
|
# Takes configuration parameter from the "PMP" fact.
|
11
11
|
#
|
12
|
-
# The factbase may have a few facts with the +what+ set to +pmp+ (stands for
|
13
|
-
# "project management plan"). These facts contain information that
|
12
|
+
# The factbase may have a few facts with the +what+ set to +pmp+ (stands for the
|
13
|
+
# "project management plan"). These facts contain information that configures
|
14
14
|
# the project. It is expected that every fact with the +what+ set to +pmp+ also
|
15
15
|
# contains the +area+ property, which is set to one of nine values: +scope+,
|
16
|
-
# +time+, +cost+, etc. (
|
16
|
+
# +time+, +cost+, etc. (the nine process areas in the PMBOK).
|
17
|
+
#
|
18
|
+
# If a proper pmp fact is not found or the property is absent in the fact,
|
19
|
+
# this method throws an exception. The factbase must contain PMP-related facts.
|
20
|
+
# Most probably, a special judge must fill it up with such a fact.
|
17
21
|
#
|
18
22
|
# @param [Factbase] fb The factbase
|
19
23
|
# @param [Hash] global The hash for global caching
|
data/lib/fbe/repeatedly.rb
CHANGED
@@ -23,7 +23,7 @@ def Fbe.repeatedly(area, p_every_hours, fb: Fbe.fb, judge: $judge, loog: $loog,
|
|
23
23
|
(eq what '#{judge}')
|
24
24
|
(gt when (minus (to_time (env 'TODAY' '#{Time.now.utc.iso8601}')) '#{hours} hours')))"
|
25
25
|
).each.to_a.empty?
|
26
|
-
loog.debug("#{$judge}
|
26
|
+
loog.debug("#{$judge} has recently been executed, skipping now")
|
27
27
|
return
|
28
28
|
end
|
29
29
|
f = fb.query("(and (eq what '#{judge}'))").each.to_a.first
|
data/lib/fbe/sec.rb
CHANGED
@@ -7,7 +7,7 @@ require_relative '../fbe'
|
|
7
7
|
|
8
8
|
# Converts number of seconds into text.
|
9
9
|
#
|
10
|
-
#
|
10
|
+
# The number of seconds is taken from the +fact+ provided, usually stored
|
11
11
|
# there in the +seconds+ property. The seconds are formatted to hours,
|
12
12
|
# days, or weeks.
|
13
13
|
#
|
data/lib/fbe/unmask_repos.rb
CHANGED
@@ -23,9 +23,9 @@ end
|
|
23
23
|
# Builds a list of repositories required by the +repositories+ option.
|
24
24
|
#
|
25
25
|
# The +repositories+ option defined in the +$options+ must contain something
|
26
|
-
# like "zerocracy/fbe,zerocracy/ab*" (comma-separated list of masks). This
|
26
|
+
# like "zerocracy/fbe,zerocracy/ab*" (a comma-separated list of masks). This
|
27
27
|
# function will go to the GitHub API and fetch all available repositories
|
28
|
-
#
|
28
|
+
# matching these masks.
|
29
29
|
#
|
30
30
|
# @param [Judges::Options] options The options coming from the +judges+ tool
|
31
31
|
# @param [Hash] global The hash for global caching
|
data/lib/fbe/who.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
require_relative '../fbe'
|
7
7
|
require_relative 'octo'
|
8
8
|
|
9
|
-
# Converts an ID of GitHub user into a nicely
|
9
|
+
# Converts an ID of GitHub user into a nicely formatted string with their name.
|
10
10
|
#
|
11
11
|
# The ID of the user (integer) is expected to be stored in the +who+ property of the
|
12
12
|
# provided +fact+. This function makes a live request to GitHub API in order
|
data/lib/fbe.rb
CHANGED
data/test/fbe/test_enter.rb
CHANGED
@@ -17,9 +17,12 @@ class TestEnter < Minitest::Test
|
|
17
17
|
def test_simple
|
18
18
|
WebMock.disable_net_connect!
|
19
19
|
options = Judges::Options.new({ 'zerocracy_token' => '00000-0000-0000-00000' })
|
20
|
+
stub_request(:get, 'https://api.zerocracy.com/csrf')
|
21
|
+
.to_return(body: 'token')
|
20
22
|
stub_request(:get, 'https://api.zerocracy.com/valves/result?badge=foo')
|
21
23
|
.to_return(status: 204)
|
22
|
-
stub_request(:post, 'https://api.zerocracy.com/valves/add?
|
24
|
+
stub_request(:post, 'https://api.zerocracy.com/valves/add?job=0')
|
25
|
+
.with(body: '_csrf=token&badge=foo&name&result=hi&why=no%20reason')
|
23
26
|
.to_return(status: 302)
|
24
27
|
assert_equal('hi', Fbe.enter('foo', 'no reason', options:, loog: Loog::NULL) { 'hi' })
|
25
28
|
end
|
data/test/test__helper.rb
CHANGED
@@ -8,10 +8,19 @@ $stdout.sync = true
|
|
8
8
|
require 'minitest/reporters'
|
9
9
|
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
SimpleCov
|
11
|
+
if ENV['RACK_ENV'] == 'test'
|
12
|
+
require 'simplecov'
|
13
|
+
require 'simplecov-cobertura'
|
14
|
+
SimpleCov.formatters = [
|
15
|
+
SimpleCov::Formatter::HTMLFormatter,
|
16
|
+
SimpleCov::Formatter::CoberturaFormatter
|
17
|
+
]
|
18
|
+
SimpleCov.start do
|
19
|
+
enable_coverage :branch
|
20
|
+
track_files 'lib/**/*.rb'
|
21
|
+
add_filter '/test/'
|
22
|
+
add_filter '/vendor/'
|
23
|
+
end
|
24
|
+
end
|
16
25
|
|
17
26
|
require 'minitest/autorun'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fbe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-29 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: backtrace
|