fbe 0.33.0 → 0.34.1
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 +4 -4
- data/Gemfile.lock +2 -2
- data/assets/bylaws/{code-contribution-was-rewarded.liquid → code-contribution-was-rewarded.fe.liquid} +3 -7
- data/lib/fbe/bylaws.rb +2 -2
- data/lib/fbe/consider.rb +28 -0
- data/lib/fbe/delete.rb +1 -0
- data/lib/fbe/overwrite.rb +12 -4
- data/lib/fbe.rb +1 -1
- metadata +12 -11
- /data/assets/bylaws/{bad-branch-name-was-punished.liquid → bad-branch-name-was-punished.fe.liquid} +0 -0
- /data/assets/bylaws/{bug-report-was-rewarded.liquid → bug-report-was-rewarded.fe.liquid} +0 -0
- /data/assets/bylaws/{code-review-was-rewarded.liquid → code-review-was-rewarded.fe.liquid} +0 -0
- /data/assets/bylaws/{dud-was-punished.liquid → dud-was-punished.fe.liquid} +0 -0
- /data/assets/bylaws/{enhancement-suggestion-was-rewarded.liquid → enhancement-suggestion-was-rewarded.fe.liquid} +0 -0
- /data/assets/bylaws/{long-pull-was-punished.liquid → long-pull-was-punished.fe.liquid} +0 -0
- /data/assets/bylaws/{published-release-was-rewarded.liquid → published-release-was-rewarded.fe.liquid} +0 -0
- /data/assets/bylaws/{push-to-master-was-punished.liquid → push-to-master-was-punished.fe.liquid} +0 -0
- /data/assets/bylaws/{resolved-bug-was-rewarded.liquid → resolved-bug-was-rewarded.fe.liquid} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6640546ac78327c9198d84ead54ecb48c08706f015d487ac5ee1e68a33012579
|
4
|
+
data.tar.gz: 4257c989c9af1be8e8c45755df5c182c1feef2eb9e8247578239e08d08d6c175
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3eef26c76c8a03ec95fc92a18ede1fa53a1fb3c89e189d7694d6175ab742750414c437cde293c342c30c2cf82db519119e801eade81fbaa4fb806aeced6ece0f
|
7
|
+
data.tar.gz: 48e608695735e4ffe0af617394b236bb2b82507c7504617a8a810256a6aa74aecb5851d7e72f64e868764461e7331f9744fff2b339e8b8d5a8cce96297b74288
|
data/Gemfile.lock
CHANGED
@@ -76,7 +76,7 @@ GEM
|
|
76
76
|
ellipsized (0.3.0)
|
77
77
|
ethon (0.15.0)
|
78
78
|
ffi (>= 1.15.0)
|
79
|
-
factbase (0.16.
|
79
|
+
factbase (0.16.2)
|
80
80
|
backtrace (~> 0.4)
|
81
81
|
decoor (~> 0.1)
|
82
82
|
ellipsized (~> 0.3)
|
@@ -188,7 +188,7 @@ GEM
|
|
188
188
|
rake (13.3.0)
|
189
189
|
regexp_parser (2.11.2)
|
190
190
|
retries (0.0.5)
|
191
|
-
rexml (3.4.
|
191
|
+
rexml (3.4.3)
|
192
192
|
rubocop (1.80.2)
|
193
193
|
json (~> 2.3)
|
194
194
|
language_server-protocol (~> 3.17.0.2)
|
@@ -17,24 +17,20 @@
|
|
17
17
|
(set bonus_for_hoc (if (lt hoc hoc_threshold) (times hoc hoc_k) 0))
|
18
18
|
(set bonus_for_hoc (between bonus_for_hoc hoc_min hoc_max))
|
19
19
|
(give bonus_for_hoc "for the ${hoc} hits-of-code that you wrote")
|
20
|
-
"add ${hoc_k} points for each
|
21
|
-
[hit-of-code](https://www.yegor256.com/2014/11/14/hits-of-code.html),
|
22
|
-
but not more than ${hoc_max} points")
|
20
|
+
"add ${hoc_k} points for each [hit-of-code](https://www.yegor256.com/2014/11/14/hits-of-code.html), but not more than ${hoc_max} points")
|
23
21
|
|
24
22
|
(aka
|
25
23
|
(let many_hoc_fee {{ 4 | times: anger }})
|
26
24
|
(set penalty_for_hoc (if (gte hoc hoc_threshold) (times -1 many_hoc_fee) 0))
|
27
25
|
(give penalty_for_hoc "for too many hits-of-code (${hoc} >= ${hoc_threshold})")
|
28
|
-
"deduct ${many_hoc_fee} points if more than ${hoc_threshold}
|
29
|
-
[hits-of-code](https://www.yegor256.com/2014/11/14/hits-of-code.html)")
|
26
|
+
"deduct ${many_hoc_fee} points if more than ${hoc_threshold} [hits-of-code](https://www.yegor256.com/2014/11/14/hits-of-code.html)")
|
30
27
|
|
31
28
|
(aka
|
32
29
|
(let many_hoc_fee2 {{ 8 | times: anger }})
|
33
30
|
(let hoc_threshold2 {{ 1600 | divided_by: paranoia }})
|
34
31
|
(set penalty_for_hoc2 (if (gte hoc hoc_threshold2) (times -1 many_hoc_fee2) 0))
|
35
32
|
(give penalty_for_hoc2 "for way too many hits-of-code (${hoc} >= ${hoc_threshold2})")
|
36
|
-
"deduct ${many_hoc_fee2} points if more than ${hoc_threshold2}
|
37
|
-
[hits-of-code](https://www.yegor256.com/2014/11/14/hits-of-code.html)")
|
33
|
+
"deduct ${many_hoc_fee2} points if more than ${hoc_threshold2} [hits-of-code](https://www.yegor256.com/2014/11/14/hits-of-code.html)")
|
38
34
|
|
39
35
|
(aka
|
40
36
|
(let no_review_fee {{ 8 | times: anger }})
|
data/lib/fbe/bylaws.rb
CHANGED
@@ -41,10 +41,10 @@ def Fbe.bylaws(anger: 2, love: 2, paranoia: 2)
|
|
41
41
|
raise "The 'paranoia' must be in the [1..4] interval: #{paranoia.inspect}" unless paranoia.positive? && paranoia < 5
|
42
42
|
home = File.join(__dir__, '../../assets/bylaws')
|
43
43
|
raise "The directory with templates is absent #{home.inspect}" unless File.exist?(home)
|
44
|
-
Dir[File.join(home, '*.liquid')].to_h do |f|
|
44
|
+
Dir[File.join(home, '*.fe.liquid')].to_h do |f|
|
45
45
|
formula = Liquid::Template.parse(File.read(f)).render(
|
46
46
|
'anger' => anger, 'love' => love, 'paranoia' => paranoia
|
47
47
|
)
|
48
|
-
[File.basename(f).gsub(/\.liquid$/, ''), formula]
|
48
|
+
[File.basename(f).gsub(/\.fe.liquid$/, ''), formula]
|
49
49
|
end
|
50
50
|
end
|
data/lib/fbe/consider.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
|
4
|
+
# SPDX-License-Identifier: MIT
|
5
|
+
|
6
|
+
require_relative '../fbe'
|
7
|
+
require_relative 'conclude'
|
8
|
+
require_relative 'fb'
|
9
|
+
|
10
|
+
# Creates an instance of {Fbe::Conclude} and then runs "consider" in it.
|
11
|
+
#
|
12
|
+
# @param [String] query The query
|
13
|
+
# @param [Factbase] fb The factbase
|
14
|
+
# @param [String] judge The name of the judge, from the +judges+ tool
|
15
|
+
# @param [Hash] global The hash for global caching
|
16
|
+
# @param [Judges::Options] options The options coming from the +judges+ tool
|
17
|
+
# @param [Loog] loog The logging facility
|
18
|
+
# @yield [Factbase::Fact] The fact
|
19
|
+
def Fbe.consider(
|
20
|
+
query,
|
21
|
+
fb: Fbe.fb, judge: $judge, loog: $loog, options: $options, global: $global,
|
22
|
+
start: $start, &
|
23
|
+
)
|
24
|
+
Fbe.conclude(fb:, judge:, loog:, options:, global:, start:) do
|
25
|
+
on query
|
26
|
+
consider(&)
|
27
|
+
end
|
28
|
+
end
|
data/lib/fbe/delete.rb
CHANGED
@@ -24,6 +24,7 @@ require_relative 'fb'
|
|
24
24
|
# # new_fact will have all properties except 'age' and 'city'
|
25
25
|
def Fbe.delete(fact, *props, fb: Fbe.fb, id: '_id')
|
26
26
|
raise 'The fact is nil' if fact.nil?
|
27
|
+
return if props.all? { |k| fact[k].nil? }
|
27
28
|
i = fact[id]
|
28
29
|
raise "There is no #{id.inspect} in the fact" if i.nil?
|
29
30
|
i = i.first
|
data/lib/fbe/overwrite.rb
CHANGED
@@ -17,7 +17,7 @@ require_relative 'fb'
|
|
17
17
|
#
|
18
18
|
# @param [Factbase::Fact] fact The fact to modify (must have _id property)
|
19
19
|
# @param [String] property The name of the property to set
|
20
|
-
# @param [Any]
|
20
|
+
# @param [Any] values The value to set (can be any type, including array)
|
21
21
|
# @param [Factbase] fb The factbase to use (defaults to Fbe.fb)
|
22
22
|
# @return [nil] Nothing
|
23
23
|
# @raise [RuntimeError] If fact is nil, has no _id, or property is not a String
|
@@ -27,11 +27,19 @@ require_relative 'fb'
|
|
27
27
|
# user = fb.query('(eq login "john")').first
|
28
28
|
# updated_user = Fbe.overwrite(user, 'status', 'active')
|
29
29
|
# # All properties preserved, only 'status' is set to 'active'
|
30
|
-
def Fbe.overwrite(fact, property,
|
30
|
+
def Fbe.overwrite(fact, property, values, fb: Fbe.fb, fid: '_id')
|
31
31
|
raise 'The fact is nil' if fact.nil?
|
32
32
|
raise 'The fb is nil' if fb.nil?
|
33
33
|
raise "The property is not a String but #{property.class} (#{property})" unless property.is_a?(String)
|
34
|
-
|
34
|
+
raise 'The values is nil' if values.nil?
|
35
|
+
values = [values] unless values.is_a?(Array)
|
36
|
+
return fact if !fact[property].nil? && fact[property].one? && values.one? && fact[property].first == values.first
|
37
|
+
if fact[property].nil?
|
38
|
+
values.each do |v|
|
39
|
+
fact.send(:"#{property}=", v)
|
40
|
+
end
|
41
|
+
return
|
42
|
+
end
|
35
43
|
before = {}
|
36
44
|
fact.all_properties.each do |prop|
|
37
45
|
before[prop.to_s] = fact[prop]
|
@@ -41,7 +49,7 @@ def Fbe.overwrite(fact, property, value, fb: Fbe.fb, fid: '_id')
|
|
41
49
|
raise "No facts by #{fid} = #{id}" if fb.query("(eq #{fid} #{id})").delete!.zero?
|
42
50
|
fb.txn do |fbt|
|
43
51
|
n = fbt.insert
|
44
|
-
before[property.to_s] =
|
52
|
+
before[property.to_s] = values
|
45
53
|
before.each do |k, vv|
|
46
54
|
next unless n[k].nil?
|
47
55
|
vv.each do |v|
|
data/lib/fbe.rb
CHANGED
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.
|
4
|
+
version: 0.34.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
@@ -351,21 +351,22 @@ files:
|
|
351
351
|
- README.md
|
352
352
|
- REUSE.toml
|
353
353
|
- Rakefile
|
354
|
-
- assets/bylaws/bad-branch-name-was-punished.liquid
|
355
|
-
- assets/bylaws/bug-report-was-rewarded.liquid
|
356
|
-
- assets/bylaws/code-contribution-was-rewarded.liquid
|
357
|
-
- assets/bylaws/code-review-was-rewarded.liquid
|
358
|
-
- assets/bylaws/dud-was-punished.liquid
|
359
|
-
- assets/bylaws/enhancement-suggestion-was-rewarded.liquid
|
360
|
-
- assets/bylaws/long-pull-was-punished.liquid
|
361
|
-
- assets/bylaws/published-release-was-rewarded.liquid
|
362
|
-
- assets/bylaws/push-to-master-was-punished.liquid
|
363
|
-
- assets/bylaws/resolved-bug-was-rewarded.liquid
|
354
|
+
- assets/bylaws/bad-branch-name-was-punished.fe.liquid
|
355
|
+
- assets/bylaws/bug-report-was-rewarded.fe.liquid
|
356
|
+
- assets/bylaws/code-contribution-was-rewarded.fe.liquid
|
357
|
+
- assets/bylaws/code-review-was-rewarded.fe.liquid
|
358
|
+
- assets/bylaws/dud-was-punished.fe.liquid
|
359
|
+
- assets/bylaws/enhancement-suggestion-was-rewarded.fe.liquid
|
360
|
+
- assets/bylaws/long-pull-was-punished.fe.liquid
|
361
|
+
- assets/bylaws/published-release-was-rewarded.fe.liquid
|
362
|
+
- assets/bylaws/push-to-master-was-punished.fe.liquid
|
363
|
+
- assets/bylaws/resolved-bug-was-rewarded.fe.liquid
|
364
364
|
- fbe.gemspec
|
365
365
|
- lib/fbe.rb
|
366
366
|
- lib/fbe/award.rb
|
367
367
|
- lib/fbe/bylaws.rb
|
368
368
|
- lib/fbe/conclude.rb
|
369
|
+
- lib/fbe/consider.rb
|
369
370
|
- lib/fbe/copy.rb
|
370
371
|
- lib/fbe/delete.rb
|
371
372
|
- lib/fbe/delete_one.rb
|
/data/assets/bylaws/{bad-branch-name-was-punished.liquid → bad-branch-name-was-punished.fe.liquid}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
/data/assets/bylaws/{push-to-master-was-punished.liquid → push-to-master-was-punished.fe.liquid}
RENAMED
File without changes
|
/data/assets/bylaws/{resolved-bug-was-rewarded.liquid → resolved-bug-was-rewarded.fe.liquid}
RENAMED
File without changes
|