fbe 0.0.54 → 0.0.55

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b0b9b1716b7cc0b7f757fdbc023c90254d27582eba1e865e1d003a9a1b212f5
4
- data.tar.gz: ba55f263c9a091c14ea08764bd081bc93e53e842539a9294899a5f6b760f32ce
3
+ metadata.gz: 705cf29669f71d490c86421f566b0ec05c61fa1d8352b97d752ea26b8bcbb294
4
+ data.tar.gz: e68fc23391048fac0a41a5b26af5ac85c4a34b3c434845710736d093d7eeb714
5
5
  SHA512:
6
- metadata.gz: de5a40ffed186489c61661796d469c1b67a323230fb60120e4db02d6389b73e8c3d03071171dfd208e5e35813d82c05927a35f4b8e5e545507ed0e09199977a3
7
- data.tar.gz: e2301187e03a966495eb31bd8f8ba89675ca0b78effe4f4542b04a9b03c4ce9e53f9fb31f2f0f126188187c29c9e6e06df6d562ade4e510bcae52060a816b1d5
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
- Max: 25
48
+ Enabled: false
49
49
  Metrics/PerceivedComplexity:
50
- Max: 30
50
+ Enabled: false
51
51
  Metrics/ClassLength:
52
52
  Enabled: false
53
53
  Layout/EmptyLineAfterGuardClause:
data/lib/fbe/award.rb CHANGED
@@ -300,7 +300,7 @@ class Fbe::Award
300
300
  end
301
301
 
302
302
  def points
303
- @lines.map { |l| l[:v] }.inject(&:+).to_i
303
+ @lines.map { |l| l[:v] }.inject(&:+).to_f.round.to_i
304
304
  end
305
305
 
306
306
  def greeting
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
- def initialize(fb:, judge:, loog:, options:, global:)
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
- "#{Fbe.octo(global:, options:, loog:).repo_name_by_id(fact.repository)}##{fact.issue}"
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
- # Project management functions.
29
- module Fbe; end
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
@@ -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.send(prop.to_s)
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
- "@#{Fbe.octo(options:, global:, loog:).user_name_by_id(fact.send(prop.to_s))}"
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
@@ -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.54'
30
+ VERSION = '0.0.55'
31
31
  end
@@ -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. '
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.54
4
+ version: 0.0.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko