fbe 0.0.44 → 0.0.46

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: e48e27db602678e608a7b2301e9a70e801c4651fef5cbca3c9f0e17082109572
4
- data.tar.gz: ca468197e588f5267e7d9c33c169a0e156bed76d71a6bd0f03d7125e341f08c1
3
+ metadata.gz: 2431cb14f0a8b96e3c7c1478004756c89c736c41e30a83908955883f677f223f
4
+ data.tar.gz: a60cfd3c3083d2e9b89de82992981737ab6d375c920fa10de7413ba584ec36f0
5
5
  SHA512:
6
- metadata.gz: d2efed7f06e47435b287774682305f856194426271dc6afe5e2c2763877066f2e0c389812ff6ee1d8ff19addb51f71c6d127e42509728107e01d45a3511762d1
7
- data.tar.gz: d23a168fcbaeec4ac9e8541f25d3ac212b65c0f92f968926942fa4dc593d7a52635945b67592e0f59745ca2f131702b6951716573c4982eb42d52840b94cfab1
6
+ metadata.gz: ae5a89b06a88acfbde4e41601faad9df89d3155f09f545e8564d2944a18da7c1dfb27a928edfb79beaee51b357cc433bd4fb404542d3e3592305441c2e01a676
7
+ data.tar.gz: ffc6494268796dbe1edb4da92163bf107e84e422944000e233f419adc59842ddf0842012da4b43cd2a7ad6080fa1f0150bcde81c894c78e6fc0188bba80458e7
data/Gemfile.lock CHANGED
@@ -19,41 +19,54 @@ PATH
19
19
  GEM
20
20
  remote: https://rubygems.org/
21
21
  specs:
22
- actionpack (7.1.3.4)
23
- actionview (= 7.1.3.4)
24
- activesupport (= 7.1.3.4)
22
+ actionpack (7.2.0)
23
+ actionview (= 7.2.0)
24
+ activesupport (= 7.2.0)
25
25
  nokogiri (>= 1.8.5)
26
26
  racc
27
- rack (>= 2.2.4)
27
+ rack (>= 2.2.4, < 3.2)
28
28
  rack-session (>= 1.0.1)
29
29
  rack-test (>= 0.6.3)
30
30
  rails-dom-testing (~> 2.2)
31
31
  rails-html-sanitizer (~> 1.6)
32
- actionview (7.1.3.4)
33
- activesupport (= 7.1.3.4)
32
+ useragent (~> 0.16)
33
+ actionview (7.2.0)
34
+ activesupport (= 7.2.0)
34
35
  builder (~> 3.1)
35
36
  erubi (~> 1.11)
36
37
  rails-dom-testing (~> 2.2)
37
38
  rails-html-sanitizer (~> 1.6)
38
- activesupport (7.1.3.4)
39
+ activesupport (7.2.0)
39
40
  base64
40
41
  bigdecimal
41
- concurrent-ruby (~> 1.0, >= 1.0.2)
42
+ concurrent-ruby (~> 1.0, >= 1.3.1)
42
43
  connection_pool (>= 2.2.5)
43
44
  drb
44
45
  i18n (>= 1.6, < 2)
46
+ logger (>= 1.4.2)
45
47
  minitest (>= 5.1)
46
- mutex_m
47
- tzinfo (~> 2.0)
48
+ securerandom (>= 0.3)
49
+ tzinfo (~> 2.0, >= 2.0.5)
48
50
  addressable (2.8.7)
49
51
  public_suffix (>= 2.0.2, < 7.0)
50
52
  ansi (1.5.0)
51
53
  ast (2.4.2)
52
54
  backtrace (0.4.0)
53
55
  base64 (0.2.0)
56
+ baza.rb (0.0.4)
57
+ backtrace (> 0)
58
+ faraday (> 0)
59
+ faraday-http-cache (> 0)
60
+ faraday-multipart (> 0)
61
+ faraday-retry (> 0)
62
+ iri (> 0)
63
+ loog (> 0)
64
+ retries (~> 0)
65
+ tago (~> 0)
66
+ typhoeus (~> 1.3)
54
67
  bigdecimal (3.1.8)
55
68
  builder (3.3.0)
56
- concurrent-ruby (1.3.3)
69
+ concurrent-ruby (1.3.4)
57
70
  connection_pool (2.4.1)
58
71
  crack (1.0.0)
59
72
  bigdecimal
@@ -66,7 +79,7 @@ GEM
66
79
  erubi (1.13.0)
67
80
  ethon (0.16.0)
68
81
  ffi (>= 1.15.0)
69
- factbase (0.2.1)
82
+ factbase (0.3.0)
70
83
  backtrace (> 0)
71
84
  decoor (> 0)
72
85
  json (~> 2.7)
@@ -100,8 +113,9 @@ GEM
100
113
  reline (>= 0.4.2)
101
114
  iri (0.8.0)
