judges 0.10.0 ā†’ 0.12.0

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: a66536b050bc10aad0401eece9025c2cca7cc98862b18fd8fc31be03a390c8b9
4
- data.tar.gz: 022e2a420efcfd08c7df9690f81dba7490fcbc1b9c16fe5991224140fa843d67
3
+ metadata.gz: fdaaebbfb61ca792443a79d06439a3946f92bf9fdeb46fdf89ab0f702f0a2176
4
+ data.tar.gz: 617dce64bda23eb2d4987ef45b60987766248d48ee5770b6c4f35964d4f73cdf
5
5
  SHA512:
6
- metadata.gz: 928a033f2853602094977d119c30f0a64516f4548e4c776540b9861bcf1792b96100947d6d36d4e971468ce314434dd46c2e0e0ba033a11fed5fccb02f879928
7
- data.tar.gz: 7a47a73a1627723225d93c98d1ba3391bb27c20322411ffe55dfc21f4ee176578fb42e8c62e47b1efa87faa1e5160df5a28fe52f046ecaf197458fa49208d6a7
6
+ metadata.gz: 8e0cfe9f3488ed3e67f687400a2d4ab7bd6ccae47985d0eec8681bca3aac61c9bdbef4025ca974adff07e7aadb9a6ab594bc1765f2fccaabc7fa23d0c250201e
7
+ data.tar.gz: 8148daa02d6d83ddcc6dcd6093108cbe051cd205876a924c65590a02b52e861b9d9517cef775e4e86e7ff007cc040379ce11d86c4e1b758a7a4eff6aa82ec327
data/Gemfile CHANGED
@@ -24,12 +24,12 @@ source 'https://rubygems.org'
24
24
  gemspec
25
25
 
26
26
  gem 'cucumber', '9.2.0', require: false
27
- gem 'minitest', '5.23.1', require: false
27
+ gem 'minitest', '5.24.0', require: false
28
28
  gem 'net-ping', '2.0.8', require: false
29
29
  gem 'rake', '13.2.1', require: false
30
- gem 'rspec-rails', '6.1.2', require: false
30
+ gem 'rspec-rails', '6.1.3', require: false
31
31
  gem 'rubocop', '1.64.1', require: false
32
- gem 'rubocop-performance', '1.21.0', require: false
32
+ gem 'rubocop-performance', '1.21.1', require: false
33
33
  gem 'rubocop-rspec', '3.0.1', require: false
34
34
  gem 'simplecov', '0.22.0', require: false
35
35
  gem 'simplecov-cobertura', '2.1.0', require: false
data/Gemfile.lock CHANGED
@@ -10,6 +10,7 @@ PATH
10
10
  loog (~> 0.2)
11
11
  moments (~> 0.3)
12
12
  nokogiri (~> 1.10)
13
+ others (~> 0.0)
13
14
  retries (~> 0.0)
14
15
  tago (~> 0.0)
15
16
  typhoeus (~> 1.3)
@@ -43,8 +44,8 @@ GEM
43
44
  minitest (>= 5.1)
44
45
  mutex_m
45
46
  tzinfo (~> 2.0)
46
- addressable (2.8.6)
47
- public_suffix (>= 2.0.2, < 6.0)
47
+ addressable (2.8.7)
48
+ public_suffix (>= 2.0.2, < 7.0)
48
49
  ast (2.4.2)
49
50
  backtrace (0.4.0)
50
51
  base64 (0.2.0)
@@ -77,20 +78,24 @@ GEM
77
78
  bigdecimal
78
79
  cucumber-gherkin (27.0.0)
79
80
  cucumber-messages (>= 19.1.4, < 23)
80
- cucumber-html-formatter (21.3.1)
81
+ cucumber-html-formatter (21.4.0)
81
82
  cucumber-messages (> 19, < 25)
82
83
  cucumber-messages (22.0.0)
83
84
  cucumber-tag-expressions (6.1.0)
85
+ decoor (0.0.1)
84
86
  diff-lcs (1.5.1)
85
87
  docile (1.4.0)
86
88
  drb (2.2.1)
87
- erubi (1.12.0)
89
+ erubi (1.13.0)
88
90
  ethon (0.16.0)
89
91
  ffi (>= 1.15.0)
90
- factbase (0.0.50)
92
+ factbase (0.0.54)
93
+ backtrace (~> 0.3)
94
+ decoor (~> 0.0)
91
95
  json (~> 2.7)
92
96
  loog (~> 0.2)
93
97
  nokogiri (~> 1.10)
98
+ others (~> 0.0)
94
99
  tago (~> 0.0)
95
100
  yaml (~> 0.3)
96
101
  ffi (1.17.0-aarch64-linux-gnu)
@@ -105,7 +110,7 @@ GEM
105
110
  i18n (1.14.5)
106
111
  concurrent-ruby (~> 1.0)
107
112
  io-console (0.7.2)
108
- irb (1.13.1)
113
+ irb (1.13.2)
109
114
  rdoc (>= 4.0.0)
110
115
  reline (>= 0.4.2)
111
116
  iri (0.8.0)
@@ -116,34 +121,35 @@ GEM
116
121
  nokogiri (>= 1.12.0)
117
122
  loog (0.5.1)
118
123
  mini_mime (1.1.5)
119
- minitest (5.23.1)
124
+ minitest (5.24.0)
120
125
  moments (0.3.0)
121
126
  multi_test (1.1.0)
122
127
  mutex_m (0.2.0)
123
128
  net-ping (2.0.8)
124
- nokogiri (1.16.5-aarch64-linux)
129
+ nokogiri (1.16.6-aarch64-linux)
125
130
  racc (~> 1.4)
126
- nokogiri (1.16.5-arm-linux)
131
+ nokogiri (1.16.6-arm-linux)
127
132
  racc (~> 1.4)
128
- nokogiri (1.16.5-arm64-darwin)
133
+ nokogiri (1.16.6-arm64-darwin)
129
134
  racc (~> 1.4)
130
- nokogiri (1.16.5-x64-mingw-ucrt)
135
+ nokogiri (1.16.6-x64-mingw-ucrt)
131
136
  racc (~> 1.4)
132
- nokogiri (1.16.5-x86-linux)
137
+ nokogiri (1.16.6-x86-linux)
133
138
  racc (~> 1.4)
134
- nokogiri (1.16.5-x86_64-darwin)
139
+ nokogiri (1.16.6-x86_64-darwin)
135
140
  racc (~> 1.4)
136
- nokogiri (1.16.5-x86_64-linux)
141
+ nokogiri (1.16.6-x86_64-linux)
137
142
  racc (~> 1.4)
143
+ others (0.0.3)
138
144
  parallel (1.25.1)
139
145
  parser (3.3.3.0)
140
146
  ast (~> 2.4.1)
141
147
  racc
142
148
  psych (5.1.2)
143
149
  stringio
144
- public_suffix (5.0.5)
150
+ public_suffix (6.0.0)
145
151
  racc (1.8.0)
146
- rack (3.1.3)
152
+ rack (3.1.4)
147
153
  rack-session (2.0.0)
148
154
  rack (>= 3.0.0)
149
155
  rack-test (2.1.0)
@@ -178,13 +184,13 @@ GEM
178
184
  strscan
179
185
  rspec-core (3.13.0)
180
186
  rspec-support (~> 3.13.0)
181
- rspec-expectations (3.13.0)
187
+ rspec-expectations (3.13.1)
182
188
  diff-lcs (>= 1.2.0, < 2.0)
183
189
  rspec-support (~> 3.13.0)
184
190
  rspec-mocks (3.13.1)
185
191
  diff-lcs (>= 1.2.0, < 2.0)
186
192
  rspec-support (~> 3.13.0)
187
- rspec-rails (6.1.2)
193
+ rspec-rails (6.1.3)
188
194
  actionpack (>= 6.1)
189
195
  activesupport (>= 6.1)
190
196
  railties (>= 6.1)
@@ -206,7 +212,7 @@ GEM
206
212
  unicode-display_width (>= 2.4.0, < 3.0)
207
213
  rubocop-ast (1.31.3)
208
214
  parser (>= 3.3.1.0)
209
- rubocop-performance (1.21.0)
215
+ rubocop-performance (1.21.1)
210
216
  rubocop (>= 1.48.1, < 2.0)
211
217
  rubocop-ast (>= 1.31.1, < 2.0)
212
218
  rubocop-rspec (3.0.1)
@@ -221,7 +227,7 @@ GEM
221
227
  simplecov (~> 0.19)
222
228
  simplecov-html (0.12.3)
223
229
  simplecov_json_formatter (0.1.4)
224
- stringio (3.1.0)
230
+ stringio (3.1.1)
225
231
  strscan (3.1.0)
226
232
  sys-uname (1.3.0)
227
233
  ffi (~> 1.1)
@@ -239,7 +245,7 @@ GEM
239
245
  webrick (1.8.1)
240
246
  yaml (0.3.0)
241
247
  yard (0.9.36)
242
- zeitwerk (2.6.15)
248
+ zeitwerk (2.6.16)
243
249
 
244
250
  PLATFORMS
245
251
  aarch64-linux
@@ -253,12 +259,12 @@ PLATFORMS
253
259
  DEPENDENCIES
254
260
  cucumber (= 9.2.0)
255
261
  judges!
256
- minitest (= 5.23.1)
262
+ minitest (= 5.24.0)
257
263
  net-ping (= 2.0.8)
258
264
  rake (= 13.2.1)
259
- rspec-rails (= 6.1.2)
265
+ rspec-rails (= 6.1.3)
260
266
  rubocop (= 1.64.1)
261
- rubocop-performance (= 1.21.0)
267
+ rubocop-performance (= 1.21.1)
262
268
  rubocop-rspec (= 3.0.1)
263
269
  simplecov (= 0.22.0)
264
270
  simplecov-cobertura (= 2.1.0)
data/bin/judges CHANGED
@@ -50,8 +50,8 @@ class App
50
50
  if global[:verbose]
51
51
  loog = Loog::VERBOSE
52
52
  end
53
- loog.debug("judges #{Judges::VERSION}")
54
- loog.debug("facbase #{Factbase::VERSION}")
53
+ loog.debug("Judges #{Judges::VERSION}")
54
+ loog.debug("Factbase #{Factbase::VERSION}")
55
55
  true
56
56
  end
57
57
 
@@ -167,6 +167,8 @@ class App
167
167
  c.flag([:timeout], default_value: 30, type: Integer)
168
168
  c.desc 'Shall SSL be used?'
169
169
  c.switch([:ssl], default_value: true)
170
+ c.desc 'A unique name to use for a lock/unlock'
171
+ c.flag([:owner], default_value: 'default', type: String)
170
172
  c.action do |global, options, args|
171
173
  require_relative '../lib/judges/commands/push'
172
174
  Judges::Push.new(loog).run(options, args)
@@ -187,6 +189,8 @@ class App
187
189
  c.flag([:timeout], default_value: 30, type: Integer)
188
190
  c.desc 'Shall SSL be used?'
189
191
  c.switch([:ssl], default_value: true)
192
+ c.desc 'A unique name to use for a lock/unlock'
193
+ c.flag([:owner], default_value: 'default', type: String)
190
194
  c.action do |global, options, args|
191
195
  require_relative '../lib/judges/commands/pull'
192
196
  Judges::Pull.new(loog).run(options, args)
data/judges.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
27
27
  s.required_ruby_version = '>=3.2'
28
28
  s.name = 'judges'
29
- s.version = '0.10.0'
29
+ s.version = '0.12.0'
30
30
  s.license = 'MIT'
31
31
  s.summary = 'Command-Line Tool for a Factbase'
32
32
  s.description =
@@ -50,6 +50,7 @@ Gem::Specification.new do |s|
50
50
  s.add_runtime_dependency 'loog', '~>0.2'
51
51
  s.add_runtime_dependency 'moments', '~>0.3'
52
52
  s.add_runtime_dependency 'nokogiri', '~>1.10'
53
+ s.add_runtime_dependency 'others', '~>0.0'
53
54
  s.add_runtime_dependency 'retries', '~>0.0'
54
55
  s.add_runtime_dependency 'tago', '~>0.0'
55
56
  s.add_runtime_dependency 'typhoeus', '~>1.3'
data/lib/judges/baza.rb CHANGED
@@ -110,6 +110,36 @@ class Judges::Baza
110
110
  finished
111
111
  end
112
112
 
113
+ # Lock the name.
114
+ def lock(name, owner)
115
+ elapsed(@loog) do
116
+ with_retries do
117
+ checked(
118
+ Typhoeus::Request.get(
119
+ home.append('lock').append(name).add(owner:).to_s,
120
+ headers:
121
+ ),
122
+ 302
123
+ )
124
+ end
125
+ end
126
+ end
127
+
128
+ # Unlock the name.
129
+ def unlock(name, owner)
130
+ elapsed(@loog) do
131
+ with_retries do
132
+ checked(
133
+ Typhoeus::Request.get(
134
+ home.append('unlock').append(name).add(owner:).to_s,
135
+ headers:
136
+ ),
137
+ 302
138
+ )
139
+ end
140
+ end
141
+ end
142
+
113
143
  def recent(name)
114
144
  job = 0
115
145
  elapsed(@loog) do
@@ -47,6 +47,7 @@ class Judges::Pull
47
47
  name = args[0]
48
48
  elapsed(@loog) do
49
49
  if baza.name_exists?(name)
50
+ baza.lock(name, opts['owner'])
50
51
  fb.import(baza.pull(wait(baza, baza.recent(name), opts['wait'])))
51
52
  Judges::Impex.new(@loog, args[1]).export(fb)
52
53
  throw :"Pulled #{fb.size} facts by the name '#{name}'"
@@ -46,7 +46,9 @@ class Judges::Push
46
46
  loog: @loog
47
47
  )
48
48
  elapsed(@loog) do
49
+ baza.lock(name, opts['owner'])
49
50
  id = baza.push(name, fb.export)
51
+ baza.unlock(name, opts['owner'])
50
52
  throw :"Pushed #{fb.size} facts, job ID is #{id}"
51
53
  end
52
54
  end
