fbe 0.0.36 → 0.0.38

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df35ffd71de34d881cd82c12282e4a27cf95b0ca4c409e8a4dd417aa15387d49
4
- data.tar.gz: 0e499a83a4196d31c74b5b518f3f1c80c0319c08e09374c9fece8460c7a690ca
3
+ metadata.gz: e69702483c25c55333a0391946414e8204e5116c47af9ce6c76736f30ac60e09
4
+ data.tar.gz: 5d868159c91bd6c58d6b6be8c5ba25c1138c0191cf5b915044a49b170342a36e
5
5
  SHA512:
6
- metadata.gz: 4caff409bad7c6c229b0148b5ae01e931cc925bad9c7f00ae355d64c328166ba8743a642f86fb58e8e7d190af2050f97e32060d31950fbc05f4b5d83dd181cd4
7
- data.tar.gz: 45cfdb22a178282dc4597f5e282588fc4da46aea567b9b88900de2814a7577036c4431c97df6db05ce49dbe3ca03692241a2116687506856ba6b4a9a6ffd2433
6
+ metadata.gz: 0c7ed04c82fe5f4c1fe28a127113ab65bc539db0079bb097ebb9979ba2cb521f37a4f5b6ee16aab51f8eac2e67e3da2bbba2f28372218a4a17de6c767514edf4
7
+ data.tar.gz: 4dc676859c6a144bd405808180a63c23bebd61423dc6d009a752a983c4267786b170e6d50758f98896adeb699d775ed75d9978dbf3dc90d0dbd56faee9502a15
data/Gemfile CHANGED
@@ -29,7 +29,7 @@ gem 'rake', '13.2.1', require: false
29
29
  gem 'rspec-rails', '6.1.3', require: false
30
30
  gem 'rubocop', '1.65.1', require: false
31
31
  gem 'rubocop-performance', '1.21.1', require: false
32
- gem 'rubocop-rspec', '3.0.3', require: false
32
+ gem 'rubocop-rspec', '3.0.4', require: false
33
33
  gem 'simplecov', '0.22.0', require: false
34
34
  gem 'simplecov-cobertura', '2.1.0', require: false
35
35
  gem 'webmock', '3.23.1', require: false
data/Gemfile.lock CHANGED
@@ -61,28 +61,28 @@ GEM
61
61
  crass (1.0.6)
62
62
  decoor (0.0.1)
63
63
  diff-lcs (1.5.1)
64
- docile (1.4.0)
64
+ docile (1.4.1)
65
65
  drb (2.2.1)
66
66
  erubi (1.13.0)
67
67
  ethon (0.16.0)
68
68
  ffi (>= 1.15.0)
69
- factbase (0.1.1)
70
- backtrace (~> 0.3)
71
- decoor (~> 0.0)
69
+ factbase (0.2.1)
70
+ backtrace (> 0)
71
+ decoor (> 0)
72
72
  json (~> 2.7)
73
- loog (~> 0.2)
73
+ loog (> 0)
74
74
  nokogiri (~> 1.10)
75
- others (~> 0.0)
76
- tago (~> 0.0)
75
+ others (> 0)
76
+ tago (> 0)
77
77
  yaml (~> 0.3)
78
- faraday (2.10.0)
78
+ faraday (2.10.1)
79
79
  faraday-net_http (>= 2.0, < 3.2)
80
80
  logger
81
81
  faraday-http-cache (2.5.1)
82
82
  faraday (>= 0.8)
83
83
  faraday-multipart (1.0.4)
84
84
  multipart-post (~> 2)
85
- faraday-net_http (3.1.0)
85
+ faraday-net_http (3.1.1)
86
86
  net-http
87
87
  faraday-retry (2.2.1)
88
88
  faraday (~> 2.0)
@@ -91,7 +91,7 @@ GEM
91
91
  ffi (1.17.0-x86_64-darwin)
92
92
  ffi (1.17.0-x86_64-linux-gnu)
93
93
  gli (2.21.5)
94
- hashdiff (1.1.0)
94
+ hashdiff (1.1.1)
95
95
  i18n (1.14.5)
96
96
  concurrent-ruby (~> 1.0)
97
97
  io-console (0.7.2)
