fbe 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0049f50b79fc11504fa48a1b8bf6f3245ec73673068254b639a342996467d3ae'
4
- data.tar.gz: dae993c649a54a5e8a653d4a55128482d1350bbf07a9942cc5bce674a92f85b8
3
+ metadata.gz: b13ad3c8a5578c4a9e248948cab63ae21caeea7052d96260f2be85a43ee6f3b8
4
+ data.tar.gz: 90f8b081a67be3fd2f94a92cea890abb9b93f9b4b11a37a7bc6502f704c16510
5
5
  SHA512:
6
- metadata.gz: b0b56a583dc6236fe4539192b10954cb5d16c3acad9f9193de6ed0d77fb14caab012fda9dbf25bfb416cd88ae601cdc710d28312f454ea93cb3144ee75cb3114
7
- data.tar.gz: 1393af02f45e78b354d0bba98706427bba9c769ffa39f029973ef209e85b401ac9d021421af08ab9f5a3f997e51ce8b4f0861ca0ba42b2a184645671ae56143f
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 you build is green before you contribute
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
- # Award generator.
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
- "You've earned #{format('%+d', points)} points for this: #{items.join('; ')}. "
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.rb CHANGED
@@ -27,5 +27,5 @@
27
27
  # License:: MIT
28
28
  module Fbe
29
29
  # Current version of the gem (changed by .rultor.yml on every release)
30
- VERSION = '0.0.22'
30
+ VERSION = '0.0.23'
31
31
  end
@@ -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/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.22
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-19 00:00:00.000000000 Z
11
+ date: 2024-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace