judges 0.11.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: 9ef24207b8d6248eb98283c45d490b6d8b74fd8c00a6ef8f81dffa546dd6d270
4
- data.tar.gz: 856eeb0c1f19d4d28055880514aca057cb0ec7b8584898bb44c30e9382e5e139
3
+ metadata.gz: fdaaebbfb61ca792443a79d06439a3946f92bf9fdeb46fdf89ab0f702f0a2176
4
+ data.tar.gz: 617dce64bda23eb2d4987ef45b60987766248d48ee5770b6c4f35964d4f73cdf
5
5
  SHA512:
6
- metadata.gz: ca5c1ef2e4cd29c60a1b0c3eba7c9578f5ef7d835c70bfaa994f5a3adbb2b6d98a5dd1b96847a06ec9ab281991b7933db860b651f6f0c7df06aa1dceccc34092
7
- data.tar.gz: f884e4007e22b4be4efb7513eb7101c4913071bfc916b80041109d62fa655ed48424aea3af351ce1976dfad198f6e5cd1495c3e13e2c0fcf574aa6ba225fae2e
6
+ metadata.gz: 8e0cfe9f3488ed3e67f687400a2d4ab7bd6ccae47985d0eec8681bca3aac61c9bdbef4025ca974adff07e7aadb9a6ab594bc1765f2fccaabc7fa23d0c250201e
7
+ data.tar.gz: 8148daa02d6d83ddcc6dcd6093108cbe051cd205876a924c65590a02b52e861b9d9517cef775e4e86e7ff007cc040379ce11d86c4e1b758a7a4eff6aa82ec327
data/bin/judges CHANGED
@@ -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.11.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 =
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
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.11.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.11.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-24 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