judges 0.16.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/bin/judges +4 -0
- data/features/push.feature +1 -1
- data/judges.gemspec +1 -1
- data/lib/judges/baza.rb +14 -9
- data/lib/judges/commands/pull.rb +2 -1
- data/lib/judges/commands/push.rb +2 -1
- data/lib/judges.rb +1 -1
- data/test/test_baza.rb +15 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fde2252d089419bf5cb20dabc6368db3b70b7a7e6fb116624b3ec2f04811544
|
4
|
+
data.tar.gz: 80accd532717b42f176b2bcfc9510610e1dc43d9396ed670196782b923ef2c70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bbdd338bea78fe3d8890b7f581d80081828e3391b738fdbf7a507751f5fab1897764e13dea952ecb5fa2c210c2baa577fb72b1b4d5b6e3994aec49d78eea1b4
|
7
|
+
data.tar.gz: 1e514af2b34b531fbdc70337d3183aeb54d47f8127cda4145ce735724dc7a029e237e09b3c445876c413c1e3c0c660015c648bceef20661fb8b430e00d739692
|
data/Gemfile
CHANGED
@@ -31,7 +31,7 @@ gem 'random-port', '~>0.0', require: false
|
|
31
31
|
gem 'rspec-rails', '6.1.3', require: false
|
32
32
|
gem 'rubocop', '1.65.0', require: false
|
33
33
|
gem 'rubocop-performance', '1.21.1', require: false
|
34
|
-
gem 'rubocop-rspec', '3.0.
|
34
|
+
gem 'rubocop-rspec', '3.0.3', require: false
|
35
35
|
gem 'simplecov', '0.22.0', require: false
|
36
36
|
gem 'simplecov-cobertura', '2.1.0', require: false
|
37
37
|
gem 'webmock', '3.23.1', require: false
|
data/Gemfile.lock
CHANGED
@@ -216,7 +216,7 @@ GEM
|
|
216
216
|
rubocop-performance (1.21.1)
|
217
217
|
rubocop (>= 1.48.1, < 2.0)
|
218
218
|
rubocop-ast (>= 1.31.1, < 2.0)
|
219
|
-
rubocop-rspec (3.0.
|
219
|
+
rubocop-rspec (3.0.3)
|
220
220
|
rubocop (~> 1.61)
|
221
221
|
ruby-progressbar (1.13.0)
|
222
222
|
simplecov (0.22.0)
|
@@ -267,7 +267,7 @@ DEPENDENCIES
|
|
267
267
|
rspec-rails (= 6.1.3)
|
268
268
|
rubocop (= 1.65.0)
|
269
269
|
rubocop-performance (= 1.21.1)
|
270
|
-
rubocop-rspec (= 3.0.
|
270
|
+
rubocop-rspec (= 3.0.3)
|
271
271
|
simplecov (= 0.22.0)
|
272
272
|
simplecov-cobertura (= 2.1.0)
|
273
273
|
webmock (= 3.23.1)
|
data/bin/judges
CHANGED
@@ -179,6 +179,8 @@ class App
|
|
179
179
|
c.flag([:owner], default_value: 'default', type: String)
|
180
180
|
c.desc 'Supplementary meta information about the upload (key:value)'
|
181
181
|
c.flag([:meta], type: String, multiple: true)
|
182
|
+
c.desc 'How many times to retry'
|
183
|
+
c.flag([:retries], type: Integer, default_value: 3)
|
182
184
|
c.action do |global, options, args|
|
183
185
|
require_relative '../lib/judges/commands/push'
|
184
186
|
Judges::Push.new(loog).run(options, args)
|
@@ -201,6 +203,8 @@ class App
|
|
201
203
|
c.switch([:ssl], default_value: true)
|
202
204
|
c.desc 'A unique name to use for a lock/unlock'
|
203
205
|
c.flag([:owner], default_value: 'default', type: String)
|
206
|
+
c.desc 'How many times to retry'
|
207
|
+
c.flag([:retries], type: Integer, default_value: 3)
|
204
208
|
c.action do |global, options, args|
|
205
209
|
require_relative '../lib/judges/commands/pull'
|
206
210
|
Judges::Pull.new(loog).run(options, args)
|
data/features/push.feature
CHANGED
@@ -6,6 +6,6 @@ Feature: Push
|
|
6
6
|
Given I make a temp directory
|
7
7
|
Then I run bin/judges with "--verbose eval simple.fb '(0..1000).each { $fb.insert.foo = 42 }'"
|
8
8
|
And Exit code is zero
|
9
|
-
Then I run bin/judges with "push --token 00000000-0000-0000-0000-000000000000 --meta a:b --meta foo:bar simple simple.fb"
|
9
|
+
Then I run bin/judges with "push --token 00000000-0000-0000-0000-000000000000 --meta a:b --meta foo:bar --meta=pages_url:https://zerocracy.github.io/zerocracy.html --meta=duration:1055 simple simple.fb"
|
10
10
|
Then Stdout contains "Pushed"
|
11
11
|
And Exit code is zero
|
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.
|
29
|
+
s.version = '0.17.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
@@ -34,7 +34,7 @@ require_relative '../judges/elapsed'
|
|
34
34
|
# License:: MIT
|
35
35
|
class Judges::Baza
|
36
36
|
# rubocop:disable Metrics/ParameterLists
|
37
|
-
def initialize(host, port, token, ssl: true, timeout: 30, loog: Loog::NULL)
|
37
|
+
def initialize(host, port, token, ssl: true, timeout: 30, retries: 3, loog: Loog::NULL)
|
38
38
|
# rubocop:enable Metrics/ParameterLists
|
39
39
|
@host = host
|
40
40
|
@port = port
|
@@ -42,6 +42,7 @@ class Judges::Baza
|
|
42
42
|
@token = token
|
43
43
|
@timeout = timeout
|
44
44
|
@loog = loog
|
45
|
+
@retries = retries
|
45
46
|
end
|
46
47
|
|
47
48
|
def push(name, data, meta)
|
@@ -50,9 +51,11 @@ class Judges::Baza
|
|
50
51
|
'Content-Type' => 'application/octet-stream',
|
51
52
|
'Content-Length' => data.size
|
52
53
|
)
|
53
|
-
|
54
|
+
unless meta.empty?
|
55
|
+
hdrs = hdrs.merge('X-Zerocracy-Meta' => meta.map { |v| Base64.encode64(v).gsub("\n", '') }.join(' '))
|
56
|
+
end
|
54
57
|
elapsed(@loog) do
|
55
|
-
ret = with_retries do
|
58
|
+
ret = with_retries(max_tries: @retries) do
|
56
59
|
checked(
|
57
60
|
Typhoeus::Request.put(
|
58
61
|
home.append('push').append(name).to_s,
|
@@ -85,7 +88,9 @@ class Judges::Baza
|
|
85
88
|
request.on_body do |chunk|
|
86
89
|
f.write(chunk)
|
87
90
|
end
|
88
|
-
|
91
|
+
with_retries(max_tries: @retries) do
|
92
|
+
request.run
|
93
|
+
end
|
89
94
|
checked(request.response)
|
90
95
|
end
|
91
96
|
data = File.binread(file)
|
@@ -99,7 +104,7 @@ class Judges::Baza
|
|
99
104
|
def finished?(id)
|
100
105
|
finished = false
|
101
106
|
elapsed(@loog) do
|
102
|
-
ret = with_retries do
|
107
|
+
ret = with_retries(max_tries: @retries) do
|
103
108
|
checked(
|
104
109
|
Typhoeus::Request.get(
|
105
110
|
home.append('finished').append(id).to_s,
|
@@ -116,7 +121,7 @@ class Judges::Baza
|
|
116
121
|
# Lock the name.
|
117
122
|
def lock(name, owner)
|
118
123
|
elapsed(@loog) do
|
119
|
-
with_retries do
|
124
|
+
with_retries(max_tries: @retries) do
|
120
125
|
checked(
|
121
126
|
Typhoeus::Request.get(
|
122
127
|
home.append('lock').append(name).add(owner:).to_s,
|
@@ -131,7 +136,7 @@ class Judges::Baza
|
|
131
136
|
# Unlock the name.
|
132
137
|
def unlock(name, owner)
|
133
138
|
elapsed(@loog) do
|
134
|
-
with_retries do
|
139
|
+
with_retries(max_tries: @retries) do
|
135
140
|
checked(
|
136
141
|
Typhoeus::Request.get(
|
137
142
|
home.append('unlock').append(name).add(owner:).to_s,
|
@@ -146,7 +151,7 @@ class Judges::Baza
|
|
146
151
|
def recent(name)
|
147
152
|
job = 0
|
148
153
|
elapsed(@loog) do
|
149
|
-
ret = with_retries do
|
154
|
+
ret = with_retries(max_tries: @retries) do
|
150
155
|
checked(
|
151
156
|
Typhoeus::Request.get(
|
152
157
|
home.append('recent').append("#{name}.txt").to_s,
|
@@ -163,7 +168,7 @@ class Judges::Baza
|
|
163
168
|
def name_exists?(name)
|
164
169
|
exists = 0
|
165
170
|
elapsed(@loog) do
|
166
|
-
ret = with_retries do
|
171
|
+
ret = with_retries(max_tries: @retries) do
|
167
172
|
checked(
|
168
173
|
Typhoeus::Request.get(
|
169
174
|
home.append('exists').append(name).to_s,
|
data/lib/judges/commands/pull.rb
CHANGED
data/lib/judges/commands/push.rb
CHANGED
@@ -43,7 +43,8 @@ class Judges::Push
|
|
43
43
|
opts['host'], opts['port'].to_i, opts['token'],
|
44
44
|
ssl: opts['ssl'],
|
45
45
|
timeout: (opts['timeout'] || 30).to_i,
|
46
|
-
loog: @loog
|
46
|
+
loog: @loog,
|
47
|
+
retries: (opts['retries'] || 3).to_i
|
47
48
|
)
|
48
49
|
elapsed(@loog) do
|
49
50
|
baza.lock(name, opts['owner'])
|
data/lib/judges.rb
CHANGED
data/test/test_baza.rb
CHANGED
@@ -89,6 +89,21 @@ class TestBaza < Minitest::Test
|
|
89
89
|
assert(req.include?("X-Zerocracy-Meta: Ym9vbSE= 0YXQtdC5IQ==\r\n"))
|
90
90
|
end
|
91
91
|
|
92
|
+
def test_push_with_big_meta
|
93
|
+
req = with_http_server(200, 'yes') do |baza|
|
94
|
+
baza.push(
|
95
|
+
'simple',
|
96
|
+
'hello, world!',
|
97
|
+
[
|
98
|
+
'pages_url:https://zerocracy.github.io/zerocracy.html',
|
99
|
+
'others:https://zerocracy.github.io/zerocracy.html',
|
100
|
+
'duration:59595'
|
101
|
+
]
|
102
|
+
)
|
103
|
+
end
|
104
|
+
assert(req.join.include?('X-Zerocracy-Meta: '))
|
105
|
+
end
|
106
|
+
|
92
107
|
private
|
93
108
|
|
94
109
|
def with_http_server(code, response)
|