fbe 0.0.20 → 0.0.22
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/lib/fbe/award.rb +32 -3
- data/lib/fbe/octo.rb +16 -0
- data/lib/fbe.rb +1 -1
- data/test/fbe/test_award.rb +9 -8
- data/test/fbe/test_fb.rb +3 -1
- data/test/fbe/test_octo.rb +9 -0
- 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: '0049f50b79fc11504fa48a1b8bf6f3245ec73673068254b639a342996467d3ae'
|
4
|
+
data.tar.gz: dae993c649a54a5e8a653d4a55128482d1350bbf07a9942cc5bce674a92f85b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0b56a583dc6236fe4539192b10954cb5d16c3acad9f9193de6ed0d77fb14caab012fda9dbf25bfb416cd88ae601cdc710d28312f454ea93cb3144ee75cb3114
|
7
|
+
data.tar.gz: 1393af02f45e78b354d0bba98706427bba9c769ffa39f029973ef209e85b401ac9d021421af08ab9f5a3f997e51ce8b4f0861ca0ba42b2a184645671ae56143f
|
data/lib/fbe/award.rb
CHANGED
@@ -67,6 +67,12 @@ class Fbe::Award
|
|
67
67
|
rescue StandardError => e
|
68
68
|
raise "Failure in #{o}: #{e.message}"
|
69
69
|
end
|
70
|
+
when :aka
|
71
|
+
@operands[0..-2].each do |o|
|
72
|
+
o.bill_to(bill)
|
73
|
+
rescue StandardError => e
|
74
|
+
raise "Failure in #{o}: #{e.message}"
|
75
|
+
end
|
70
76
|
when :let, :set
|
71
77
|
bill.set(@operands[0], to_val(@operands[1], bill))
|
72
78
|
when :give
|
@@ -147,7 +153,7 @@ class Fbe::Award
|
|
147
153
|
when :if
|
148
154
|
"if #{to_p(@operands[0])} then #{to_p(@operands[1])} else #{to_p(@operands[2])}"
|
149
155
|
when :eq
|
150
|
-
"#{to_p(@operands[0])}
|
156
|
+
"#{to_p(@operands[0])} = #{to_p(@operands[1])}"
|
151
157
|
when :lt
|
152
158
|
"#{to_p(@operands[0])} < #{to_p(@operands[1])}"
|
153
159
|
when :lte
|
@@ -183,12 +189,21 @@ class Fbe::Award
|
|
183
189
|
rescue StandardError => e
|
184
190
|
raise "Failure in #{o}: #{e.message}"
|
185
191
|
end
|
192
|
+
when :aka
|
193
|
+
@operands[0..-2].each do |o|
|
194
|
+
o.publish_to(policy)
|
195
|
+
rescue StandardError => e
|
196
|
+
raise "Failure in #{o}: #{e.message}"
|
197
|
+
end
|
198
|
+
policy.revert(@operands.size - 1)
|
199
|
+
policy.line(to_p(@operands[@operands.size - 1]))
|
186
200
|
when :explain
|
187
201
|
policy.intro(to_p(@operands[0]))
|
188
202
|
when :in
|
189
203
|
policy.line("assume that #{to_p(@operands[0])} is #{to_p(@operands[1])}")
|
190
204
|
when :let
|
191
205
|
policy.line("let #{to_p(@operands[0])} be equal to #{to_p(@operands[1])}")
|
206
|
+
policy.let(@operands[0], @operands[1])
|
192
207
|
when :set
|
193
208
|
policy.line("set #{to_p(@operands[0])} to #{to_p(@operands[1])}")
|
194
209
|
when :give
|
@@ -217,7 +232,7 @@ class Fbe::Award
|
|
217
232
|
9 => '₉'
|
218
233
|
}
|
219
234
|
s.gsub!(/([a-z]+)([0-9])/) { |_| "#{Regexp.last_match[1]}#{subs[Regexp.last_match[2].to_i]}" }
|
220
|
-
"_#{s.gsub('_', '
|
235
|
+
"_#{s.gsub('_', '-')}_"
|
221
236
|
when Integer, Float
|
222
237
|
"**#{any}**"
|
223
238
|
else
|
@@ -262,6 +277,11 @@ class Fbe::Award
|
|
262
277
|
def initialize
|
263
278
|
@lines = []
|
264
279
|
@intro = ''
|
280
|
+
@lets = {}
|
281
|
+
end
|
282
|
+
|
283
|
+
def revert(num)
|
284
|
+
@lines.slice!(-num, num)
|
265
285
|
end
|
266
286
|
|
267
287
|
def intro(text)
|
@@ -269,14 +289,23 @@ class Fbe::Award
|
|
269
289
|
end
|
270
290
|
|
271
291
|
def line(line)
|
292
|
+
line = line.gsub(/\$\{([a-z_0-9]+)\}/) { |_x| @lets[Regexp.last_match[1].to_sym] }
|
272
293
|
@lines << line
|
273
294
|
end
|
274
295
|
|
296
|
+
def let(key, value)
|
297
|
+
@lets[key] = value
|
298
|
+
end
|
299
|
+
|
275
300
|
def markdown
|
276
301
|
pars = []
|
277
302
|
pars << "#{@intro}." unless @intro.empty?
|
278
303
|
pars << 'Here is how it\'s calculated:'
|
279
|
-
|
304
|
+
if @lines.size == 1
|
305
|
+
pars << "Just #{@lines.first}."
|
306
|
+
else
|
307
|
+
pars += @lines.each_with_index.map { |t, i| "#{i.zero? ? 'First' : 'Then'}, #{t}." }
|
308
|
+
end
|
280
309
|
pars.join(' ').gsub('. Then, award ', ', and award ')
|
281
310
|
end
|
282
311
|
end
|
data/lib/fbe/octo.rb
CHANGED
@@ -175,6 +175,22 @@ class Fbe::FakeOctokit
|
|
175
175
|
}
|
176
176
|
end
|
177
177
|
|
178
|
+
def commit_pulls(repo, _sha)
|
179
|
+
[
|
180
|
+
pull_request(repo, 42)
|
181
|
+
]
|
182
|
+
end
|
183
|
+
|
184
|
+
def pull_request(repo, number)
|
185
|
+
{
|
186
|
+
id: 42,
|
187
|
+
number:,
|
188
|
+
repo: {
|
189
|
+
full_name: repo
|
190
|
+
}
|
191
|
+
}
|
192
|
+
end
|
193
|
+
|
178
194
|
def add_comment(_repo, _issue, _text)
|
179
195
|
{
|
180
196
|
id: 42
|
data/lib/fbe.rb
CHANGED
data/test/fbe/test_award.rb
CHANGED
@@ -40,8 +40,11 @@ class TestAward < Minitest::Test
|
|
40
40
|
(let max 36)
|
41
41
|
(let basis 30)
|
42
42
|
(give basis "as a basis")
|
43
|
-
(
|
44
|
-
(
|
43
|
+
(let fee 10)
|
44
|
+
(aka
|
45
|
+
(set b1 (if (lt hours max) fee 0))
|
46
|
+
(give b1 "for resolving the bug in ${hours} (<${max}) hours")
|
47
|
+
"add ${+fee} if it was resolved in less than ${max} hours")
|
45
48
|
(set days (div hours 24))
|
46
49
|
(set b2 (times days -1))
|
47
50
|
(let worst -20)
|
@@ -86,12 +89,10 @@ class TestAward < Minitest::Test
|
|
86
89
|
|
87
90
|
def test_some_policies
|
88
91
|
{
|
89
|
-
'(award (let
|
90
|
-
'First, let
|
91
|
-
|
92
|
-
|
93
|
-
# '(award (let x -5) (give x "..."))' =>
|
94
|
-
# 'The amount is **-5**.',
|
92
|
+
'(award (let x_a 25) (set z (plus x_a 1)) (give z "..."))' =>
|
93
|
+
'First, let _x-a_ be equal to **25**. Then, set _z_ to _x-a_ + **1**, and award _z_.',
|
94
|
+
'(award (aka (let x 17) (give x "hey") "add ${x} when necessary"))' =>
|
95
|
+
'Just add 17 when necessary'
|
95
96
|
}.each do |q, t|
|
96
97
|
md = Fbe::Award.new(q).policy.markdown
|
97
98
|
assert(md.include?(t), md)
|
data/test/fbe/test_fb.rb
CHANGED
@@ -39,9 +39,11 @@ class TestFb < Minitest::Test
|
|
39
39
|
$fb = Factbase.new
|
40
40
|
$global = {}
|
41
41
|
$options = Judges::Options.new
|
42
|
-
$loog = Loog::
|
42
|
+
$loog = Loog::Buffer.new
|
43
43
|
Fbe.fb.insert.foo = 1
|
44
44
|
Fbe.fb.insert.bar = 2
|
45
45
|
assert_equal(1, Fbe.fb.query('(exists bar)').each.to_a.size)
|
46
|
+
stdout = $loog.to_s
|
47
|
+
assert(stdout.include?('Inserted new fact #1'), stdout)
|
46
48
|
end
|
47
49
|
end
|
data/test/fbe/test_octo.rb
CHANGED
@@ -38,6 +38,8 @@ class TestOcto < Minitest::Test
|
|
38
38
|
options = Judges::Options.new({ 'testing' => true })
|
39
39
|
o = Fbe.octo(loog: Loog::NULL, global:, options:)
|
40
40
|
assert(!o.off_quota)
|
41
|
+
assert(!o.pull_request('foo/foo', 42).nil?)
|
42
|
+
assert(!o.commit_pulls('foo/foo', 'sha').nil?)
|
41
43
|
end
|
42
44
|
|
43
45
|
def test_post_comment
|
@@ -59,4 +61,11 @@ class TestOcto < Minitest::Test
|
|
59
61
|
o = Fbe.octo(loog: Loog::NULL, global:, options:)
|
60
62
|
assert_raises { o.repository('zerocracy/fbe') }
|
61
63
|
end
|
64
|
+
|
65
|
+
def test_commit_pulls
|
66
|
+
skip # it's a "live" test, run it manually if you need it
|
67
|
+
o = Fbe.octo(loog: Loog::NULL, global: {}, options: Judges::Options.new)
|
68
|
+
assert_equal(1, o.commit_pulls('zerocracy/fbe', '0b7d0699bd744b62c0731064c2adaad0c58e1416').size)
|
69
|
+
assert_equal(0, o.commit_pulls('zerocracy/fbe', '16b3ea6b71c6e932ba7666c40ca846ecaa6d6f0d').size)
|
70
|
+
end
|
62
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fbe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|