@@ -100,7 +100,7 @@ GEM
100
100
  reline (>= 0.4.2)
101
101
  iri (0.8.0)
102
102
  json (2.7.2)
103
- judges (0.18.1)
103
+ judges (0.22.1)
104
104
  backtrace (~> 0)
105
105
  concurrent-ruby (~> 1.2)
106
106
  factbase (~> 0)
@@ -118,7 +118,7 @@ GEM
118
118
  loofah (2.22.0)
119
119
  crass (~> 1.0.2)
120
120
  nokogiri (>= 1.12.0)
121
- loog (0.5.2)
121
+ loog (0.6.0)
122
122
  minitest (5.24.1)
123
123
  minitest-reporters (1.7.1)
124
124
  ansi
@@ -130,13 +130,13 @@ GEM
130
130
  mutex_m (0.2.0)
131
131
  net-http (0.4.1)
132
132
  uri
133
- nokogiri (1.16.6-arm64-darwin)
133
+ nokogiri (1.16.7-arm64-darwin)
134
134
  racc (~> 1.4)
135
- nokogiri (1.16.6-x64-mingw-ucrt)
135
+ nokogiri (1.16.7-x64-mingw-ucrt)
136
136
  racc (~> 1.4)
137
- nokogiri (1.16.6-x86_64-darwin)
137
+ nokogiri (1.16.7-x86_64-darwin)
138
138
  racc (~> 1.4)
139
- nokogiri (1.16.6-x86_64-linux)
139
+ nokogiri (1.16.7-x86_64-linux)
140
140
  racc (~> 1.4)
141
141
  obk (0.3.1)
142
142
  octokit (9.1.0)
@@ -149,7 +149,7 @@ GEM
149
149
  racc
150
150
  psych (5.1.2)
151
151
  stringio
152
- public_suffix (6.0.0)
152
+ public_suffix (6.0.1)
153
153
  racc (1.8.1)
154
154
  rack (3.1.7)
155
155
  rack-session (2.0.0)
@@ -212,12 +212,12 @@ GEM
212
212
  rubocop-ast (>= 1.31.1, < 2.0)
213
213
  ruby-progressbar (~> 1.7)
214
214
  unicode-display_width (>= 2.4.0, < 3.0)
215
- rubocop-ast (1.31.3)
215
+ rubocop-ast (1.32.0)
216
216
  parser (>= 3.3.1.0)
217
217
  rubocop-performance (1.21.1)
218
218
  rubocop (>= 1.48.1, < 2.0)
219
219
  rubocop-ast (>= 1.31.1, < 2.0)
220
- rubocop-rspec (3.0.3)
220
+ rubocop-rspec (3.0.4)
221
221
  rubocop (~> 1.61)
222
222
  ruby-progressbar (1.13.0)
223
223
  sawyer (0.9.2)
@@ -252,7 +252,7 @@ GEM
252
252
  webrick (1.8.1)
253
253
  yaml (0.3.0)
254
254
  yard (0.9.36)
255
- zeitwerk (2.6.16)
255
+ zeitwerk (2.6.17)
256
256
 
257
257
  PLATFORMS
258
258
  arm64-darwin-22
@@ -269,7 +269,7 @@ DEPENDENCIES
269
269
  rspec-rails (= 6.1.3)
270
270
  rubocop (= 1.65.1)
271
271
  rubocop-performance (= 1.21.1)
272
- rubocop-rspec (= 3.0.3)
272
+ rubocop-rspec (= 3.0.4)
273
273
  simplecov (= 0.22.0)
274
274
  simplecov-cobertura (= 2.1.0)
275
275
  webmock (= 3.23.1)
data/lib/fbe/octo.rb CHANGED
@@ -191,6 +191,24 @@ class Fbe::FakeOctokit
191
191
  }
192
192
  end
193
193
 
194
+ def workflow_run_usage(_repo, _id)
195
+ {
196
+ billable: {
197
+ UBUNTU: {
198
+ total_ms: 0,
199
+ jobs: 1,
200
+ job_runs: [
201
+ {
202
+ job_id: 1,
203
+ duration_ms: 0
204
+ }
205
+ ]
206
+ }
207
+ },
208
+ run_duration_ms: 53_000
209
+ }
210
+ end
211
+
194
212
  def releases(_repo, _opts = {})
195
213
  [
196
214
  release('https://github...'),
@@ -237,7 +255,7 @@ class Fbe::FakeOctokit
237
255
  has_pages: false,
238
256
  has_discussions: false,
239
257
  forks_count: 0,
240
- archived: false,
258
+ archived: name == 'zerocracy/datum',
241
259
  disabled: false,
242
260
  open_issues_count: 6,
243
261
  license: { key: 'mit', name: 'MIT License' },
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2024 Zerocracy
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+
25
+ require_relative '../fbe'
26
+ require_relative 'fb'
27
+
28
+ def Fbe.regularly(area, days, interval, fb: Fbe.fb, judge: $judge, loog: $loog, &)
29
+ pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{days}))").each.to_a.first
30
+ days = pmp.nil? ? 28 : pmp[days].first
31
+ since = Time.now - (days * 24 * 60 * 60)
32
+ interval = pmp.nil? ? 7 : pmp[interval].first
33
+ unless fb.query(
34
+ "(and
35
+ (eq what '#{judge}')
36
+ (gt when (minus (to_time (env 'TODAY' '#{Time.now.utc.iso8601}')) '#{interval} days')))"
37
+ ).each.to_a.empty?
38
+ loog.debug("#{$judge} statistics have recently been collected, skipping now")
39
+ return
40
+ end
41
+ f = fb.insert
42
+ f.what = judge
43
+ f.when = Time.now
44
+ f.since = since
45
+ yield f
46
+ end
@@ -37,6 +37,7 @@ module Fbe
37
37
 
38
38
  def self.unmask_repos(options: $options, global: $global, loog: $loog)
39
39
  repos = []
40
+ octo = Fbe.octo(loog:, global:, options:)
40
41
  masks = (options.repositories || '').split(',')
41
42
  masks.reject { |m| m.start_with?('-') }.each do |mask|
42
43
  unless mask.include?('*')
@@ -44,7 +45,7 @@ module Fbe
44
45
  next
45
46
  end
46
47
  re = Fbe.mask_to_regex(mask)
47
- Fbe.octo(loog:, global:, options:).repositories(mask.split('/')[0]).each do |r|
48
+ octo.repositories(mask.split('/')[0]).each do |r|
48
49
  repos << r[:full_name] if re.match?(r[:full_name])
49
50
  end
50
51
  end
@@ -52,6 +53,7 @@ module Fbe
52
53
  re = Fbe.mask_to_regex(mask[1..])
53
54
  repos.reject! { |r| re.match?(r) }
54
55
  end
56
+ repos.reject! { |repo| octo.repository(repo)[:archived] }
55
57
  raise "No repos found matching: #{options.repositories}" if repos.empty?
56
58
  loog.debug("Scanning #{repos.size} repositories: #{repos.join(', ')}...")
57
59
  repos
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.36'
30
+ VERSION = '0.0.38'
31
31
  end
@@ -81,6 +81,7 @@ class TestAward < Minitest::Test
81
81
  def test_some_terms
82
82
  {
83
83
  '(let x 25)' => 0,
84
+ '(award (give (times 5 0.25 "fun")))' => 1,
84
85
  '(award (give 25 "for being a good boy"))' => 25,
85
86
  '(award (give (between 42 -10 -50) "empty"))' => -10,
86
87
  '(award (give (between -3 -10 -50) "empty"))' => 0,
@@ -91,6 +92,17 @@ class TestAward < Minitest::Test
91
92
  end
92
93
  end
93
94
 
95
+ def test_some_greetings
96
+ {
97
+ '(award (give (times 5 0.25 "fun")))' => 'You\'ve earned +1 points. ',
98
+ '(award (give 25 "for being a good boy"))' => 'You\'ve earned +25 points. ',
99
+ '(award (let x 0.1) (set b (times x 14)) (give b "fun"))' => 'You\'ve earned +1 points. '
100
+ }.each do |q, v|
101
+ a = Fbe::Award.new(q)
102
+ assert_equal(v, a.bill.greeting, q)
103
+ end
104
+ end
105
+
94
106
  def test_must_not_give_anything_when_too_small_value
95
107
  {
96
108
  '(award (give (between 0 5 20)))' => 0,
@@ -110,6 +110,12 @@ class TestOcto < Minitest::Test
110
110
  assert_raises { o.repository('zerocracy/fbe') }
111
111
  end
112
112
 
113
+ def test_workflow_run_usage
114
+ WebMock.disable_net_connect!
115
+ o = Fbe.octo(loog: Loog::NULL, global: {}, options: Judges::Options.new({ 'testing' => true }))
116
+ assert_equal(53_000, o.workflow_run_usage('zerocracy/fbe', 1)[:run_duration_ms])
117
+ end
118
+
113
119
  def test_commit_pulls
114
120
  skip # it's a "live" test, run it manually if you need it
115
121
  WebMock.enable_net_connect!
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2024 Zerocracy
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+
25
+ require 'minitest/autorun'
26
+ require 'loog'
27
+ require 'factbase'
28
+ require_relative '../test__helper'
29
+ require_relative '../../lib/fbe/regularly'
30
+
31
+ # Test.
32
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
33
+ # Copyright:: Copyright (c) 2024 Zerocracy
34
+ # License:: MIT
35
+ class TestRegularly < Minitest::Test
36
+ def test_simple
37
+ fb = Factbase.new
38
+ loog = Loog::NULL
39
+ judge = 'test'
40
+ 2.times do
41
+ Fbe.regularly('pmp', 'days', 'interval', fb:, loog:, judge:) do |f|
42
+ f.foo = 42
43
+ end
44
+ end
45
+ assert_equal(1, fb.size)
46
+ end
47
+ end
@@ -37,22 +37,25 @@ class TestUnmaskRepos < Minitest::Test
37
37
  opts = Judges::Options.new(
38
38
  {
39
39
  'testing' => true,
40
- 'repositories' => 'yegor256/tacit,zerocracy/*,-zerocracy/judges-action'
40
+ 'repositories' => 'yegor256/tacit,zerocracy/*,-zerocracy/judges-action,zerocracy/datum'
41
41
  }
42
42
  )
43
- assert(Fbe.unmask_repos(options: opts, global: {}, loog: Loog::NULL).size.positive?)
43
+ list = Fbe.unmask_repos(options: opts, global: {}, loog: Loog::NULL)
44
+ assert(list.size.positive?)
45
+ refute_includes(list, 'zerocracy/datum')
44
46
  end
45
47
 
46
48
  def test_live_usage
47
49
  skip('Run it only manually, since it touches GitHub API')
48
- Judges::Options.new(
50
+ opts = Judges::Options.new(
49
51
  {
50
- 'repositories' => 'zerocracy/*,-zerocracy/judges-action'
52
+ 'repositories' => 'zerocracy/*,-zerocracy/judges-action,zerocracy/datum'
51
53
  }
52
54
  )
53
55
  list = Fbe.unmask_repos(options: opts, global: {}, loog: Loog::NULL)
54
56
  assert(list.size.positive?)
55
57
  assert(list.include?('zerocracy/pages-action'))
56
58
  assert(!list.include?('zerocracy/judges-action'))
59
+ refute_includes(list, 'zerocracy/datum')
57
60
  end
58
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.36
4
+ version: 0.0.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-02 00:00:00.000000000 Z
11
+ date: 2024-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -234,6 +234,7 @@ files:
234
234
  - lib/fbe/middleware/quota.rb
235
235
  - lib/fbe/octo.rb
236
236
  - lib/fbe/pmp.rb
237
+ - lib/fbe/regularly.rb
237
238
  - lib/fbe/sec.rb
238
239
  - lib/fbe/unmask_repos.rb
239
240
  - lib/fbe/who.rb
@@ -248,6 +249,7 @@ files:
248
249
  - test/fbe/test_iterate.rb
249
250
  - test/fbe/test_octo.rb
250
251
  - test/fbe/test_pmp.rb
252
+ - test/fbe/test_regularly.rb
251
253
  - test/fbe/test_sec.rb
252
254
  - test/fbe/test_unmask_repos.rb
253
255
  - test/fbe/test_who.rb