fbe 0.34.3 → 0.35.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: 00c5ad7eee72d3b169a32b886cd91d31e370fb7cf27cfe7021dedc1e879e6d08
4
- data.tar.gz: 330fbee020ff69bee3b31df9716fa255ca9f2d2a33109ebd1617cc0c9f2b121d
3
+ metadata.gz: 3bddbb890f6001c0df689c40caf9803218154009f27a5510be94599b874d218b
4
+ data.tar.gz: 2f202ab71bd13a341d545889be0e54daa2a4cc512af81607d12c5e26267eb147
5
5
  SHA512:
6
- metadata.gz: 12ac3511a088d3cf3cdd4075dcc6a49a07151e1ac004c51b4f9e3175ae098b40286643ae58b4e37f4d326e3357f38ba21c0834fe89f8f27fc83a2f35da173e6b
7
- data.tar.gz: 51ad480ea0c4146155556e017536af6b99ae11631283fb4929ec92b2b81cf632cceab477c798cabf237d9a6d31730db15f005eb7a86b8b5fd94bf6bf97665083
6
+ metadata.gz: e22ef6d4ca2d1235418d6b6bcea3a317a962b1dc0b5ac4841becd708df6cd41f838178d08ebd74bb08e25a8cf7f597ca3a9378d4a71cc945f26fe8a8da05a4a0
7
+ data.tar.gz: 2a771ac3b0ecd1eb64aae745518cac12adb5f5cb24f548829c74b4961856f51d2fa01e5a2fb4c841ba706d664b58740793da621b22a9f7408bc0da769ab843a2
data/Gemfile.lock CHANGED
@@ -47,9 +47,9 @@ GEM
47
47
  ast (2.4.3)
48
48
  backtrace (0.4.1)
49
49
  base64 (0.3.0)
50
- baza.rb (0.10.1)
50
+ baza.rb (0.10.2)
51
51
  backtrace (~> 0.4)
52
- elapsed (~> 0.0)
52
+ elapsed (~> 0.2)
53
53
  faraday (~> 2.13)
54
54
  faraday-http-cache (~> 2.5)
55
55
  faraday-multipart (~> 1.1)
@@ -57,7 +57,7 @@ GEM
57
57
  iri (~> 0.11)
58
58
  loog (~> 0.6)
59
59
  retries (~> 0.0)
60
- tago (~> 0.0)
60
+ tago (~> 0.2)
61
61
  typhoeus (~> 1.4)
62
62
  benchmark (0.4.1)
63
63
  bigdecimal (3.2.3)
@@ -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.2)
79
+ factbase (0.16.4)
80
80
  backtrace (~> 0.4)
81
81
  decoor (~> 0.1)
82
82
  ellipsized (~> 0.3)
@@ -121,7 +121,7 @@ GEM
121
121
  iri (0.11.2)
122
122
  joined (0.4.0)
123
123
  json (2.13.2)
124
- judges (0.53.6)
124
+ judges (0.53.8)
125
125
  backtrace (~> 0.4)
126
126
  baza.rb (~> 0.5)
127
127
  concurrent-ruby (~> 1.2)
@@ -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.3)
191
+ rexml (3.4.4)
192
192
  rubocop (1.80.2)
193
193
  json (~> 2.3)
194
194
  language_server-protocol (~> 3.17.0.2)
@@ -240,9 +240,9 @@ GEM
240
240
  ethon (>= 0.9.0, < 0.16.0)
241
241
  tzinfo (2.0.6)
242
242
  concurrent-ruby (~> 1.0)
243
- unicode-display_width (3.1.5)
244
- unicode-emoji (~> 4.0, >= 4.0.4)
245
- unicode-emoji (4.0.4)
243
+ unicode-display_width (3.2.0)
244
+ unicode-emoji (~> 4.1)
245
+ unicode-emoji (4.1.0)
246
246
  uri (1.0.3)
247
247
  veils (0.4.0)
248
248
  verbose (0.1.0)
data/lib/fbe/just_one.rb CHANGED
@@ -54,7 +54,7 @@ def Fbe.just_one(fb: Fbe.fb)
54
54
  "(eq #{k} #{vv})"