@@ -84,7 +84,7 @@ class Judges::Update
84
84
  global = {}
85
85
  elapsed(@loog) do
86
86
  done = judges.each_with_index do |p, i|
87
- @loog.info("\n\nšŸ‘‰ Running #{p.name} (##{i}) at #{p.dir.to_rel}...")
87
+ @loog.info("\nšŸ‘‰ Running #{p.name} (##{i}) at #{p.dir.to_rel}...")
88
88
  elapsed(@loog) do
89
89
  c = one_judge(fb, p, global, options)
90
90
  churn += c
@@ -20,6 +20,7 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
+ require 'others'
23
24
  require_relative '../judges'
24
25
 
25
26
  # Options for Ruby scripts in the judges.
@@ -54,7 +55,7 @@ class Judges::Options
54
55
  end
55
56
 
56
57
  # Get option by name.
57
- def method_missing(*args)
58
+ others do |*args|
58
59
  @hash ||= begin
59
60
  pp = @pairs || []
60
61
  pp = @pairs.map { |k, v| "#{k}=#{v}" } if pp.is_a?(Hash)
@@ -72,14 +73,4 @@ class Judges::Options
72
73
  k = args[0].downcase
73
74
  @hash[k]
74
75
  end
75
-
76
- # rubocop:disable Style/OptionalBooleanParameter
77
- def respond_to?(_method, _include_private = false)
78
- # rubocop:enable Style/OptionalBooleanParameter
79
- true
80
- end
81
-
82
- def respond_to_missing?(_method, _include_private = false)
83
- true
84
- end
85
76
  end
data/lib/judges.rb CHANGED
@@ -25,5 +25,5 @@
25
25
  # Copyright:: Copyright (c) 2024 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Judges
28
- VERSION = '0.10.0'
28
+ VERSION = '0.12.0'
29
29
  end
@@ -34,6 +34,7 @@ require_relative '../../lib/judges/commands/pull'
34
34
  class TestPull < Minitest::Test
35
35
  def test_pull_simple_factbase
36
36
  WebMock.disable_net_connect!
37
+ stub_request(:get, 'http://example.org/lock/foo?owner=none').to_return(status: 302)
37
38
  stub_request(:get, 'http://example.org/exists/foo').to_return(body: 'yes')
38
39
  stub_request(:get, 'http://example.org/recent/foo.txt').to_return(body: '42')
39
40
  stub_request(:get, 'http://example.org/finished/42').to_return(body: 'yes')
@@ -48,7 +49,8 @@ class TestPull < Minitest::Test
48
49
  'host' => 'example.org',
49
50
  'port' => 80,
50
51
  'ssl' => false,
51
- 'wait' => 10
52
+ 'wait' => 10,
53
+ 'owner' => 'none'
52
54
  },
53
55
  ['foo', file]
54
56
  )
@@ -33,6 +33,8 @@ require_relative '../../lib/judges/commands/push'
33
33
  class TestPush < Minitest::Test
34
34
  def test_push_simple_factbase
35
35
  WebMock.disable_net_connect!
36
+ stub_request(:get, 'https://example.org/lock/foo?owner=none').to_return(status: 302)
37
+ stub_request(:get, 'https://example.org/unlock/foo?owner=none').to_return(status: 302)
36
38
  stub_request(:put, 'https://example.org/push/foo').to_return(
37
39
  status: 200, body: '42'
38
40
  )
@@ -46,7 +48,8 @@ class TestPush < Minitest::Test
46
48
  'token' => '000',
47
49
  'host' => 'example.org',
48
50
  'port' => 443,
49
- 'ssl' => true
51
+ 'ssl' => true,
52
+ 'owner' => 'none'
50
53
  },
51
54
  ['foo', file]
52
55
  )
@@ -55,6 +58,7 @@ class TestPush < Minitest::Test
55
58
 
56
59
  def test_fails_on_http_error
57
60
  WebMock.disable_net_connect!
61
+ stub_request(:get, 'http://example.org/lock/foo?owner=none').to_return(status: 302)
58
62
  stub_request(:put, 'http://example.org/push/foo').to_return(status: 500)
59
63
  Dir.mktmpdir do |d|
60
64
  file = File.join(d, 'base.fb')
@@ -67,7 +71,8 @@ class TestPush < Minitest::Test
67
71
  'token' => '000',
68
72
  'host' => 'example.org',
69
73
  'port' => 80,
70
- 'ssl' => false
74
+ 'ssl' => false,
75
+ 'owner' => 'none'
71
76
  },
72
77
  ['foo', file]
73
78
  )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judges
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.12.0
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-06-13 00:00:00.000000000 Z
11
+ date: 2024-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '1.10'
125
+ - !ruby/object:Gem::Dependency
126
+ name: others
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: retries
127
141
  requirement: !ruby/object:Gem::Requirement