102
115
  json (2.7.2)
103
- judges (0.22.1)
116
+ judges (0.25.0)
104
117
  backtrace (~> 0)
118
+ baza.rb (~> 0)
105
119
  concurrent-ruby (~> 1.2)
106
120
  factbase (~> 0)
107
121
  gli (~> 2.21)
@@ -127,7 +141,6 @@ GEM
127
141
  ruby-progressbar
128
142
  moments (0.3.0)
129
143
  multipart-post (2.4.1)
130
- mutex_m (0.2.0)
131
144
  net-http (0.4.1)
132
145
  uri
133
146
  nokogiri (1.16.7-arm64-darwin)
@@ -143,8 +156,8 @@ GEM
143
156
  faraday (>= 1, < 3)
144
157
  sawyer (~> 0.9)
145
158
  others (0.0.3)
146
- parallel (1.25.1)
147
- parser (3.3.4.0)
159
+ parallel (1.26.2)
160
+ parser (3.3.4.2)
148
161
  ast (~> 2.4.1)
149
162
  racc
150
163
  psych (5.1.2)
@@ -166,10 +179,10 @@ GEM
166
179
  rails-html-sanitizer (1.6.0)
167
180
  loofah (~> 2.21)
168
181
  nokogiri (~> 1.14)
169
- railties (7.1.3.4)
170
- actionpack (= 7.1.3.4)
171
- activesupport (= 7.1.3.4)
172
- irb
182
+ railties (7.2.0)
183
+ actionpack (= 7.2.0)
184
+ activesupport (= 7.2.0)
185
+ irb (~> 1.13)
173
186
  rackup (>= 1.0.0)
174
187
  rake (>= 12.2)
175
188
  thor (~> 1.0, >= 1.2.2)
@@ -182,7 +195,7 @@ GEM
182
195
  reline (0.5.9)
183
196
  io-console (~> 0.5)
184
197
  retries (0.0.5)
185
- rexml (3.3.4)
198
+ rexml (3.3.5)
186
199
  strscan
187
200
  rspec-core (3.13.0)
188
201
  rspec-support (~> 3.13.0)
@@ -223,6 +236,7 @@ GEM
223
236
  sawyer (0.9.2)
224
237
  addressable (>= 2.3.5)
225
238
  faraday (>= 0.17.3, < 3)
239
+ securerandom (0.3.1)
226
240
  simplecov (0.22.0)
227
241
  docile (~> 1.1)
228
242
  simplecov-html (~> 0.11)
@@ -242,6 +256,7 @@ GEM
242
256
  concurrent-ruby (~> 1.0)
243
257
  unicode-display_width (2.5.0)
244
258
  uri (0.13.0)
259
+ useragent (0.16.10)
245
260
  verbose (0.0.2)
246
261
  loog (~> 0.2)
247
262
  tago (~> 0.0)
data/lib/fbe/overwrite.rb CHANGED
@@ -39,6 +39,8 @@ require_relative 'fb'
39
39
  # @param [Any] vqlue The value to set
40
40
  def Fbe.overwrite(fact, property, value, fb: Fbe.fb)
41
41
  raise 'The fact is nil' if fact.nil?
42
+ raise "The property is not a String but #{property.class} (#{property})" unless property.is_a?(String)
43
+ return if !fact[property].nil? && fact[property].size == 1 && fact[property].first == value
42
44
  before = {}
43
45
  fact.all_properties.each do |prop|
44
46
  before[prop.to_s] = fact[prop]
@@ -0,0 +1,50 @@
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
+ # Run the block provided every X hours.
29
+ #
30
+ # @param [String] area The name of the PMP area
31
+ # @param [Integer] p_every_hours How frequently to run, every X hours
32
+ def Fbe.repeatedly(area, p_every_hours, fb: Fbe.fb, judge: $judge, loog: $loog, &)
33
+ pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_hours}))").each.to_a.first
34
+ hours = pmp.nil? ? 24 : pmp[p_every_hours].first
35
+ unless fb.query(
36
+ "(and
37
+ (eq what '#{judge}')
38
+ (gt when (minus (to_time (env 'TODAY' '#{Time.now.utc.iso8601}')) '#{hours} hours')))"
39
+ ).each.to_a.empty?
40
+ loog.debug("#{$judge} have recently been executed, skipping now")
41
+ return
42
+ end
43
+ f = fb.query("(and (eq what '#{judge}'))").each.to_a.first
44
+ if f.nil?
45
+ f = fb.insert
46
+ f.what = judge
47
+ end
48
+ Fbe.overwrite(f, 'when', Time.now)
49
+ yield f
50
+ end
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.44'
30
+ VERSION = '0.0.46'
31
31
  end
@@ -45,7 +45,7 @@ class QuotaTest < Minitest::Test
45
45
 
46
46
  def test_quota_middleware_pauses_when_quota_low
47
47
  loog = Loog::NULL