55
55
  end.join(' ')
56
56
  q = "(and #{q})"
57
- before = fb.query(q).each.to_a.first
57
+ before = fb.query(q).each.first
58
58
  return before unless before.nil?
59
59
  n = fb.insert
60
60
  attrs.each { |k, v| n.send(:"#{k}=", v) }
data/lib/fbe/octo.rb CHANGED
@@ -198,6 +198,24 @@ def Fbe.octo(options: $options, global: $global, loog: $loog)
198
198
  @loog.debug("GitHub repository ##{id} has a name: #{name}")
199
199
  name
200
200
  end
201
+
202
+ # Disable auto pagination for octokit client called in block
203
+ #
204
+ # @yield [octo] Give octokit client with disabled auto pagination
205
+ # @yieldparam [Octokit::Client, Fbe::FakeOctokit] Octokit client
206
+ # @return [Object] Last value in block
207
+ # @example
208
+ # issue =
209
+ # Fbe.octo.with_disable_auto_paginate do |octo|
210
+ # octo.list_issue('zerocracy/fbe', per_page: 1).first
211
+ # end
212
+ def with_disable_auto_paginate
213
+ ap = @origin.auto_paginate
214
+ @origin.auto_paginate = false
215
+ yield self if block_given?
216
+ ensure
217
+ @origin.auto_paginate = ap
218
+ end
201
219
  end
202
220
  o =
203
221
  intercepted(o) do |e, m, _args, _r|
@@ -251,6 +269,10 @@ class Fbe::FakeOctokit
251
269
  name.chars.sum(&:ord)
252
270
  end
253
271
 
272
+ def auto_paginate=(_); end
273
+
274
+ def auto_paginate; end
275
+
254
276
  # Returns a mock rate limit object.
255
277
  #
256
278
  # @return [Object] An object with a remaining method that returns 100
@@ -588,6 +610,7 @@ class Fbe::FakeOctokit
588
610
  raise Octokit::NotFound if [404_123, 404_124].include?(name)
589
611
  full_name = name.is_a?(Integer) ? 'yegor256/test' : name
590
612
  full_name = 'zerocracy/baza' if name == 1439
613
+ full_name = 'foo/bazz' if name == 810
591
614
  {
592
615
  id: name_to_number(name),
593
616
  full_name:,
@@ -651,7 +674,9 @@ class Fbe::FakeOctokit
651
674
  [
652
675
  issue(repo, 42),
653
676
  issue(repo, 43)
654
- ]
677
+ ].tap do |list|
678
+ list.prepend(issue(repo, 144)) if repo == 'foo/bazz'
679
+ end
655
680
  end
656
681
 
657
682
  # Gets a single issue.
@@ -663,7 +688,8 @@ class Fbe::FakeOctokit
663
688
  # client.issue('octocat/Hello-World', 42)
664
689
  # # => {:id=>42, :number=>42, :created_at=>...}
665
690
  def issue(repo, number)
666
- if number == 142
691
+ case number
692
+ when 142
667
693
  {
668
694
  id: 655,
669
695
  number:,
@@ -675,7 +701,7 @@ class Fbe::FakeOctokit
675
701
  closed_at: Time.parse('2025-06-02 15:00:00 UTC'),
676
702
  closed_by: { id: 526_301, login: 'yegor256' }
677
703
  }
678
- elsif number == 143
704
+ when 143
679
705
  {
680
706
  id: 656,
681
707
  number:,
@@ -688,6 +714,15 @@ class Fbe::FakeOctokit
688
714
  closed_at: Time.parse('2025-06-01 18:20:00 UTC'),
689
715
  closed_by: { id: 526_301, login: 'yegor256' }
690
716
  }
717
+ when 144
718
+ {
719
+ id: 657,
720
+ number:,
721
+ repo: { full_name: repo },
722
+ user: { login: 'yegor256', id: 526_301, type: 'User' },
723
+ pull_request: { merged_at: nil },
724
+ created_at: Time.parse('2025-05-29 17:00:55 UTC')
725
+ }
691
726
  else
692
727
  {
693
728
  id: 42,
data/lib/fbe/pmp.rb CHANGED
@@ -48,7 +48,7 @@ def Fbe.pmp(fb: Fbe.fb, global: $global, options: $options, loog: $loog)
48
48
  end
49
49
  others do |*args2|
50
50
  param = args2.first
51
- f = Fbe.fb(global:, fb:, options:, loog:).query("(and (eq what 'pmp') (eq area '#{area}'))").each.to_a.first
51
+ f = Fbe.fb(global:, fb:, options:, loog:).query("(and (eq what 'pmp') (eq area '#{area}'))").each.first
52
52
  raise "Unknown area #{area.inspect}" if f.nil?
53
53
  r = f[param]
54
54
  raise "Unknown property #{param.inspect} in the #{area.inspect} area" if r.nil?
data/lib/fbe/regularly.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
+ require 'tago'
6
7
  require_relative '../fbe'
7
8
  require_relative 'fb'
8
9
 
@@ -34,14 +35,18 @@ def Fbe.regularly(area, p_every_days, p_since_days = nil, fb: Fbe.fb, judge: $ju
34
35
  raise 'The fb is nil' if fb.nil?
35
36
  raise 'The $judge is not set' if judge.nil?
36
37
  raise 'The $loog is not set' if loog.nil?
37
- pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_days}))").each.to_a.first
38
+ pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_days}))").each.first
38
39
  interval = pmp.nil? ? 7 : pmp[p_every_days].first
39
- unless fb.query(
40
+ recent = fb.query(
40
41
  "(and
41
42
  (eq what '#{judge}')
42
43
  (gt when (minus (to_time (env 'TODAY' '#{Time.now.utc.iso8601}')) '#{interval} days')))"
43
- ).each.to_a.empty?
44
- loog.debug("#{$judge} statistics have recently been collected, skipping now")
44
+ ).each.first
45
+ if recent
46
+ loog.debug(
47
+ "#{$judge} statistics were collected #{recent.when.ago} ago, " \
48
+ "skipping now (we run it every #{interval} days)"
49
+ )
45
50
  return
46
51
  end
47
52
  fb.txn do |fbt|
@@ -3,6 +3,7 @@
3
3
  # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
+ require 'tago'
6
7
  require_relative '../fbe'
7
8
  require_relative 'fb'
8
9
  require_relative 'overwrite'
@@ -36,22 +37,23 @@ def Fbe.repeatedly(area, p_every_hours, fb: Fbe.fb, judge: $judge, loog: $loog,
36
37
  raise 'The fb is nil' if fb.nil?
37
38
  raise 'The $judge is not set' if judge.nil?
38
39
  raise 'The $loog is not set' if loog.nil?
39
- pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_hours}))").each.to_a.first
40
+ pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_hours}))").each.first
40
41
  hours = pmp.nil? ? 24 : pmp[p_every_hours].first
41
- unless fb.query(
42
+ recent = fb.query(
42
43
  "(and
43
44
  (eq what '#{judge}')
44
45
  (gt when (minus (to_time (env 'TODAY' '#{Time.now.utc.iso8601}')) '#{hours} hours')))"
45
- ).each.to_a.empty?
46
- loog.debug("#{$judge} has recently been executed, skipping now")
46
+ ).each.first
47
+ if recent
48
+ loog.info("#{$judge} was executed #{recent.when.ago} ago, skipping now (we run it every #{hours} hours)")
47
49
  return
48
50
  end
49
- f = fb.query("(and (eq what '#{judge}'))").each.to_a.first
51
+ f = fb.query("(and (eq what '#{judge}'))").each.first
50
52
  if f.nil?
51
53
  f = fb.insert
52
54
  f.what = judge
53
55
  end
54
56
  Fbe.overwrite(f, 'when', Time.now)
55
- yield fb.query("(and (eq what '#{judge}'))").each.to_a.first
57
+ yield fb.query("(and (eq what '#{judge}'))").each.first
56
58
  nil
57
59
  end
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.34.3' unless const_defined?(:VERSION)
13
+ VERSION = '0.35.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.34.3
4
+ version: 0.35.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko