fbe 0.0.21 → 0.0.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/fbe/award.rb +28 -3
- data/lib/fbe/octo.rb +16 -0
- data/lib/fbe.rb +1 -1
- data/test/fbe/test_award.rb +11 -1
- data/test/fbe/test_fb.rb +3 -1
- data/test/fbe/test_octo.rb +9 -0
- data/test/test__helper.rb +3 -3
- 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: b13ad3c8a5578c4a9e248948cab63ae21caeea7052d96260f2be85a43ee6f3b8
|
4
|
+
data.tar.gz: 90f8b081a67be3fd2f94a92cea890abb9b93f9b4b11a37a7bc6502f704c16510
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ea216f0e9be56b06ae8e350ea89b341f9d9fc230ca7785f5b0c0a494fcba3de913143e9c0c5d7074eea3ad368520bfaa462f891c5daf744b4ababbf05e600e8
|
7
|
+
data.tar.gz: 28c70598550a0e68ad1315fee0adce8ebeb31a7eb400f348181c0f916b3b5aac646a1d4f8d51d79f70e5553f3a4a88b33ba4afd67f2075a735cb578ea5312f0c
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# FactBase Extended
|
1
|
+
# FactBase Extended (FBE)
|
2
2
|
|
3
3
|
[![DevOps By Rultor.com](http://www.rultor.com/b/zerocracy/fbe)](http://www.rultor.com/p/zerocracy/fbe)
|
4
4
|
[![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
|
@@ -13,12 +13,14 @@
|
|
13
13
|
|
14
14
|
It's a collection of tools for
|
15
15
|
[zerocracy/judges-action](https://github.com/zerocracy/judges-action).
|
16
|
+
You are not supposed to use it directly, but only in a combination
|
17
|
+
with other tools of Zerocracy.
|
16
18
|
|
17
19
|
## How to contribute
|
18
20
|
|
19
21
|
Read
|
20
22
|
[these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
|
21
|
-
Make sure
|
23
|
+
Make sure your build is green before you contribute
|
22
24
|
your pull request. You will need to have
|
23
25
|
[Ruby](https://www.ruby-lang.org/en/) 3.2+ and
|
24
26
|
[Bundler](https://bundler.io/) installed. Then:
|
data/lib/fbe/award.rb
CHANGED
@@ -24,7 +24,25 @@
|
|
24
24
|
|
25
25
|
require 'factbase/syntax'
|
26
26
|
|
27
|
-
#
|
27
|
+
# A generator of awards.
|
28
|
+
#
|
29
|
+
# First, you should create a policy, using the same Lisp-ish syntax as
|
30
|
+
# we use in queries to a Factbase, for example:
|
31
|
+
#
|
32
|
+
# require 'fbe/award'
|
33
|
+
# a = Fbe::Award.new('(award (in loc "lines") (give (times loc 5) "for LoC"))')
|
34
|
+
#
|
35
|
+
# Then, you can either get a bill from it:
|
36
|
+
#
|
37
|
+
# b = a.bill(loc: 345)
|
38
|
+
# puts b.points # how many points to reward, a number
|
39
|
+
# puts b.greeting # how to explain the reward, a text
|
40
|
+
#
|
41
|
+
# Or else, you can get a policy text:
|
42
|
+
#
|
43
|
+
# p = a.policy
|
44
|
+
# puts p.markdown # Markdown of the policy
|
45
|
+
#
|
28
46
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
29
47
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
30
48
|
# License:: MIT
|
@@ -266,7 +284,14 @@ class Fbe::Award
|
|
266
284
|
|
267
285
|
def greeting
|
268
286
|
items = @lines.map { |l| "#{format('%+d', l[:v])} #{l[:t]}" }
|
269
|
-
|
287
|
+
case items.size
|
288
|
+
when 0
|
289
|
+
"You've earned nothing. "
|
290
|
+
when 1
|
291
|
+
"You've earned #{format('%+d', points)} points. "
|
292
|
+
else
|
293
|
+
"You've earned #{format('%+d', points)} points for this: #{items.join('; ')}. "
|
294
|
+
end
|
270
295
|
end
|
271
296
|
end
|
272
297
|
|
@@ -289,7 +314,7 @@ class Fbe::Award
|
|
289
314
|
end
|
290
315
|
|
291
316
|
def line(line)
|
292
|
-
line = line.gsub(/\$\{([a-z_0-9]+)\}/) { |_x| @lets[Regexp.last_match[1].to_sym] }
|
317
|
+
line = line.gsub(/\$\{([a-z_0-9]+)\}/) { |_x| "**#{@lets[Regexp.last_match[1].to_sym]}**" }
|
293
318
|
@lines << line
|
294
319
|
end
|
295
320
|
|
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
@@ -92,10 +92,20 @@ class TestAward < Minitest::Test
|
|
92
92
|
'(award (let x_a 25) (set z (plus x_a 1)) (give z "..."))' =>
|
93
93
|
'First, let _x-a_ be equal to **25**. Then, set _z_ to _x-a_ + **1**, and award _z_.',
|
94
94
|
'(award (aka (let x 17) (give x "hey") "add ${x} when necessary"))' =>
|
95
|
-
'Just add 17 when necessary'
|
95
|
+
'Just add **17** when necessary'
|
96
96
|
}.each do |q, t|
|
97
97
|
md = Fbe::Award.new(q).policy.markdown
|
98
98
|
assert(md.include?(t), md)
|
99
99
|
end
|
100
100
|
end
|
101
|
+
|
102
|
+
def test_shorten_when_one_number
|
103
|
+
g = Fbe::Award.new('(award (give 23 "for love"))').bill.greeting
|
104
|
+
assert_equal('You\'ve earned +23 points. ', g, g)
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_shorten_when_nothing
|
108
|
+
g = Fbe::Award.new('(award (give 0 "for none"))').bill.greeting
|
109
|
+
assert_equal('You\'ve earned nothing. ', g, g)
|
110
|
+
end
|
101
111
|
end
|
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
|
data/test/test__helper.rb
CHANGED
@@ -22,6 +22,9 @@
|
|
22
22
|
|
23
23
|
$stdout.sync = true
|
24
24
|
|
25
|
+
require 'minitest/reporters'
|
26
|
+
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
|
27
|
+
|
25
28
|
require 'simplecov'
|
26
29
|
SimpleCov.start
|
27
30
|
|
@@ -29,6 +32,3 @@ require 'simplecov-cobertura'
|
|
29
32
|
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
|
30
33
|
|
31
34
|
require 'minitest/autorun'
|
32
|
-
|
33
|
-
require 'minitest/reporters'
|
34
|
-
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
|
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.23
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|