fbe 0.7.1 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1ce252b4d0093ff1f94e319d2c65502e134dad520398ca018fad1820b9dac78
4
- data.tar.gz: f0039a70dcd2533e2acd36f80b7ef3ac68441f1f68611b38ee07d9c67449ddf3
3
+ metadata.gz: 3828337a178cb00363cfde7328b72d719e412861b1faeedeacbfa90ecdf55f01
4
+ data.tar.gz: 13e04faef8302ce164266d19cf5b54d9876376500c113a692467c30bde96345e
5
5
  SHA512:
6
- metadata.gz: 25191aefeccb723456f4de449c6f042ce628c895fc7f2e941f5e63e0685bfb2bccf550e04c288ff28e288acf8a4c0b57f3402b2826cae5ccb5da549c977f1ffe
7
- data.tar.gz: 6362777ada12c805d463db462afbfbf5bab5d20b897565b798c2ede567d097f3250622d1a67656731e94f0ac8fc37fb604ace94c150e51e47c2a83ec14f4be60
6
+ metadata.gz: 7f35b12b769b206e111a63de0575f673be0c8514c42b3b90b33009a65529d8572f98d173d6c18dce29e8edd231afb7cd890c8dbe17af1b2e58733e7359453e73
7
+ data.tar.gz: 1743b4a1fe9deb57b39763f666683eb51ea6878fd56b86bc99fe1189c4fa58fcb42762b8e6f14cb7b0fd4256aca858824b8ca4ca6c0a7238d4f547c80d673b45
@@ -51,19 +51,6 @@
51
51
  (give bonus_for_comments "for too many (${comments}) comments that were made during review")
52
52
  "deduct ${comments_k} points for every comment made during review, but not more than ${comments_max} points")
53
53
 
54
- (aka
55
- (let few_comments_fee {{ 2 | times: anger }})
56
- (let comments_needed {{ 3 | times: paranoia }})
57
- (set penalty_for_few_comments (if (and (lt comments comments_needed) (not (eq comments 0))) (times -1 few_comments_fee) 0))
58
- (give penalty_for_few_comments "for very few (${comments}) comments")
59
- "deduct ${few_comments_fee} points if there were less than ${comments_needed} comments made during review")
60
-
61
- (aka
62
- (let silence_fee {{ 8 | times: anger }})
63
- (set penalty_for_silence (if (eq comments 0) (times -1 silence_fee) 0))
64
- (give penalty_for_silence "for absolutely no comments posted by reviewers")
65
- "deduct ${silence_fee} points if there were absolutely no comments made by reviewers during the review")
66
-
67
54
  (aka
68
55
  (let few_hoc_fee {{ 4 | times: anger }})
69
56
  (let hoc_needed {{ 10 | times: paranoia }})
data/lib/fbe/conclude.rb CHANGED
@@ -18,6 +18,11 @@ require_relative 'if_absent'
18
18
  # @param [Loog] loog The logging facility
19
19
  # @yield [Factbase::Fact] The fact
20
20
  def Fbe.conclude(fb: Fbe.fb, judge: $judge, loog: $loog, options: $options, global: $global, &)
21
+ raise 'The fb is nil' if fb.nil?
22
+ raise 'The $judge is not set' if judge.nil?
23
+ raise 'The $global is not set' if global.nil?
24
+ raise 'The $options is not set' if options.nil?
25
+ raise 'The $loog is not set' if loog.nil?
21
26
  c = Fbe::Conclude.new(fb:, judge:, loog:, options:, global:)
22
27
  c.instance_eval(&)
23
28
  end
data/lib/fbe/enter.rb CHANGED
@@ -14,6 +14,10 @@ require_relative '../fbe'
14
14
  # @param [Loog] loog The logging facility
15
15
  # @return [String] Full name of the user
16
16
  def Fbe.enter(badge, why, options: $options, loog: $loog, &)
17
+ raise 'The badge is nil' if badge.nil?
18
+ raise 'The why is nil' if why.nil?
19
+ raise 'The $options is not set' if options.nil?
20
+ raise 'The $loog is not set' if loog.nil?
17
21
  return yield unless options.testing.nil?
18
22
  baza = BazaRb.new('api.zerocracy.com', 443, options.zerocracy_token, loog:)
19
23
  baza.enter(options.job_name, badge, why, options.job_id.to_i, &)
data/lib/fbe/fb.rb CHANGED
@@ -26,6 +26,10 @@ require_relative '../fbe'
26
26
  # @param [Loog] loog The logging facility
27
27
  # @return [Factbase] The global factbase
28
28
  def Fbe.fb(fb: $fb, global: $global, options: $options, loog: $loog)
29
+ raise 'The fb is nil' if fb.nil?
30
+ raise 'The $global is not set' if global.nil?
31
+ raise 'The $options is not set' if options.nil?
32
+ raise 'The $loog is not set' if loog.nil?
29
33
  global[:fb] ||=
30
34
  begin
31
35
  rules = Dir.glob(File.join('rules', '*.fe')).map { |f| File.read(f) }
data/lib/fbe/issue.rb CHANGED
@@ -19,6 +19,10 @@ require_relative 'octo'
19
19
  # @param [Loog] loog The logging facility
20
20
  # @return [String] Textual representation of GitHub issue number
21
21
  def Fbe.issue(fact, options: $options, global: $global, loog: $loog)
22
+ raise 'The fact is nil' if fact.nil?
23
+ raise 'The $global is not set' if global.nil?
24
+ raise 'The $options is not set' if options.nil?
25
+ raise 'The $loog is not set' if loog.nil?
22
26
  rid = fact['repository']
23
27
  raise "There is no 'repository' property" if rid.nil?
24
28
  rid = rid.first.to_i
data/lib/fbe/iterate.rb CHANGED
@@ -18,6 +18,10 @@ require_relative 'unmask_repos'
18
18
  # @param [Loog] loog The logging facility
19
19
  # @yield [Factbase::Fact] The fact
20
20
  def Fbe.iterate(fb: Fbe.fb, loog: $loog, options: $options, global: $global, &)
21
+ raise 'The fb is nil' if fb.nil?
22
+ raise 'The $global is not set' if global.nil?
23
+ raise 'The $options is not set' if options.nil?
24
+ raise 'The $loog is not set' if loog.nil?
21
25
  c = Fbe::Iterate.new(fb:, loog:, options:, global:)
22
26
  c.instance_eval(&)
23
27
  end
data/lib/fbe/octo.rb CHANGED
@@ -26,6 +26,8 @@ require_relative 'middleware/formatter'
26
26
  # @return [Hash] Usually returns a JSON, as it comes from the GitHub API
27
27
  def Fbe.octo(options: $options, global: $global, loog: $loog)
28
28
  raise 'The $global is not set' if global.nil?
29
+ raise 'The $options is not set' if options.nil?
30
+ raise 'The $loog is not set' if loog.nil?
29
31
  global[:octo] ||=
30
32
  begin
31
33
  if options.testing.nil?
@@ -94,13 +96,16 @@ def Fbe.octo(options: $options, global: $global, loog: $loog)
94
96
  end
95
97
 
96
98
  def user_name_by_id(id)
99
+ raise 'The ID of the user is nil' if id.nil?
100
+ raise 'The ID of the user must be an Integer' unless id.is_a?(Integer)
97
101
  json = @origin.user(id)
98
- name = json[:login]
102
+ name = json[:login].downcase
99
103
  @loog.debug("GitHub user ##{id} has a name: @#{name}")
100
104
  name
101
105
  end
102
106
 
103
107
  def repo_id_by_name(name)
108
+ raise 'The name of the repo is nil' if name.nil?
104
109
  json = @origin.repository(name)
105
110
  id = json[:id]
106
111
  @loog.debug("GitHub repository #{name.inspect} has an ID: ##{id}")
@@ -108,8 +113,10 @@ def Fbe.octo(options: $options, global: $global, loog: $loog)
108
113
  end
109
114
 
110
115
  def repo_name_by_id(id)
116
+ raise 'The ID of the repo is nil' if id.nil?
117
+ raise 'The ID of the repo must be an Integer' unless id.is_a?(Integer)
111
118
  json = @origin.repository(id)
112
- name = json[:full_name]
119
+ name = json[:full_name].downcase
113
120
  @loog.debug("GitHub repository ##{id} has a name: #{name}")
114
121
  name
115
122
  end
data/lib/fbe/overwrite.rb CHANGED
@@ -21,6 +21,7 @@ require_relative 'fb'
21
21
  # @return [Factbase::Fact] Returns new fact or previous one
22
22
  def Fbe.overwrite(fact, property, value, fb: Fbe.fb)
23
23
  raise 'The fact is nil' if fact.nil?
24
+ raise 'The fb is nil' if fb.nil?
24
25
  raise "The property is not a String but #{property.class} (#{property})" unless property.is_a?(String)
25
26
  return fact if !fact[property].nil? && fact[property].size == 1 && fact[property].first == value
26
27
  before = {}
data/lib/fbe/regularly.rb CHANGED
@@ -16,6 +16,11 @@ require_relative 'fb'
16
16
  # @param [Loog] loog The logging facility
17
17
  # @return [nil] Nothing
18
18
  def Fbe.regularly(area, p_every_days, p_since_days = nil, fb: Fbe.fb, judge: $judge, loog: $loog, &)
19
+ raise 'The area is nil' if area.nil?
20
+ raise 'The p_every_days is nil' if p_every_days.nil?
21
+ raise 'The fb is nil' if fb.nil?
22
+ raise 'The $judge is not set' if judge.nil?
23
+ raise 'The $loog is not set' if loog.nil?
19
24
  pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_days}))").each.to_a.first
20
25
  interval = pmp.nil? ? 7 : pmp[p_every_days].first
21
26
  unless fb.query(
@@ -16,6 +16,11 @@ require_relative 'overwrite'
16
16
  # @param [Loog] loog The logging facility
17
17
  # @return [nil] Nothing
18
18
  def Fbe.repeatedly(area, p_every_hours, fb: Fbe.fb, judge: $judge, loog: $loog, &)
19
+ raise 'The area is nil' if area.nil?
20
+ raise 'The p_every_hours is nil' if p_every_hours.nil?
21
+ raise 'The fb is nil' if fb.nil?
22
+ raise 'The $judge is not set' if judge.nil?
23
+ raise 'The $loog is not set' if loog.nil?
19
24
  pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_hours}))").each.to_a.first
20
25
  hours = pmp.nil? ? 24 : pmp[p_every_hours].first
21
26
  unless fb.query(
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.7.1' unless const_defined?(:VERSION)
13
+ VERSION = '0.8.1' unless const_defined?(:VERSION)
14
14
  end
@@ -61,7 +61,7 @@ class TestBylaws < Fbe::Test
61
61
  { hoc: 50, comments: 25, reviews: 0 } => 4,
62
62
  { hoc: 180, comments: 7, reviews: 2 } => 13,
63
63
  { hoc: 199, comments: 8, reviews: 3 } => 14,
64
- { hoc: 150, comments: 5, reviews: 1 } => 8,
64
+ { hoc: 150, comments: 5, reviews: 1 } => 12,
65
65
  { hoc: 500, comments: 25, reviews: 2 } => 4,
66
66
  { hoc: 99, comments: 6, reviews: 1 } => 4,
67
67
  { hoc: 1_500, comments: 3, reviews: 0 } => 4,
@@ -51,6 +51,28 @@ class TestOcto < Fbe::Test
51
51
  assert_equal(100, o.rate_limit.remaining)
52
52
  end
53
53
 
54
+ def test_reads_nickname_by_id
55
+ WebMock.disable_net_connect!
56
+ global = {}
57
+ o = Fbe.octo(loog: Loog::NULL, global:, options: Judges::Options.new)
58
+ stub_request(:get, 'https://api.github.com/user/42').to_return(
59
+ body: { login: 'Dude56' }.to_json, headers: { 'Content-Type': 'application/json' }
60
+ )
61
+ nick = o.user_name_by_id(42)
62
+ assert_equal('dude56', nick)
63
+ end
64
+
65
+ def test_reads_repo_name_by_id
66
+ WebMock.disable_net_connect!
67
+ global = {}
68
+ o = Fbe.octo(loog: Loog::NULL, global:, options: Judges::Options.new)
69
+ stub_request(:get, 'https://api.github.com/repositories/42').to_return(
70
+ body: { full_name: 'Foo/bar56-Ff' }.to_json, headers: { 'Content-Type': 'application/json' }
71
+ )
72
+ nick = o.repo_name_by_id(42)
73
+ assert_equal('foo/bar56-ff', nick)
74
+ end
75
+
54
76
  def test_caching
55
77
  WebMock.disable_net_connect!
56
78
  global = {}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-16 00:00:00.000000000 Z
10
+ date: 2025-04-18 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: backtrace