fbe 0.0.54 → 0.0.55
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/lib/fbe/award.rb +1 -1
- data/lib/fbe/conclude.rb +14 -1
- data/lib/fbe/fb.rb +6 -0
- data/lib/fbe/issue.rb +13 -1
- data/lib/fbe/pmp.rb +7 -3
- data/lib/fbe/regularly.rb +8 -0
- data/lib/fbe/repeatedly.rb +3 -0
- data/lib/fbe/sec.rb +7 -1
- data/lib/fbe/who.rb +11 -1
- data/lib/fbe.rb +1 -1
- data/test/fbe/test_award.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 705cf29669f71d490c86421f566b0ec05c61fa1d8352b97d752ea26b8bcbb294
|
4
|
+
data.tar.gz: e68fc23391048fac0a41a5b26af5ac85c4a34b3c434845710736d093d7eeb714
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20ca9dfe05821edf5df55fccc51303fa23598e81dd15361cfb8b8f23db99b399c9e984ed0a1e1e97f43a0ebd048bd0beec5d8f870163cf0cea5c264fc1a505fc
|
7
|
+
data.tar.gz: e8fdc7f6988f441cf0d0cb63c52f29a95f17c9681be435eb6c57012403e903e0ce65bd4b60402e802485221f3c7d7ca0cc847d1ba2f40e318af9be82ab989dcc
|
data/.rubocop.yml
CHANGED
@@ -45,9 +45,9 @@ Metrics/BlockLength:
|
|
45
45
|
Metrics/AbcSize:
|
46
46
|
Enabled: false
|
47
47
|
Metrics/CyclomaticComplexity:
|
48
|
-
|
48
|
+
Enabled: false
|
49
49
|
Metrics/PerceivedComplexity:
|
50
|
-
|
50
|
+
Enabled: false
|
51
51
|
Metrics/ClassLength:
|
52
52
|
Enabled: false
|
53
53
|
Layout/EmptyLineAfterGuardClause:
|
data/lib/fbe/award.rb
CHANGED
data/lib/fbe/conclude.rb
CHANGED
@@ -28,6 +28,12 @@ require_relative 'octo'
|
|
28
28
|
require_relative 'if_absent'
|
29
29
|
|
30
30
|
# Create a conclude code block.
|
31
|
+
#
|
32
|
+
# @param [Factbase] fb The factbase
|
33
|
+
# @param [String] judge The name of the judge, from the +judges+ tool
|
34
|
+
# @param [Hash] global The hash for global caching
|
35
|
+
# @param [Judges::Options] options The options coming from the +judges+ tool
|
36
|
+
# @param [Loog] logg The logging facility
|
31
37
|
def Fbe.conclude(fb: Fbe.fb, judge: $judge, loog: $loog, options: $options, global: $global, &)
|
32
38
|
c = Fbe::Conclude.new(fb:, judge:, loog:, options:, global:)
|
33
39
|
c.instance_eval(&)
|
@@ -38,7 +44,14 @@ end
|
|
38
44
|
# Copyright:: Copyright (c) 2024 Zerocracy
|
39
45
|
# License:: MIT
|
40
46
|
class Fbe::Conclude
|
41
|
-
|
47
|
+
# Ctor.
|
48
|
+
#
|
49
|
+
# @param [Factbase] fb The factbase
|
50
|
+
# @param [String] judge The name of the judge, from the +judges+ tool
|
51
|
+
# @param [Hash] global The hash for global caching
|
52
|
+
# @param [Judges::Options] options The options coming from the +judges+ tool
|
53
|
+
# @param [Loog] logg The logging facility
|
54
|
+
def initialize(fb:, judge:, global:, options:, loog:)
|
42
55
|
@fb = fb
|
43
56
|
@judge = judge
|
44
57
|
@loog = loog
|
data/lib/fbe/fb.rb
CHANGED
@@ -30,6 +30,12 @@ require 'factbase/pre'
|
|
30
30
|
require 'factbase/rules'
|
31
31
|
require_relative '../fbe'
|
32
32
|
|
33
|
+
# Returns an instance of +Factbase+ (cached).
|
34
|
+
#
|
35
|
+
# @param [Factbase] fb The global factbase provided by the +judges+ tool
|
36
|
+
# @param [Hash] global The hash for global caching
|
37
|
+
# @param [Judges::Options] options The options coming from the +judges+ tool
|
38
|
+
# @param [Loog] logg The logging facility
|
33
39
|
def Fbe.fb(fb: $fb, global: $global, options: $options, loog: $loog)
|
34
40
|
global[:fb] ||=
|
35
41
|
begin
|
data/lib/fbe/issue.rb
CHANGED
@@ -24,6 +24,18 @@
|
|
24
24
|
|
25
25
|
require_relative '../fbe'
|
26
26
|
|
27
|
+
# Converts an ID of GitHub issue into a nicely formatting string.
|
28
|
+
#
|
29
|
+
# @param [Factbase::Fact] fact The fact, where to get the ID of GitHub issue
|
30
|
+
# @param [Judges::Options] options The options coming from the +judges+ tool
|
31
|
+
# @param [Hash] global The hash for global caching
|
32
|
+
# @param [Loog] logg The logging facility
|
27
33
|
def Fbe.issue(fact, options: $options, global: $global, loog: $loog)
|
28
|
-
|
34
|
+
rid = fact['repository']
|
35
|
+
raise "There is no 'repository' property" if rid.nil?
|
36
|
+
rid = rid.first.to_i
|
37
|
+
issue = fact['issue']
|
38
|
+
raise "There is no 'issue' property" if issue.nil?
|
39
|
+
issue = issue.first.to_i
|
40
|
+
"#{Fbe.octo(global:, options:, loog:).repo_name_by_id(rid)}##{issue}"
|
29
41
|
end
|
data/lib/fbe/pmp.rb
CHANGED
@@ -24,10 +24,14 @@
|
|
24
24
|
|
25
25
|
require 'others'
|
26
26
|
require_relative 'fb'
|
27
|
+
require_relative '../fbe'
|
27
28
|
|
28
|
-
#
|
29
|
-
|
30
|
-
|
29
|
+
# Get configuration parameter from the "PMP" fact.
|
30
|
+
#
|
31
|
+
# @param [Factbase] fb The factbase
|
32
|
+
# @param [Hash] global The hash for global caching
|
33
|
+
# @param [Judges::Options] options The options coming from the +judges+ tool
|
34
|
+
# @param [Loog] logg The logging facility
|
31
35
|
def Fbe.pmp(fb: Fbe.fb, global: $global, options: $options, loog: $loog)
|
32
36
|
others do |*args1|
|
33
37
|
area = args1.first
|
data/lib/fbe/regularly.rb
CHANGED
@@ -25,6 +25,14 @@
|
|
25
25
|
require_relative '../fbe'
|
26
26
|
require_relative 'fb'
|
27
27
|
|
28
|
+
# Run the block provided every X days.
|
29
|
+
#
|
30
|
+
# @param [String] area The name of the PMP area
|
31
|
+
# @param [Integer] p_every_days How frequently to run, every X days
|
32
|
+
# @param [Integer] p_since_days Since when to collect stats, X days
|
33
|
+
# @param [Factbase] fb The factbase
|
34
|
+
# @param [String] judge The name of the judge, from the +judges+ tool
|
35
|
+
# @param [Loog] logg The logging facility
|
28
36
|
def Fbe.regularly(area, p_every_days, p_since_days = nil, fb: Fbe.fb, judge: $judge, loog: $loog, &)
|
29
37
|
pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_days}))").each.to_a.first
|
30
38
|
interval = pmp.nil? ? 7 : pmp[p_every_days].first
|
data/lib/fbe/repeatedly.rb
CHANGED
@@ -30,6 +30,9 @@ require_relative 'overwrite'
|
|
30
30
|
#
|
31
31
|
# @param [String] area The name of the PMP area
|
32
32
|
# @param [Integer] p_every_hours How frequently to run, every X hours
|
33
|
+
# @param [Factbase] fb The factbase
|
34
|
+
# @param [String] judge The name of the judge, from the +judges+ tool
|
35
|
+
# @param [Loog] logg The logging facility
|
33
36
|
def Fbe.repeatedly(area, p_every_hours, fb: Fbe.fb, judge: $judge, loog: $loog, &)
|
34
37
|
pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_hours}))").each.to_a.first
|
35
38
|
hours = pmp.nil? ? 24 : pmp[p_every_hours].first
|
data/lib/fbe/sec.rb
CHANGED
@@ -24,8 +24,14 @@
|
|
24
24
|
|
25
25
|
require_relative '../fbe'
|
26
26
|
|
27
|
+
# Converts number of seconds into text.
|
28
|
+
#
|
29
|
+
# @param [Factbase::Fact] fact The fact, where to get the number of seconds
|
30
|
+
# @param [String] prop The property in the fact, with the seconds
|
27
31
|
def Fbe.sec(fact, prop = :seconds)
|
28
|
-
s = fact
|
32
|
+
s = fact[prop.to_s]
|
33
|
+
raise "There is no #{prop} property" if s.nil?
|
34
|
+
s = s.first.to_i
|
29
35
|
if s < 60
|
30
36
|
format('%d seconds', s)
|
31
37
|
elsif s < 60 * 60
|
data/lib/fbe/who.rb
CHANGED
@@ -24,6 +24,16 @@
|
|
24
24
|
|
25
25
|
require_relative '../fbe'
|
26
26
|
|
27
|
+
# Converts an ID of GitHub user into a nicely formatting string with his name.
|
28
|
+
#
|
29
|
+
# @param [Factbase::Fact] fact The fact, where to get the ID of GitHub user
|
30
|
+
# @param [String] prop The property in the fact, with the ID
|
31
|
+
# @param [Judges::Options] options The options coming from the +judges+ tool
|
32
|
+
# @param [Hash] global The hash for global caching
|
33
|
+
# @param [Loog] logg The logging facility
|
27
34
|
def Fbe.who(fact, prop = :who, options: $options, global: $global, loog: $loog)
|
28
|
-
|
35
|
+
id = fact[prop.to_s]
|
36
|
+
raise "There is no #{prop} property" if id.nil?
|
37
|
+
id = id.first.to_i
|
38
|
+
"@#{Fbe.octo(options:, global:, loog:).user_name_by_id(id)}"
|
29
39
|
end
|
data/lib/fbe.rb
CHANGED
data/test/fbe/test_award.rb
CHANGED
@@ -96,6 +96,7 @@ class TestAward < Minitest::Test
|
|
96
96
|
|
97
97
|
def test_some_greetings
|
98
98
|
{
|
99
|
+
'(award (give (times 7 0.25 "fun")))' => 'You\'ve earned +2 points. ',
|
99
100
|
'(award (give (times 5 0.25 "fun")))' => 'You\'ve earned +1 points. ',
|
100
101
|
'(award (give 25 "for being a good boy"))' => 'You\'ve earned +25 points. ',
|
101
102
|
'(award (let x 0.1) (set b (times x 14)) (give b "fun"))' => 'You\'ve earned +1 points. '
|