fbe 0.41.6 → 0.43.0

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: 6b5d47bbe77b20ccc3ef6a6999868a14ece4179820fcfa6399d95b5f337847c4
4
- data.tar.gz: ed8adf2adf7788b6e9a1b5db1f0c72fb79f1c819ccfadd783254ea6f7d7423b9
3
+ metadata.gz: 5389d9ecc0b9c343ea11ce2054aa1c8bf2efaff8d62e320e92e142bc3b9ed1cc
4
+ data.tar.gz: e04b7d8d445789490aee49c7ee8a068da1256c6636b01ad1b350b74ddf8168e6
5
5
  SHA512:
6
- metadata.gz: c39aede26820313b2c38717d7580a59e3596155ba4a469896cb5639c226b339231af20851c5497c3a3d5b15dd298db20af5b97d29058ab2d2b5250253b0f1aee
7
- data.tar.gz: 5ba8916e613ce8036b712c42c1edca912ac61c4265e8680bd3358bcfa9ccab74b9f1d89cce356e20699cb8a8881f812868ebdfaad94695963059c79a40131672
6
+ metadata.gz: e4b269991d90d608370dd3c0fb2ad703d700f1a959022143a0f13291d9699d7af71f85125fa760b4cda3584c59a73fe2b49666445ee95beb4d1c104b66e44a75
7
+ data.tar.gz: ec874b7fb71b3c325c7d05cb3bba9c168270ddfe10e3c8294778a0ffabac5ebf2aa522fafc39eddf11f64f7f7308798d9d88c3adb41559241e97dd88436676fa
@@ -15,7 +15,7 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v5
18
+ - uses: actions/checkout@v6
19
19
  - name: Download actionlint
20
20
  id: get_actionlint
21
21
  run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
@@ -12,7 +12,7 @@ jobs:
12
12
  timeout-minutes: 15
13
13
  runs-on: ubuntu-24.04
14
14
  steps:
15
- - uses: actions/checkout@v5
15
+ - uses: actions/checkout@v6
16
16
  - uses: ruby/setup-ruby@v1
17
17
  with:
18
18
  ruby-version: 3.4.7
@@ -11,5 +11,5 @@ jobs:
11
11
  timeout-minutes: 15
12
12
  runs-on: ubuntu-24.04
13
13
  steps:
14
- - uses: actions/checkout@v5
14
+ - uses: actions/checkout@v6
15
15
  - uses: yegor256/copyrights-action@0.0.12
@@ -19,5 +19,5 @@ jobs:
19
19
  timeout-minutes: 15
20
20
  runs-on: ubuntu-24.04
21
21
  steps:
22
- - uses: actions/checkout@v5
23
- - uses: DavidAnson/markdownlint-cli2-action@v20.0.0
22
+ - uses: actions/checkout@v6
23
+ - uses: DavidAnson/markdownlint-cli2-action@v21.0.0
@@ -15,5 +15,5 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v5
18
+ - uses: actions/checkout@v6
19
19
  - uses: volodya-lombrozo/pdd-action@master
@@ -18,7 +18,7 @@ jobs:
18
18
  ruby: [3.3]
19
19
  runs-on: ${{ matrix.os }}
20
20
  steps:
21
- - uses: actions/checkout@v5
21
+ - uses: actions/checkout@v6
22
22
  - uses: ruby/setup-ruby@v1
23
23
  with:
24
24
  ruby-version: ${{ matrix.ruby }}
@@ -15,5 +15,5 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v5
18
+ - uses: actions/checkout@v6
19
19
  - uses: fsfe/reuse-action@v6
@@ -15,7 +15,7 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v5
19
- - uses: crate-ci/typos@v1.39.0
18
+ - uses: actions/checkout@v6
19
+ - uses: crate-ci/typos@v1.40.0
20
20
  with:
21
21
  config: .github/.typos.toml
@@ -11,5 +11,5 @@ jobs:
11
11
  timeout-minutes: 15
12
12
  runs-on: ubuntu-24.04
13
13
  steps:
14
- - uses: actions/checkout@v5
14
+ - uses: actions/checkout@v6
15
15
  - uses: g4s8/xcop-action@master
@@ -15,7 +15,7 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v5
18
+ - uses: actions/checkout@v6
19
19
  - uses: ibiqlik/action-yamllint@v3
20
20
  with:
21
21
  config_file: .yamllint.yml