48
- pause = 1
48
+ pause = 0.1
49
49
  app = FakeApp.new
50
50
  middleware = Fbe::Middleware::Quota.new(app, loog:, pause:)
51
51
  start_time = Time.now
@@ -62,7 +62,7 @@ class QuotaTest < Minitest::Test
62
62
  end
63
63
 
64
64
  def test_quota_middleware_logs_when_quota_low
65
- pause = 1
65
+ pause = 0.1
66
66
  log_output = StringIO.new
67
67
  loog = Logger.new(log_output)
68
68
  app = FakeApp.new
@@ -139,7 +139,7 @@ class TestOcto < Minitest::Test
139
139
  def test_pauses_when_quota_is_exceeded
140
140
  WebMock.disable_net_connect!
141
141
  global = {}
142
- pause = 1
142
+ pause = 0.1
143
143
  o = Fbe.octo(loog: Loog::NULL, global:, options: Judges::Options.new({ 'github_api_pause' => pause }))
144
144
  limit = 100
145
145
  start_time = Time.now
@@ -40,17 +40,27 @@ class TestOverwrite < Minitest::Test
40
40
  f.bar = 'hey you друг'
41
41
  f.many = 3
42
42
  f.many = 3.14
43
- Fbe.overwrite(f, :foo, 55, fb:)
43
+ Fbe.overwrite(f, 'foo', 55, fb:)
44
44
  assert_equal(55, fb.query('(always)').each.to_a.first['foo'].first)
45
45
  assert_equal('hey you друг', fb.query('(always)').each.to_a.first['bar'].first)
46
46
  assert_equal(2, fb.query('(always)').each.to_a.first['many'].size)
47
47
  end
48
48
 
49
+ def test_no_need_to_overwrite
50
+ fb = Factbase.new
51
+ f = fb.insert
52
+ f._id = 1
53
+ f.foo = 42
54
+ fb.insert._id = 2
55
+ Fbe.overwrite(f, 'foo', 42, fb:)
56
+ assert_equal(1, fb.query('(always)').each.to_a.first._id)
57
+ end
58
+
49
59
  def test_simple_insert
50
60
  fb = Factbase.new
51
61
  f = fb.insert
52
62
  f._id = 1
53
- Fbe.overwrite(f, :foo, 42, fb:)
63
+ Fbe.overwrite(f, 'foo', 42, fb:)
54
64
  assert_equal(42, fb.query('(always)').each.to_a.first['foo'].first)
55
65
  end
56
66
 
@@ -58,7 +68,7 @@ class TestOverwrite < Minitest::Test
58
68
  fb = Factbase.new
59
69
  f = fb.insert
60
70
  assert_raises do
61
- Fbe.overwrite(f, :foo, 42, fb:)
71
+ Fbe.overwrite(f, 'foo', 42, fb:)
62
72
  end
63
73
  end
64
74
 
@@ -71,7 +81,7 @@ class TestOverwrite < Minitest::Test
71
81
  f2._id = 2
72
82
  f3 = fb.insert
73
83
  f3._id = 1
74
- Fbe.overwrite(f3, :foo, 42, fb:)
84
+ Fbe.overwrite(f3, 'foo', 42, fb:)
75
85
  assert_equal(3, fb.size)
76
86
  end
77
87
  end
@@ -0,0 +1,48 @@
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/repeatedly'
30
+
31
+ # Test.
32
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
33
+ # Copyright:: Copyright (c) 2024 Zerocracy
34
+ # License:: MIT
35
+ class TestRepeatedly < Minitest::Test
36
+ def test_simple
37
+ $fb = Factbase.new
38
+ loog = Loog::NULL
39
+ judge = 'test'
40
+ $global = {}
41
+ 3.times do
42
+ Fbe.repeatedly('pmp', 'every_x_hours', loog:, judge:) do |f|
43
+ f.foo = 42
44
+ end
45
+ end
46
+ assert_equal(1, $fb.size)
47
+ end
48
+ 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.44
4
+ version: 0.0.46
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-11 00:00:00.000000000 Z
11
+ date: 2024-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -237,6 +237,7 @@ files:
237
237
  - lib/fbe/overwrite.rb
238
238
  - lib/fbe/pmp.rb
239
239
  - lib/fbe/regularly.rb
240
+ - lib/fbe/repeatedly.rb
240
241
  - lib/fbe/sec.rb
241
242
  - lib/fbe/unmask_repos.rb
242
243
  - lib/fbe/who.rb
@@ -254,6 +255,7 @@ files:
254
255
  - test/fbe/test_overwrite.rb
255
256
  - test/fbe/test_pmp.rb
256
257
  - test/fbe/test_regularly.rb
258
+ - test/fbe/test_repeatedly.rb
257
259
  - test/fbe/test_sec.rb
258
260
  - test/fbe/test_unmask_repos.rb
259
261
  - test/fbe/test_who.rb