fbe 0.0.1
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 +7 -0
- data/.0pdd.yml +25 -0
- data/.gitattributes +7 -0
- data/.github/workflows/actionlint.yml +41 -0
- data/.github/workflows/codecov.yml +39 -0
- data/.github/workflows/copyrights.yml +30 -0
- data/.github/workflows/markdown-lint.yml +38 -0
- data/.github/workflows/pdd.yml +34 -0
- data/.github/workflows/rake.yml +44 -0
- data/.github/workflows/xcop.yml +30 -0
- data/.github/workflows/yamllint.yml +36 -0
- data/.gitignore +8 -0
- data/.pdd +7 -0
- data/.rubocop.yml +60 -0
- data/.rultor.yml +42 -0
- data/.simplecov +41 -0
- data/.yamllint.yml +24 -0
- data/Gemfile +34 -0
- data/Gemfile.lock +264 -0
- data/LICENSE.txt +21 -0
- data/README.md +30 -0
- data/Rakefile +66 -0
- data/fbe.gemspec +59 -0
- data/lib/fbe/conclude.rb +117 -0
- data/lib/fbe/fb.rb +45 -0
- data/lib/fbe/if_absent.rb +55 -0
- data/lib/fbe/iterate.rb +103 -0
- data/lib/fbe/octo.rb +260 -0
- data/lib/fbe/unmask_repos.rb +58 -0
- data/lib/fbe.rb +31 -0
- data/renovate.json +6 -0
- data/rules/basic.fe +158 -0
- data/test/fbe/test_conclude.rb +89 -0
- data/test/fbe/test_fb.rb +43 -0
- data/test/fbe/test_if_absent.rb +104 -0
- data/test/fbe/test_iterate.rb +53 -0
- data/test/fbe/test_octo.rb +46 -0
- data/test/fbe/test_unmask_repos.rb +57 -0
- data/test/test__helper.rb +31 -0
- data/test/test_fbe.rb +34 -0
- metadata +324 -0
data/Gemfile.lock
ADDED
@@ -0,0 +1,264 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fbe (0.0.0)
|
5
|
+
backtrace (~> 0.3)
|
6
|
+
decoor (~> 0.0)
|
7
|
+
factbase (~> 0.0)
|
8
|
+
faraday (= 2.9.1)
|
9
|
+
faraday-http-cache (= 2.5.1)
|
10
|
+
faraday-multipart (= 1.0.4)
|
11
|
+
faraday-retry (= 2.2.1)
|
12
|
+
json (~> 2.7)
|
13
|
+
judges (~> 0.0)
|
14
|
+
loog (~> 0.2)
|
15
|
+
nokogiri (~> 1.10)
|
16
|
+
obk (~> 0.0)
|
17
|
+
octokit (~> 9.1.0)
|
18
|
+
others (~> 0.0)
|
19
|
+
tago (~> 0.0)
|
20
|
+
verbose (~> 0.0)
|
21
|
+
yaml (~> 0.3)
|
22
|
+
|
23
|
+
GEM
|
24
|
+
remote: https://rubygems.org/
|
25
|
+
specs:
|
26
|
+
actionpack (7.1.3.4)
|
27
|
+
actionview (= 7.1.3.4)
|
28
|
+
activesupport (= 7.1.3.4)
|
29
|
+
nokogiri (>= 1.8.5)
|
30
|
+
racc
|
31
|
+
rack (>= 2.2.4)
|
32
|
+
rack-session (>= 1.0.1)
|
33
|
+
rack-test (>= 0.6.3)
|
34
|
+
rails-dom-testing (~> 2.2)
|
35
|
+
rails-html-sanitizer (~> 1.6)
|
36
|
+
actionview (7.1.3.4)
|
37
|
+
activesupport (= 7.1.3.4)
|
38
|
+
builder (~> 3.1)
|
39
|
+
erubi (~> 1.11)
|
40
|
+
rails-dom-testing (~> 2.2)
|
41
|
+
rails-html-sanitizer (~> 1.6)
|
42
|
+
activesupport (7.1.3.4)
|
43
|
+
base64
|
44
|
+
bigdecimal
|
45
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
46
|
+
connection_pool (>= 2.2.5)
|
47
|
+
drb
|
48
|
+
i18n (>= 1.6, < 2)
|
49
|
+
minitest (>= 5.1)
|
50
|
+
mutex_m
|
51
|
+
tzinfo (~> 2.0)
|
52
|
+
addressable (2.8.7)
|
53
|
+
public_suffix (>= 2.0.2, < 7.0)
|
54
|
+
ast (2.4.2)
|
55
|
+
backtrace (0.4.0)
|
56
|
+
base64 (0.2.0)
|
57
|
+
bigdecimal (3.1.8)
|
58
|
+
builder (3.3.0)
|
59
|
+
concurrent-ruby (1.3.3)
|
60
|
+
connection_pool (2.4.1)
|
61
|
+
crass (1.0.6)
|
62
|
+
decoor (0.0.1)
|
63
|
+
diff-lcs (1.5.1)
|
64
|
+
docile (1.4.0)
|
65
|
+
drb (2.2.1)
|
66
|
+
erubi (1.13.0)
|
67
|
+
ethon (0.16.0)
|
68
|
+
ffi (>= 1.15.0)
|
69
|
+
factbase (0.0.54)
|
70
|
+
backtrace (~> 0.3)
|
71
|
+
decoor (~> 0.0)
|
72
|
+
json (~> 2.7)
|
73
|
+
loog (~> 0.2)
|
74
|
+
nokogiri (~> 1.10)
|
75
|
+
others (~> 0.0)
|
76
|
+
tago (~> 0.0)
|
77
|
+
yaml (~> 0.3)
|
78
|
+
faraday (2.9.1)
|
79
|
+
faraday-net_http (>= 2.0, < 3.2)
|
80
|
+
faraday-http-cache (2.5.1)
|
81
|
+
faraday (>= 0.8)
|
82
|
+
faraday-multipart (1.0.4)
|
83
|
+
multipart-post (~> 2)
|
84
|
+
faraday-net_http (3.1.0)
|
85
|
+
net-http
|
86
|
+
faraday-retry (2.2.1)
|
87
|
+
faraday (~> 2.0)
|
88
|
+
ffi (1.17.0-arm64-darwin)
|
89
|
+
ffi (1.17.0-x64-mingw-ucrt)
|
90
|
+
ffi (1.17.0-x86_64-darwin)
|
91
|
+
ffi (1.17.0-x86_64-linux-gnu)
|
92
|
+
gli (2.21.1)
|
93
|
+
i18n (1.14.5)
|
94
|
+
concurrent-ruby (~> 1.0)
|
95
|
+
io-console (0.7.2)
|
96
|
+
irb (1.13.2)
|
97
|
+
rdoc (>= 4.0.0)
|
98
|
+
reline (>= 0.4.2)
|
99
|
+
iri (0.8.0)
|
100
|
+
json (2.7.2)
|
101
|
+
judges (0.13.0)
|
102
|
+
backtrace (~> 0.3)
|
103
|
+
concurrent-ruby (~> 1.2)
|
104
|
+
factbase (~> 0.0)
|
105
|
+
gli (~> 2.21)
|
106
|
+
iri (~> 0.8)
|
107
|
+
loog (~> 0.2)
|
108
|
+
moments (~> 0.3)
|
109
|
+
nokogiri (~> 1.10)
|
110
|
+
others (~> 0.0)
|
111
|
+
retries (~> 0.0)
|
112
|
+
tago (~> 0.0)
|
113
|
+
typhoeus (~> 1.3)
|
114
|
+
language_server-protocol (3.17.0.3)
|
115
|
+
loofah (2.22.0)
|
116
|
+
crass (~> 1.0.2)
|
117
|
+
nokogiri (>= 1.12.0)
|
118
|
+
loog (0.5.1)
|
119
|
+
minitest (5.24.0)
|
120
|
+
moments (0.3.0)
|
121
|
+
multipart-post (2.4.1)
|
122
|
+
mutex_m (0.2.0)
|
123
|
+
net-http (0.4.1)
|
124
|
+
uri
|
125
|
+
nokogiri (1.16.6-arm64-darwin)
|
126
|
+
racc (~> 1.4)
|
127
|
+
nokogiri (1.16.6-x64-mingw-ucrt)
|
128
|
+
racc (~> 1.4)
|
129
|
+
nokogiri (1.16.6-x86_64-darwin)
|
130
|
+
racc (~> 1.4)
|
131
|
+
nokogiri (1.16.6-x86_64-linux)
|
132
|
+
racc (~> 1.4)
|
133
|
+
obk (0.3.1)
|
134
|
+
octokit (9.1.0)
|
135
|
+
faraday (>= 1, < 3)
|
136
|
+
sawyer (~> 0.9)
|
137
|
+
others (0.0.3)
|
138
|
+
parallel (1.25.1)
|
139
|
+
parser (3.3.3.0)
|
140
|
+
ast (~> 2.4.1)
|
141
|
+
racc
|
142
|
+
psych (5.1.2)
|
143
|
+
stringio
|
144
|
+
public_suffix (6.0.0)
|
145
|
+
racc (1.8.0)
|
146
|
+
rack (3.1.4)
|
147
|
+
rack-session (2.0.0)
|
148
|
+
rack (>= 3.0.0)
|
149
|
+
rack-test (2.1.0)
|
150
|
+
rack (>= 1.3)
|
151
|
+
rackup (2.1.0)
|
152
|
+
rack (>= 3)
|
153
|
+
webrick (~> 1.8)
|
154
|
+
rails-dom-testing (2.2.0)
|
155
|
+
activesupport (>= 5.0.0)
|
156
|
+
minitest
|
157
|
+
nokogiri (>= 1.6)
|
158
|
+
rails-html-sanitizer (1.6.0)
|
159
|
+
loofah (~> 2.21)
|
160
|
+
nokogiri (~> 1.14)
|
161
|
+
railties (7.1.3.4)
|
162
|
+
actionpack (= 7.1.3.4)
|
163
|
+
activesupport (= 7.1.3.4)
|
164
|
+
irb
|
165
|
+
rackup (>= 1.0.0)
|
166
|
+
rake (>= 12.2)
|
167
|
+
thor (~> 1.0, >= 1.2.2)
|
168
|
+
zeitwerk (~> 2.6)
|
169
|
+
rainbow (3.1.1)
|
170
|
+
rake (13.2.1)
|
171
|
+
rdoc (6.7.0)
|
172
|
+
psych (>= 4.0.0)
|
173
|
+
regexp_parser (2.9.2)
|
174
|
+
reline (0.5.9)
|
175
|
+
io-console (~> 0.5)
|
176
|
+
retries (0.0.5)
|
177
|
+
rexml (3.3.1)
|
178
|
+
strscan
|
179
|
+
rspec-core (3.13.0)
|
180
|
+
rspec-support (~> 3.13.0)
|
181
|
+
rspec-expectations (3.13.1)
|
182
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
183
|
+
rspec-support (~> 3.13.0)
|
184
|
+
rspec-mocks (3.13.1)
|
185
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
186
|
+
rspec-support (~> 3.13.0)
|
187
|
+
rspec-rails (6.1.3)
|
188
|
+
actionpack (>= 6.1)
|
189
|
+
activesupport (>= 6.1)
|
190
|
+
railties (>= 6.1)
|
191
|
+
rspec-core (~> 3.13)
|
192
|
+
rspec-expectations (~> 3.13)
|
193
|
+
rspec-mocks (~> 3.13)
|
194
|
+
rspec-support (~> 3.13)
|
195
|
+
rspec-support (3.13.1)
|
196
|
+
rubocop (1.64.1)
|
197
|
+
json (~> 2.3)
|
198
|
+
language_server-protocol (>= 3.17.0)
|
199
|
+
parallel (~> 1.10)
|
200
|
+
parser (>= 3.3.0.2)
|
201
|
+
rainbow (>= 2.2.2, < 4.0)
|
202
|
+
regexp_parser (>= 1.8, < 3.0)
|
203
|
+
rexml (>= 3.2.5, < 4.0)
|
204
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
205
|
+
ruby-progressbar (~> 1.7)
|
206
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
207
|
+
rubocop-ast (1.31.3)
|
208
|
+
parser (>= 3.3.1.0)
|
209
|
+
rubocop-performance (1.21.1)
|
210
|
+
rubocop (>= 1.48.1, < 2.0)
|
211
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
212
|
+
rubocop-rspec (3.0.1)
|
213
|
+
rubocop (~> 1.61)
|
214
|
+
ruby-progressbar (1.13.0)
|
215
|
+
sawyer (0.9.2)
|
216
|
+
addressable (>= 2.3.5)
|
217
|
+
faraday (>= 0.17.3, < 3)
|
218
|
+
simplecov (0.22.0)
|
219
|
+
docile (~> 1.1)
|
220
|
+
simplecov-html (~> 0.11)
|
221
|
+
simplecov_json_formatter (~> 0.1)
|
222
|
+
simplecov-cobertura (2.1.0)
|
223
|
+
rexml
|
224
|
+
simplecov (~> 0.19)
|
225
|
+
simplecov-html (0.12.3)
|
226
|
+
simplecov_json_formatter (0.1.4)
|
227
|
+
stringio (3.1.1)
|
228
|
+
strscan (3.1.0)
|
229
|
+
tago (0.0.2)
|
230
|
+
thor (1.3.1)
|
231
|
+
typhoeus (1.4.1)
|
232
|
+
ethon (>= 0.9.0)
|
233
|
+
tzinfo (2.0.6)
|
234
|
+
concurrent-ruby (~> 1.0)
|
235
|
+
unicode-display_width (2.5.0)
|
236
|
+
uri (0.13.0)
|
237
|
+
verbose (0.0.2)
|
238
|
+
loog (~> 0.2)
|
239
|
+
tago (~> 0.0)
|
240
|
+
webrick (1.8.1)
|
241
|
+
yaml (0.3.0)
|
242
|
+
yard (0.9.36)
|
243
|
+
zeitwerk (2.6.16)
|
244
|
+
|
245
|
+
PLATFORMS
|
246
|
+
arm64-darwin-22
|
247
|
+
x64-mingw-ucrt
|
248
|
+
x86_64-darwin-20
|
249
|
+
x86_64-linux
|
250
|
+
|
251
|
+
DEPENDENCIES
|
252
|
+
fbe!
|
253
|
+
minitest (= 5.24.0)
|
254
|
+
rake (= 13.2.1)
|
255
|
+
rspec-rails (= 6.1.3)
|
256
|
+
rubocop (= 1.64.1)
|
257
|
+
rubocop-performance (= 1.21.1)
|
258
|
+
rubocop-rspec (= 3.0.1)
|
259
|
+
simplecov (= 0.22.0)
|
260
|
+
simplecov-cobertura (= 2.1.0)
|
261
|
+
yard (= 0.9.36)
|
262
|
+
|
263
|
+
BUNDLED WITH
|
264
|
+
2.4.22
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Zerocracy
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# FactBase Extended
|
2
|
+
|
3
|
+
[](http://www.rultor.com/p/yegor256/fbe)
|
4
|
+
[](https://www.jetbrains.com/ruby/)
|
5
|
+
|
6
|
+
[](https://github.com/yegor256/fbe/actions/workflows/rake.yml)
|
7
|
+
[](http://www.0pdd.com/p?name=yegor256/fbe)
|
8
|
+
[](http://badge.fury.io/rb/fbe)
|
9
|
+
[](https://codecov.io/github/yegor256/fbe?branch=master)
|
10
|
+
[](http://rubydoc.info/github/yegor256/fbe/master/frames)
|
11
|
+
[](https://hitsofcode.com/view/github/yegor256/fbe)
|
12
|
+
[](https://github.com/yegor256/fbe/blob/master/LICENSE.txt)
|
13
|
+
|
14
|
+
It's a collection of tools.
|
15
|
+
|
16
|
+
## How to contribute
|
17
|
+
|
18
|
+
Read
|
19
|
+
[these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
|
20
|
+
Make sure you build is green before you contribute
|
21
|
+
your pull request. You will need to have
|
22
|
+
[Ruby](https://www.ruby-lang.org/en/) 3.2+ and
|
23
|
+
[Bundler](https://bundler.io/) installed. Then:
|
24
|
+
|
25
|
+
```bash
|
26
|
+
bundle update
|
27
|
+
bundle exec rake
|
28
|
+
```
|
29
|
+
|
30
|
+
If it's clean and you don't see any error messages, submit your pull request.
|
data/Rakefile
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2024 Zerocracy
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
|
23
|
+
require 'rubygems'
|
24
|
+
require 'rake'
|
25
|
+
require 'rake/clean'
|
26
|
+
|
27
|
+
def name
|
28
|
+
@name ||= File.basename(Dir['*.gemspec'].first, '.*')
|
29
|
+
end
|
30
|
+
|
31
|
+
def version
|
32
|
+
Gem::Specification.load(Dir['*.gemspec'].first).version
|
33
|
+
end
|
34
|
+
|
35
|
+
task default: %i[clean test rubocop yard copyright]
|
36
|
+
|
37
|
+
require 'rake/testtask'
|
38
|
+
desc 'Run all unit tests'
|
39
|
+
Rake::TestTask.new(:test) do |test|
|
40
|
+
Rake::Cleaner.cleanup_files(['coverage'])
|
41
|
+
test.libs << 'lib' << 'test'
|
42
|
+
test.pattern = 'test/**/test_*.rb'
|
43
|
+
test.warning = true
|
44
|
+
test.verbose = false
|
45
|
+
end
|
46
|
+
|
47
|
+
require 'yard'
|
48
|
+
desc 'Build Yard documentation'
|
49
|
+
YARD::Rake::YardocTask.new do |t|
|
50
|
+
t.files = ['lib/**/*.rb']
|
51
|
+
end
|
52
|
+
|
53
|
+
require 'rubocop/rake_task'
|
54
|
+
desc 'Run RuboCop on all directories'
|
55
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
56
|
+
task.fail_on_error = true
|
57
|
+
task.requires << 'rubocop-rspec'
|
58
|
+
end
|
59
|
+
|
60
|
+
task :copyright do
|
61
|
+
sh "grep -q -r '#{Date.today.strftime('%Y')}' \
|
62
|
+
--include '*.rb' \
|
63
|
+
--include '*.txt' \
|
64
|
+
--include 'Rakefile' \
|
65
|
+
."
|
66
|
+
end
|
data/fbe.gemspec
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2024 Zerocracy
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
|
23
|
+
require_relative 'lib/fbe'
|
24
|
+
|
25
|
+
Gem::Specification.new do |s|
|
26
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
27
|
+
s.required_ruby_version = '>=3.0'
|
28
|
+
s.name = 'fbe'
|
29
|
+
s.version = Fbe::VERSION
|
30
|
+
s.license = 'MIT'
|
31
|
+
s.summary = 'FactBase Extended (FBE), a collection of utility classes for Zerocracy judges'
|
32
|
+
s.description =
|
33
|
+
'A collection of extensions for a factbase, helping the judges of Zerocracy ' \
|
34
|
+
'manipulate the facts and create new ones'
|
35
|
+
s.authors = ['Yegor Bugayenko']
|
36
|
+
s.email = 'yegor256@gmail.com'
|
37
|
+
s.homepage = 'http://github.com/zerocracy/fbe'
|
38
|
+
s.files = `git ls-files`.split($RS)
|
39
|
+
s.rdoc_options = ['--charset=UTF-8']
|
40
|
+
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
41
|
+
s.add_runtime_dependency 'backtrace', '~>0.3'
|
42
|
+
s.add_runtime_dependency 'decoor', '~>0.0'
|
43
|
+
s.add_runtime_dependency 'factbase', '~>0.0'
|
44
|
+
s.add_runtime_dependency 'faraday', '2.9.1'
|
45
|
+
s.add_runtime_dependency 'faraday-http-cache', '2.5.1'
|
46
|
+
s.add_runtime_dependency 'faraday-multipart', '1.0.4'
|
47
|
+
s.add_runtime_dependency 'faraday-retry', '2.2.1'
|
48
|
+
s.add_runtime_dependency 'json', '~>2.7'
|
49
|
+
s.add_runtime_dependency 'judges', '~>0.0'
|
50
|
+
s.add_runtime_dependency 'loog', '~>0.2'
|
51
|
+
s.add_runtime_dependency 'nokogiri', '~>1.10'
|
52
|
+
s.add_runtime_dependency 'obk', '~>0.0'
|
53
|
+
s.add_runtime_dependency 'octokit', '~>9.1.0'
|
54
|
+
s.add_runtime_dependency 'others', '~>0.0'
|
55
|
+
s.add_runtime_dependency 'tago', '~>0.0'
|
56
|
+
s.add_runtime_dependency 'verbose', '~>0.0'
|
57
|
+
s.add_runtime_dependency 'yaml', '~>0.3'
|
58
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
59
|
+
end
|
data/lib/fbe/conclude.rb
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2024 Zerocracy
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
12
|
+
# furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included in all
|
15
|
+
# copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
# SOFTWARE.
|
24
|
+
|
25
|
+
require_relative '../fbe'
|
26
|
+
require_relative 'octo'
|
27
|
+
|
28
|
+
# Create a conclude code block.
|
29
|
+
def Fbe.conclude(fbx = fb, judge = $judge, loog = $loog, &)
|
30
|
+
c = Fbe::Conclude.new(fbx, judge, loog)
|
31
|
+
c.instance_eval(&)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Conclude.
|
35
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
36
|
+
# Copyright:: Copyright (c) 2024 Zerocracy
|
37
|
+
# License:: MIT
|
38
|
+
class Fbe::Conclude
|
39
|
+
def initialize(fb, judge, loog)
|
40
|
+
@fb = fb
|
41
|
+
@judge = judge
|
42
|
+
@loog = loog
|
43
|
+
@query = nil
|
44
|
+
@follows = []
|
45
|
+
@threshold = 9999
|
46
|
+
@quota_aware = false
|
47
|
+
end
|
48
|
+
|
49
|
+
def quota_aware
|
50
|
+
@quota_aware = true
|
51
|
+
end
|
52
|
+
|
53
|
+
def on(query)
|
54
|
+
raise 'Query is already set' unless @query.nil?
|
55
|
+
@query = query
|
56
|
+
end
|
57
|
+
|
58
|
+
def threshold(max)
|
59
|
+
@threshold = max
|
60
|
+
end
|
61
|
+
|
62
|
+
def follow(props)
|
63
|
+
@follows = props.split
|
64
|
+
end
|
65
|
+
|
66
|
+
def draw(&)
|
67
|
+
roll do |fbt, a|
|
68
|
+
n = fbt.insert
|
69
|
+
fill(n, a, &)
|
70
|
+
n
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def maybe(&)
|
75
|
+
roll do |fbt, a|
|
76
|
+
Fbe.if_absent(fbt) do |n|
|
77
|
+
fill(n, a, &)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def consider(&)
|
83
|
+
roll do |_fbt, a|
|
84
|
+
yield a
|
85
|
+
nil
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def roll(&)
|
92
|
+
catch :stop do
|
93
|
+
passed = 0
|
94
|
+
@fb.txn do |fbt|
|
95
|
+
fbt.query(@query).each do |a|
|
96
|
+
throw :stop if @quota_aware && Fbe.octo(loog: @loog).off_quota
|
97
|
+
throw :stop if passed >= @threshold
|
98
|
+
n = yield fbt, a
|
99
|
+
@loog.info("#{n.what}: #{n.details}") unless n.nil?
|
100
|
+
passed += 1
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def fill(fact, prev)
|
107
|
+
@follows.each do |follow|
|
108
|
+
v = prev.send(follow)
|
109
|
+
fact.send("#{follow}=", v)
|
110
|
+
fact.cause = prev._id
|
111
|
+
end
|
112
|
+
r = yield fact, prev
|
113
|
+
return unless r.is_a?(String)
|
114
|
+
fact.details = r
|
115
|
+
fact.what = @judge
|
116
|
+
end
|
117
|
+
end
|
data/lib/fbe/fb.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2024 Zerocracy
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
12
|
+
# furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included in all
|
15
|
+
# copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
# SOFTWARE.
|
24
|
+
|
25
|
+
require 'judges'
|
26
|
+
require 'factbase/looged'
|
27
|
+
require 'factbase/pre'
|
28
|
+
require 'factbase/rules'
|
29
|
+
require_relative '../fbe'
|
30
|
+
|
31
|
+
def Fbe.fb
|
32
|
+
rules = Dir.glob(File.join('rules', '*.fe')).map { |f| File.read(f) }
|
33
|
+
fb = Factbase::Rules.new(
|
34
|
+
$fb,
|
35
|
+
"(and \n#{rules.join("\n")}\n)",
|
36
|
+
uid: '_id'
|
37
|
+
)
|
38
|
+
fb = Factbase::Pre.new(fb) do |f|
|
39
|
+
max = $fb.query('(eq _id (max _id))').each.to_a[0]
|
40
|
+
f._id = (max.nil? ? 0 : max._id) + 1
|
41
|
+
f._time = Time.now
|
42
|
+
f._version = "#{Factbase::VERSION}/#{Judges::VERSION}/#{$options.judges_action_version}"
|
43
|
+
end
|
44
|
+
Factbase::Looged.new(fb, Loog::NULL)
|
45
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2024 Zerocracy
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
12
|
+
# furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included in all
|
15
|
+
# copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
# SOFTWARE.
|
24
|
+
|
25
|
+
require 'time'
|
26
|
+
require 'others'
|
27
|
+
require_relative '../fbe'
|
28
|
+
|
29
|
+
# Injects a fact if it's absent in the factbase.
|
30
|
+
def Fbe.if_absent(fb)
|
31
|
+
attrs = {}
|
32
|
+
f = others(map: attrs) do |*args|
|
33
|
+
k = args[0]
|
34
|
+
if k.end_with?('=')
|
35
|
+
@map[k[0..-2].to_sym] = args[1]
|
36
|
+
else
|
37
|
+
@map[k.to_sym]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
yield f
|
41
|
+
q = attrs.except('_id', '_time', '_version').map do |k, v|
|
42
|
+
vv = v.to_s
|
43
|
+
if v.is_a?(String)
|
44
|
+
vv = "'#{vv.gsub('"', '\\\\"').gsub("'", "\\\\'")}'"
|
45
|
+
elsif v.is_a?(Time)
|
46
|
+
vv = v.utc.iso8601
|
47
|
+
end
|
48
|
+
"(eq #{k} #{vv})"
|
49
|
+
end.join(' ')
|
50
|
+
q = "(and #{q})"
|
51
|
+
return unless fb.query(q).each.to_a.empty?
|
52
|
+
n = fb.insert
|
53
|
+
attrs.each { |k, v| n.send("#{k}=", v) }
|
54
|
+
n
|
55
|
+
end
|