data/assets/pmp.xml ADDED
@@ -0,0 +1,89 @@
1
+ <?xml version='1.0'?>
2
+ <!--
3
+ SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
4
+ SPDX-License-Identifier: MIT
5
+ -->
6
+ <pmp>
7
+ <area name="hr">
8
+ <p>
9
+ <name>anger</name>
10
+ <default>2</default>
11
+ <type>int</type>
12
+ <memo>The level of anger</memo>
13
+ </p>
14
+ <p>
15
+ <name>days_to_reward</name>
16
+ <default>14</default>
17
+ <type>int</type>
18
+ <memo>How many days ago an event must happen so that we reward it?</memo>
19
+ </p>
20
+ <p>
21
+ <name>days_of_running_score</name>
22
+ <default>56</default>
23
+ <type>int</type>
24
+ <memo>How many days to include into the score of a person?</memo>
25
+ </p>
26
+ <p>
27
+ <name>master_punish_days</name>
28
+ <default>4</default>
29
+ <type>int</type>
30
+ <memo>Every X days to punish for direct push to master</memo>
31
+ </p>
32
+ </area>
33
+ <area name="integration">
34
+ <p>
35
+ <name>eva_interval</name>
36
+ <default>10</default>
37
+ <type>int</type>
38
+ <memo>Every X days to collect EVA statistics</memo>
39
+ </p>
40
+ <p>
41
+ <name>eva_learn_hours</name>
42
+ <default>8</default>
43
+ <type>int</type>
44
+ <memo>Every X hours to collect EVA numbers and learn the model using them</memo>
45
+ </p>
46
+ </area>
47
+ <area name="quality">
48
+ <p>
49
+ <name>paranoia</name>
50
+ <default>2</default>
51
+ <type>int</type>
52
+ <memo>The level of paranoia</memo>
53
+ </p>
54
+ <p>
55
+ <name>qos_days</name>
56
+ <default>32</default>
57
+ <type>int</type>
58
+ <memo>For how many days to collect QoS data</memo>
59
+ </p>
60
+ </area>
61
+ <area name="scope">
62
+ <p>
63
+ <name>qod_days</name>
64
+ <default>32</default>
65
+ <type>int</type>
66
+ <memo>For how many days to collect QoD data</memo>
67
+ </p>
68
+ </area>
69
+ <area name="cost">
70
+ <p>
71
+ <name>love</name>
72
+ <default>2</default>
73
+ <type>int</type>
74
+ <memo>The level of love</memo>
75
+ </p>
76
+ <p>
77
+ <name>award_price</name>
78
+ <default>0.0</default>
79
+ <type>float</type>
80
+ <memo>How many USD to pay for each award point</memo>
81
+ </p>
82
+ <p>
83
+ <name>slaves</name>
84
+ <default>torvalds</default>
85
+ <type>string</type>
86
+ <memo>List of people, who are not supposed to be paid real cash</memo>
87
+ </p>
88
+ </area>
89
+ </pmp>
data/lib/fbe/pmp.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
+ require 'delegate'
7
+ require 'nokogiri'
6
8
  require 'others'
7
9
  require_relative '../fbe'
8
10
  require_relative 'fb'
@@ -41,18 +43,47 @@ require_relative 'fb'
41
43
  # # Get deadline from time area
42
44
  # deadline = Fbe.pmp.time.deadline
43
45
  def Fbe.pmp(fb: Fbe.fb, global: $global, options: $options, loog: $loog)
44
- others do |*args1|
45
- area = args1.first
46
- unless %w[cost scope hr time procurement risk integration quality communication].include?(area.to_s)
47
- raise "Invalid area #{area.inspect} (not part of PMBOK)"
46
+ xml = Nokogiri::XML(File.read(File.join(__dir__, '../../assets/pmp.xml')))
47
+ pmpv =
48
+ Class.new(SimpleDelegator) do
49
+ def initialize(value, dv)
50
+ super(value)
51
+ @dv = dv
52
+ end
53
+
54
+ def default
55
+ @dv
56
+ end
57
+ end
58
+ Class.new do
59
+ define_method(:areas) do
60
+ xml.xpath('/pmp/area/@name').map(&:value)
48
61
  end
49
- others do |*args2|
50
- param = args2.first
51
- f = Fbe.fb(global:, fb:, options:, loog:).query("(and (eq what 'pmp') (eq area '#{area}'))").each.first
52
- raise "Unknown area #{area.inspect}" if f.nil?
53
- r = f[param]
54
- raise "Unknown property #{param.inspect} in the #{area.inspect} area" if r.nil?
55
- r.first
62
+ others do |*args1|
63
+ area = args1.first.to_s
64
+ node = xml.at_xpath("/pmp/area[@name='#{area}']")
65
+ raise "Unknown area #{area.inspect}" if node.nil?
66
+ Class.new do
67
+ define_method(:properties) do
68
+ node.xpath('p/name').map(&:text)
69
+ end
70
+ others do |*args2|
71
+ param = args2.first.to_s
72
+ prop = node.at_xpath("p[name='#{param}']")
73
+ raise "Unknown property #{param.inspect} in the #{area.inspect} area" if prop.nil?
74
+ f = Fbe.fb(global:, fb:, options:, loog:).query("(and (eq what 'pmp') (eq area '#{area}'))").each.first
75
+ r = f&.[](param)&.first
76
+ d = prop.at_xpath('default').text
77
+ t = prop.at_xpath('type').text
78
+ dv =
79
+ case t
80
+ when 'int' then d.to_i
81
+ when 'float' then d.to_f
82
+ else d
83
+ end
84
+ pmpv.new(r || dv, dv)
85
+ end
86
+ end.new
56
87
  end
57
- end
88
+ end.new
58
89
  end
data/lib/fbe/tombstone.rb CHANGED
@@ -22,11 +22,32 @@ class Fbe::Tombstone
22
22
  @fid = fid
23
23
  end
24
24
 
25
+ # See all issues in the tombstone, as array of numbers.
26
+ # @param [String] where The place, e.g. "github"
27
+ # @param [Integer] repo ID of repository
28
+ # @return [Array<Integer>] IDs of issue
29
+ def issues(where, repo)
30
+ raise 'The type of "where" is not String' unless where.is_a?(String)
31
+ raise 'The type of "repo" is not Integer' unless repo.is_a?(Integer)
32
+ f = @fb.query(
33
+ "(and (eq where '#{where}') (eq what 'tombstone') (eq repository #{repo}) (exists issues))"
34
+ ).each.first
35
+ return [] if f.nil?
36
+ f['issues'].map do |ii|
37
+ a, b = ii.split('-').map(&:to_i)
38
+ b = a if b.nil?
39
+ (a..b).map { |i| i }
40
+ end.flatten
41
+ end
42
+
25
43
  # Put it there.
26
44
  # @param [String] where The place, e.g. "github"
27
45
  # @param [Integer] repo ID of repository
28
- # @param [Integer] issue ID of issue (or array of them)
46
+ # @param [Integer, Array<Integer>] issue ID of issue (or array of them)
29
47
  def bury!(where, repo, issue)
48
+ raise 'The type of "where" is not String' unless where.is_a?(String)
49
+ raise 'The type of "repo" is not Integer' unless repo.is_a?(Integer)
50
+ raise 'The type of "issue" is neither Integer nor Array' unless issue.is_a?(Integer) || issue.is_a?(Array)
30
51
  f =
31
52
  Fbe.if_absent(fb: @fb, always: true) do |n|
32
53
  n.what = 'tombstone'
@@ -48,16 +69,20 @@ class Fbe::Tombstone
48
69
  end
49
70
  end
50
71
  Fbe.overwrite(
51
- f, 'issues', merged.map { |ii| ii[0] == ii[1] ? ii[0].to_s : "#{ii[0]}-#{ii[1]}" }, fb: @fb, fid: @fid
72
+ f, 'issues', merged.map { |ii| ii[0] == ii[1] ? ii[0].to_s : "#{ii[0]}-#{ii[1]}" },
73
+ fb: @fb, fid: @fid
52
74
  )
53
75
  end
54
76
 
55
77
  # Is it there?
56
78
  # @param [String] where The place, e.g. "github"
57
79
  # @param [Integer] repo ID of repository
58
- # @param [Integer] issue ID of issue (or array of them)
80
+ # @param [Integer, Array<Integer>] issue ID of issue (or array of them)
59
81
  # @return [Boolean] True if it's there
60
82
  def has?(where, repo, issue)
83
+ raise 'The type of "where" is not String' unless where.is_a?(String)
84
+ raise 'The type of "repo" is not Integer' unless repo.is_a?(Integer)
85
+ raise 'The type of "issue" is neither Integer nor Array' unless issue.is_a?(Integer) || issue.is_a?(Array)
61
86
  f = @fb.query(
62
87
  "(and (eq where '#{where}') (eq what 'tombstone') (eq repository #{repo}) (exists issues))"
63
88
  ).each.first
data/lib/fbe.rb CHANGED
@@ -10,5 +10,5 @@
10
10
  # License:: MIT
11
11
  module Fbe
12
12
  # Current version of the gem (changed by +.rultor.yml+ on every release)
13
- VERSION = '0.41.6' unless const_defined?(:VERSION)
13
+ VERSION = '0.43.0' unless const_defined?(:VERSION)
14
14
  end
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.41.6
4
+ version: 0.43.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -375,6 +375,7 @@ files:
375
375
  - assets/bylaws/published-release-was-rewarded.fe.liquid
376
376
  - assets/bylaws/push-to-master-was-punished.fe.liquid
377
377
  - assets/bylaws/resolved-bug-was-rewarded.fe.liquid
378
+ - assets/pmp.xml
378
379
  - fbe.gemspec
379
380
  - lib/fbe.rb
380
381
  - lib/fbe/award.rb