baza.rb 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +1 -1
- data/.rubocop.yml +2 -0
- data/.rultor.yml +2 -2
- data/Gemfile +1 -0
- data/Gemfile.lock +22 -16
- data/baza.rb.gemspec +5 -2
- data/lib/{baza → baza-rb}/version.rb +1 -1
- data/lib/{baza.rb → baza-rb.rb} +133 -5
- data/test/{test_baza.rb → test_baza-rb.rb} +52 -62
- metadata +22 -7
- data/lib/baza/elapsed.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79bdf99ef89239ac525987bbde20700d7c2ce13d05198df581729b0bd73bec6b
|
4
|
+
data.tar.gz: 8acc9a7baef255599d65b3ef6092f35c7355b22ce6ea09cca490a0da0e2dd429
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d03964151b2b9eb9f7362425a877321d31d4bbce17c0e500f7f151d95cb3bde298fef2edc0f870c68e5c4447c6c2b82793ebc0a2e44508bf5182fad35080103
|
7
|
+
data.tar.gz: e45fdea8eb1df4ac95cf8a43cca2e6899bd997dd6140fe5eb9c80315cdc11301b6dc5eeb57a3b9683a6c7f67538bc31048e3c3069acca389ec3ab70dbeb66351
|
data/.github/workflows/rake.yml
CHANGED
data/.rubocop.yml
CHANGED
data/.rultor.yml
CHANGED
@@ -31,8 +31,8 @@ release:
|
|
31
31
|
[[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
|
32
32
|
bundle exec rake
|
33
33
|
rm -rf *.gem
|
34
|
-
sed -i "s/0\.0\.0/${tag}/g" lib/baza/version.rb
|
35
|
-
git add lib/baza/version.rb
|
34
|
+
sed -i "s/0\.0\.0/${tag}/g" lib/baza-rb/version.rb
|
35
|
+
git add lib/baza-rb/version.rb
|
36
36
|
git commit -m "version set to ${tag}"
|
37
37
|
gem build baza.rb.gemspec
|
38
38
|
chmod 0600 ../rubygems.yml
|
data/Gemfile
CHANGED
@@ -35,5 +35,6 @@ gem 'rubocop-performance', '1.21.1', require: false
|
|
35
35
|
gem 'rubocop-rspec', '3.0.4', require: false
|
36
36
|
gem 'simplecov', '0.22.0', require: false
|
37
37
|
gem 'simplecov-cobertura', '2.1.0', require: false
|
38
|
+
gem 'wait_for', '~>0', require: false
|
38
39
|
gem 'webmock', '3.23.1', require: false
|
39
40
|
gem 'yard', '0.9.36', require: false
|
data/Gemfile.lock
CHANGED
@@ -10,37 +10,40 @@ PATH
|
|
10
10
|
iri (> 0)
|
11
11
|
loog (> 0)
|
12
12
|
retries (~> 0)
|
13
|
+
tago (~> 0)
|
13
14
|
typhoeus (~> 1.3)
|
14
15
|
|
15
16
|
GEM
|
16
17
|
remote: https://rubygems.org/
|
17
18
|
specs:
|
18
|
-
actionpack (7.
|
19
|
-
actionview (= 7.
|
20
|
-
activesupport (= 7.
|
19
|
+
actionpack (7.2.0)
|
20
|
+
actionview (= 7.2.0)
|
21
|
+
activesupport (= 7.2.0)
|
21
22
|
nokogiri (>= 1.8.5)
|
22
23
|
racc
|
23
|
-
rack (>= 2.2.4)
|
24
|
+
rack (>= 2.2.4, < 3.2)
|
24
25
|
rack-session (>= 1.0.1)
|
25
26
|
rack-test (>= 0.6.3)
|
26
27
|
rails-dom-testing (~> 2.2)
|
27
28
|
rails-html-sanitizer (~> 1.6)
|
28
|
-
|
29
|
-
|
29
|
+
useragent (~> 0.16)
|
30
|
+
actionview (7.2.0)
|
31
|
+
activesupport (= 7.2.0)
|
30
32
|
builder (~> 3.1)
|
31
33
|
erubi (~> 1.11)
|
32
34
|
rails-dom-testing (~> 2.2)
|
33
35
|
rails-html-sanitizer (~> 1.6)
|
34
|
-
activesupport (7.
|
36
|
+
activesupport (7.2.0)
|
35
37
|
base64
|
36
38
|
bigdecimal
|
37
|
-
concurrent-ruby (~> 1.0, >= 1.
|
39
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
38
40
|
connection_pool (>= 2.2.5)
|
39
41
|
drb
|
40
42
|
i18n (>= 1.6, < 2)
|
43
|
+
logger (>= 1.4.2)
|
41
44
|
minitest (>= 5.1)
|
42
|
-
|
43
|
-
tzinfo (~> 2.0)
|
45
|
+
securerandom (>= 0.3)
|
46
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
44
47
|
addressable (2.8.7)
|
45
48
|
public_suffix (>= 2.0.2, < 7.0)
|
46
49
|
ansi (1.5.0)
|
@@ -49,7 +52,7 @@ GEM
|
|
49
52
|
base64 (0.2.0)
|
50
53
|
bigdecimal (3.1.8)
|
51
54
|
builder (3.3.0)
|
52
|
-
concurrent-ruby (1.3.
|
55
|
+
concurrent-ruby (1.3.4)
|
53
56
|
connection_pool (2.4.1)
|
54
57
|
crack (1.0.0)
|
55
58
|
bigdecimal
|
@@ -108,7 +111,6 @@ GEM
|
|
108
111
|
minitest (>= 5.0)
|
109
112
|
ruby-progressbar
|
110
113
|
multipart-post (2.4.1)
|
111
|
-
mutex_m (0.2.0)
|
112
114
|
net-http (0.4.1)
|
113
115
|
uri
|
114
116
|
net-ping (2.0.8)
|
@@ -144,10 +146,10 @@ GEM
|
|
144
146
|
rails-html-sanitizer (1.6.0)
|
145
147
|
loofah (~> 2.21)
|
146
148
|
nokogiri (~> 1.14)
|
147
|
-
railties (7.
|
148
|
-
actionpack (= 7.
|
149
|
-
activesupport (= 7.
|
150
|
-
irb
|
149
|
+
railties (7.2.0)
|
150
|
+
actionpack (= 7.2.0)
|
151
|
+
activesupport (= 7.2.0)
|
152
|
+
irb (~> 1.13)
|
151
153
|
rackup (>= 1.0.0)
|
152
154
|
rake (>= 12.2)
|
153
155
|
thor (~> 1.0, >= 1.2.2)
|
@@ -199,6 +201,7 @@ GEM
|
|
199
201
|
rubocop-rspec (3.0.4)
|
200
202
|
rubocop (~> 1.61)
|
201
203
|
ruby-progressbar (1.13.0)
|
204
|
+
securerandom (0.3.1)
|
202
205
|
simplecov (0.22.0)
|
203
206
|
docile (~> 1.1)
|
204
207
|
simplecov-html (~> 0.11)
|
@@ -218,6 +221,8 @@ GEM
|
|
218
221
|
concurrent-ruby (~> 1.0)
|
219
222
|
unicode-display_width (2.5.0)
|
220
223
|
uri (0.13.0)
|
224
|
+
useragent (0.16.10)
|
225
|
+
wait_for (0.1.1)
|
221
226
|
webmock (3.23.1)
|
222
227
|
addressable (>= 2.8.0)
|
223
228
|
crack (>= 0.3.2)
|
@@ -248,6 +253,7 @@ DEPENDENCIES
|
|
248
253
|
rubocop-rspec (= 3.0.4)
|
249
254
|
simplecov (= 0.22.0)
|
250
255
|
simplecov-cobertura (= 2.1.0)
|
256
|
+
wait_for (~> 0)
|
251
257
|
webmock (= 3.23.1)
|
252
258
|
yard (= 0.9.36)
|
253
259
|
|
data/baza.rb.gemspec
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
23
|
require 'English'
|
24
|
-
require_relative 'lib/baza/version'
|
24
|
+
require_relative 'lib/baza-rb/version'
|
25
25
|
|
26
26
|
Gem::Specification.new do |s|
|
27
27
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
@@ -31,7 +31,9 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.license = 'MIT'
|
32
32
|
s.summary = 'Zerocracy API Ruby Client'
|
33
33
|
s.description =
|
34
|
-
'It is a Ruby client for Zerocracy API'
|
34
|
+
'It is a Ruby client for Zerocracy API, allowing you to check your jobs ' \
|
35
|
+
'statuses, upload and download binaries, lock/unlock them, manage durables, ' \
|
36
|
+
'and do everything else that is possible to do via the HTTP API.'
|
35
37
|
s.authors = ['Yegor Bugayenko']
|
36
38
|
s.email = 'yegor256@gmail.com'
|
37
39
|
s.homepage = 'http://github.com/zerocracy/baza.rb'
|
@@ -46,6 +48,7 @@ Gem::Specification.new do |s|
|
|
46
48
|
s.add_dependency 'iri', '>0'
|
47
49
|
s.add_dependency 'loog', '>0'
|
48
50
|
s.add_dependency 'retries', '~>0'
|
51
|
+
s.add_dependency 'tago', '~>0'
|
49
52
|
s.add_dependency 'typhoeus', '~>1.3'
|
50
53
|
s.metadata['rubygems_mfa_required'] = 'true'
|
51
54
|
end
|
data/lib/{baza.rb → baza-rb.rb}
RENAMED
@@ -25,7 +25,8 @@ require 'retries'
|
|
25
25
|
require 'iri'
|
26
26
|
require 'loog'
|
27
27
|
require 'base64'
|
28
|
-
|
28
|
+
require 'tago'
|
29
|
+
require_relative 'baza-rb/version'
|
29
30
|
|
30
31
|
# Interface to the API of zerocracy.com.
|
31
32
|
#
|
@@ -36,9 +37,7 @@ require_relative 'baza/elapsed'
|
|
36
37
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
37
38
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
38
39
|
# License:: MIT
|
39
|
-
class
|
40
|
-
VERSION = '0.0.0'
|
41
|
-
|
40
|
+
class BazaRb
|
42
41
|
def initialize(host, port, token, ssl: true, timeout: 30, retries: 3, loog: Loog::NULL, compression: true)
|
43
42
|
@host = host
|
44
43
|
@port = port
|
@@ -96,6 +95,7 @@ class Baza
|
|
96
95
|
File.open(file, 'wb') do |f|
|
97
96
|
request = Typhoeus::Request.new(
|
98
97
|
home.append('pull').append("#{id}.fb").to_s,
|
98
|
+
method: :get,
|
99
99
|
headers: headers.merge(
|
100
100
|
'Accept' => 'application/octet-stream'
|
101
101
|
),
|
@@ -154,7 +154,7 @@ class Baza
|
|
154
154
|
)
|
155
155
|
end
|
156
156
|
stdout = ret.body
|
157
|
-
throw :"The stdout of the job ##{id} has #{stdout.split("\n")} lines"
|
157
|
+
throw :"The stdout of the job ##{id} has #{stdout.split("\n").count} lines"
|
158
158
|
end
|
159
159
|
stdout
|
160
160
|
end
|
@@ -194,6 +194,7 @@ class Baza
|
|
194
194
|
302
|
195
195
|
)
|
196
196
|
end
|
197
|
+
throw :"Job name '#{name}' locked at #{@host}"
|
197
198
|
end
|
198
199
|
end
|
199
200
|
|
@@ -211,6 +212,7 @@ class Baza
|
|
211
212
|
302
|
212
213
|
)
|
213
214
|
end
|
215
|
+
throw :"Job name '#{name}' unlocked at #{@host}"
|
214
216
|
end
|
215
217
|
end
|
216
218
|
|
@@ -256,6 +258,121 @@ class Baza
|
|
256
258
|
exists
|
257
259
|
end
|
258
260
|
|
261
|
+
# Place a single durable.
|
262
|
+
# @param [String] jname The name of the job on the server
|
263
|
+
# @param [String] file The file name
|
264
|
+
def durable_place(jname, file)
|
265
|
+
raise "File '#{file}' is absent" unless File.exist?(file)
|
266
|
+
id = nil
|
267
|
+
elapsed(@loog) do
|
268
|
+
ret =
|
269
|
+
with_retries(max_tries: @retries) do
|
270
|
+
checked(
|
271
|
+
Typhoeus::Request.post(
|
272
|
+
home.append('durables').append('place').to_s,
|
273
|
+
body: {
|
274
|
+
'jname' => jname,
|
275
|
+
'file' => File.basename(file),
|
276
|
+
'zip' => File.open(file, 'r')
|
277
|
+
},
|
278
|
+
headers:,
|
279
|
+
connecttimeout: @timeout,
|
280
|
+
timeout: @timeout
|
281
|
+
),
|
282
|
+
302
|
283
|
+
)
|
284
|
+
end
|
285
|
+
id = ret.headers['X-Zerocracy-DurableId'].to_i
|
286
|
+
throw :"Durable ##{id} placed for job \"#{jname}\" at #{@host}"
|
287
|
+
end
|
288
|
+
id
|
289
|
+
end
|
290
|
+
|
291
|
+
# Save a single durable from local file to server.
|
292
|
+
# @param [Integer] id The ID of the durable
|
293
|
+
# @param [String] file The file to upload
|
294
|
+
def durable_save(id, file)
|
295
|
+
raise "File '#{file}' is absent" unless File.exist?(file)
|
296
|
+
elapsed(@loog) do
|
297
|
+
with_retries(max_tries: @retries) do
|
298
|
+
checked(
|
299
|
+
Typhoeus::Request.put(
|
300
|
+
home.append('durables').append(id).to_s,
|
301
|
+
body: File.binread(file),
|
302
|
+
headers:,
|
303
|
+
connecttimeout: @timeout,
|
304
|
+
timeout: @timeout
|
305
|
+
)
|
306
|
+
)
|
307
|
+
end
|
308
|
+
throw :"Durable ##{id} saved #{File.size(file)} bytes to #{@host}"
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
# Load a single durable from server to local file.
|
313
|
+
# @param [Integer] id The ID of the durable
|
314
|
+
# @param [String] file The file to upload
|
315
|
+
def durable_load(id, file)
|
316
|
+
FileUtils.mkdir_p(File.dirname(file))
|
317
|
+
elapsed(@loog) do
|
318
|
+
File.open(file, 'wb') do |f|
|
319
|
+
request = Typhoeus::Request.new(
|
320
|
+
home.append('durables').append(id).to_s,
|
321
|
+
method: :get,
|
322
|
+
headers: headers.merge(
|
323
|
+
'Accept' => 'application/octet-stream'
|
324
|
+
),
|
325
|
+
connecttimeout: @timeout,
|
326
|
+
timeout: @timeout
|
327
|
+
)
|
328
|
+
request.on_body do |chunk|
|
329
|
+
f.write(chunk)
|
330
|
+
end
|
331
|
+
with_retries(max_tries: @retries) do
|
332
|
+
request.run
|
333
|
+
end
|
334
|
+
checked(request.response)
|
335
|
+
end
|
336
|
+
throw :"Durable ##{id} loaded #{File.size(file)} bytes from #{@host}"
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
# Lock a single durable.
|
341
|
+
# @param [Integer] id The ID of the durable
|
342
|
+
# @param [String] owner The owner of the lock
|
343
|
+
def durable_lock(id, owner)
|
344
|
+
elapsed(@loog) do
|
345
|
+
with_retries(max_tries: @retries) do
|
346
|
+
checked(
|
347
|
+
Typhoeus::Request.get(
|
348
|
+
home.append('durables').append(id).append('lock').add(owner:).to_s,
|
349
|
+
headers:
|
350
|
+
),
|
351
|
+
302
|
352
|
+
)
|
353
|
+
end
|
354
|
+
throw :"Durable ##{id} locked at #{@host}"
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
# Unlock a single durable.
|
359
|
+
# @param [Integer] id The ID of the durable
|
360
|
+
# @param [String] owner The owner of the lock
|
361
|
+
def durable_unlock(id, owner)
|
362
|
+
elapsed(@loog) do
|
363
|
+
with_retries(max_tries: @retries) do
|
364
|
+
checked(
|
365
|
+
Typhoeus::Request.get(
|
366
|
+
home.append('durables').append(id).append('unlock').add(owner:).to_s,
|
367
|
+
headers:
|
368
|
+
),
|
369
|
+
302
|
370
|
+
)
|
371
|
+
end
|
372
|
+
throw :"Durable ##{id} unlocked at #{@host}"
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
259
376
|
private
|
260
377
|
|
261
378
|
def headers
|
@@ -280,6 +397,17 @@ class Baza
|
|
280
397
|
params.merge(body:, headers:)
|
281
398
|
end
|
282
399
|
|
400
|
+
def elapsed(loog)
|
401
|
+
start = Time.now
|
402
|
+
begin
|
403
|
+
yield
|
404
|
+
rescue UncaughtThrowError => e
|
405
|
+
tag = e.tag
|
406
|
+
throw e unless tag.is_a?(Symbol)
|
407
|
+
loog.info("#{tag} in #{start.ago}")
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
283
411
|
def gzip(data)
|
284
412
|
''.dup.tap do |result|
|
285
413
|
io = StringIO.new(result)
|
@@ -20,39 +20,28 @@
|
|
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 '
|
24
|
-
require 'webmock/minitest'
|
25
|
-
require 'webrick'
|
23
|
+
require 'factbase'
|
26
24
|
require 'loog'
|
27
|
-
require '
|
28
|
-
require '
|
25
|
+
require 'minitest/autorun'
|
26
|
+
require 'net/ping'
|
29
27
|
require 'random-port'
|
30
|
-
require 'factbase'
|
31
28
|
require 'securerandom'
|
32
|
-
require '
|
33
|
-
|
29
|
+
require 'socket'
|
30
|
+
require 'stringio'
|
31
|
+
require 'wait_for'
|
32
|
+
require 'webmock/minitest'
|
33
|
+
require 'webrick'
|
34
|
+
require_relative '../lib/baza-rb'
|
34
35
|
|
35
36
|
# Test.
|
36
37
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
37
38
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
38
39
|
# License:: MIT
|
39
|
-
class
|
40
|
+
class TestBazaRb < Minitest::Test
|
40
41
|
TOKEN = '00000000-0000-0000-0000-000000000000'
|
41
42
|
HOST = 'api.zerocracy.com'
|
42
43
|
PORT = 443
|
43
|
-
LIVE =
|
44
|
-
|
45
|
-
def test_live_recent_check
|
46
|
-
WebMock.enable_net_connect!
|
47
|
-
skip unless we_are_online
|
48
|
-
assert(LIVE.recent('zerocracy').positive?)
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_live_name_exists_check
|
52
|
-
WebMock.enable_net_connect!
|
53
|
-
skip unless we_are_online
|
54
|
-
assert(LIVE.name_exists?('zerocracy'))
|
55
|
-
end
|
44
|
+
LIVE = BazaRb.new(HOST, PORT, TOKEN, loog: Loog::VERBOSE)
|
56
45
|
|
57
46
|
def test_live_push
|
58
47
|
WebMock.enable_net_connect!
|
@@ -60,7 +49,18 @@ class TestBaza < Minitest::Test
|
|
60
49
|
fb = Factbase.new
|
61
50
|
fb.insert.foo = 'test-' * 10_000
|
62
51
|
fb.insert
|
63
|
-
|
52
|
+
n = fake_name
|
53
|
+
assert(LIVE.push(n, fb.export, []).positive?)
|
54
|
+
assert(LIVE.name_exists?(n))
|
55
|
+
assert(LIVE.recent(n).positive?)
|
56
|
+
id = LIVE.recent(n)
|
57
|
+
wait_for(60) { LIVE.finished?(id) }
|
58
|
+
assert(!LIVE.pull(id).nil?)
|
59
|
+
assert(!LIVE.stdout(id).nil?)
|
60
|
+
assert(!LIVE.exit_code(id).nil?)
|
61
|
+
owner = 'baza.rb testing'
|
62
|
+
assert(!LIVE.lock(n, owner).nil?)
|
63
|
+
assert(!LIVE.unlock(n, owner).nil?)
|
64
64
|
end
|
65
65
|
|
66
66
|
def test_live_push_no_compression
|
@@ -69,45 +69,35 @@ class TestBaza < Minitest::Test
|
|
69
69
|
fb = Factbase.new
|
70
70
|
fb.insert.foo = 'test-' * 10_000
|
71
71
|
fb.insert
|
72
|
-
baza =
|
72
|
+
baza = BazaRb.new(HOST, PORT, TOKEN, compression: false)
|
73
73
|
assert(baza.push(fake_name, fb.export, []).positive?)
|
74
74
|
end
|
75
75
|
|
76
|
-
def
|
77
|
-
WebMock.enable_net_connect!
|
78
|
-
skip unless we_are_online
|
79
|
-
id = LIVE.recent('zerocracy')
|
80
|
-
assert(!LIVE.pull(id).nil?)
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_live_check_finished
|
84
|
-
WebMock.enable_net_connect!
|
85
|
-
skip unless we_are_online
|
86
|
-
id = LIVE.recent('zerocracy')
|
87
|
-
assert(!LIVE.finished?(id).nil?)
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_live_read_stdout
|
91
|
-
WebMock.enable_net_connect!
|
92
|
-
skip unless we_are_online
|
93
|
-
id = LIVE.recent('zerocracy')
|
94
|
-
assert(!LIVE.stdout(id).nil?)
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_live_read_exit_code
|
76
|
+
def test_live_durable_lock_unlock
|
98
77
|
WebMock.enable_net_connect!
|
99
78
|
skip unless we_are_online
|
100
|
-
|
101
|
-
|
79
|
+
Dir.mktmpdir do |dir|
|
80
|
+
file = File.join(dir, "#{fake_name}.bin")
|
81
|
+
File.binwrite(file, 'hello')
|
82
|
+
id = LIVE.durable_place(fake_name, file)
|
83
|
+
owner = fake_name
|
84
|
+
LIVE.durable_lock(id, owner)
|
85
|
+
LIVE.durable_load(id, file)
|
86
|
+
LIVE.durable_save(id, file)
|
87
|
+
LIVE.durable_unlock(id, owner)
|
88
|
+
end
|
102
89
|
end
|
103
90
|
|
104
|
-
def
|
105
|
-
WebMock.
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
91
|
+
def test_durable_place
|
92
|
+
WebMock.disable_net_connect!
|
93
|
+
stub_request(:post, 'https://example.org/durables/place').to_return(
|
94
|
+
status: 302, headers: { 'X-Zerocracy-DurableId' => '42' }
|
95
|
+
)
|
96
|
+
Dir.mktmpdir do |dir|
|
97
|
+
file = File.join(dir, 'test.bin')
|
98
|
+
File.binwrite(file, 'hello')
|
99
|
+
assert_equal(42, BazaRb.new('example.org', 443, '000').durable_place('simple', file))
|
100
|
+
end
|
111
101
|
end
|
112
102
|
|
113
103
|
def test_simple_push
|
@@ -117,7 +107,7 @@ class TestBaza < Minitest::Test
|
|
117
107
|
)
|
118
108
|
assert_equal(
|
119
109
|
42,
|
120
|
-
|
110
|
+
BazaRb.new('example.org', 443, '000').push('simple', 'hello, world!', [])
|
121
111
|
)
|
122
112
|
end
|
123
113
|
|
@@ -128,7 +118,7 @@ class TestBaza < Minitest::Test
|
|
128
118
|
.to_return(status: 200, body: '42')
|
129
119
|
assert_equal(
|
130
120
|
42,
|
131
|
-
|
121
|
+
BazaRb.new('example.org', 443, '000').recent('simple')
|
132
122
|
)
|
133
123
|
end
|
134
124
|
|
@@ -138,7 +128,7 @@ class TestBaza < Minitest::Test
|
|
138
128
|
status: 200, body: 'yes'
|
139
129
|
)
|
140
130
|
assert(
|
141
|
-
|
131
|
+
BazaRb.new('example.org', 443, '000').name_exists?('simple')
|
142
132
|
)
|
143
133
|
end
|
144
134
|
|
@@ -148,7 +138,7 @@ class TestBaza < Minitest::Test
|
|
148
138
|
status: 200, body: '0'
|
149
139
|
)
|
150
140
|
assert(
|
151
|
-
|
141
|
+
BazaRb.new('example.org', 443, '000').exit_code(42).zero?
|
152
142
|
)
|
153
143
|
end
|
154
144
|
|
@@ -158,7 +148,7 @@ class TestBaza < Minitest::Test
|
|
158
148
|
status: 200, body: 'hello!'
|
159
149
|
)
|
160
150
|
assert(
|
161
|
-
!
|
151
|
+
!BazaRb.new('example.org', 443, '000').stdout(42).empty?
|
162
152
|
)
|
163
153
|
end
|
164
154
|
|
@@ -168,7 +158,7 @@ class TestBaza < Minitest::Test
|
|
168
158
|
status: 200, body: 'hello, world!'
|
169
159
|
)
|
170
160
|
assert(
|
171
|
-
|
161
|
+
BazaRb.new('example.org', 443, '000').pull(333).start_with?('hello')
|
172
162
|
)
|
173
163
|
end
|
174
164
|
|
@@ -242,7 +232,7 @@ class TestBaza < Minitest::Test
|
|
242
232
|
socket.puts "HTTP/1.1 #{code} OK\r\nContent-Length: #{response.length}\r\n\r\n#{response}"
|
243
233
|
socket.close
|
244
234
|
end
|
245
|
-
yield
|
235
|
+
yield BazaRb.new(host, port, '0000', **opts)
|
246
236
|
t.join
|
247
237
|
end
|
248
238
|
req
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baza.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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
|
+
date: 2024-08-11 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: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: tago
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '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'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: typhoeus
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,7 +150,9 @@ dependencies:
|
|
136
150
|
- - "~>"
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '1.3'
|
139
|
-
description: It is a Ruby client for Zerocracy API
|
153
|
+
description: It is a Ruby client for Zerocracy API, allowing you to check your jobs
|
154
|
+
statuses, upload and download binaries, lock/unlock them, manage durables, and do
|
155
|
+
everything else that is possible to do via the HTTP API.
|
140
156
|
email: yegor256@gmail.com
|
141
157
|
executables: []
|
142
158
|
extensions: []
|
@@ -166,12 +182,11 @@ files:
|
|
166
182
|
- README.md
|
167
183
|
- Rakefile
|
168
184
|
- baza.rb.gemspec
|
169
|
-
- lib/baza.rb
|
170
|
-
- lib/baza/
|
171
|
-
- lib/baza/version.rb
|
185
|
+
- lib/baza-rb.rb
|
186
|
+
- lib/baza-rb/version.rb
|
172
187
|
- renovate.json
|
173
188
|
- test/test__helper.rb
|
174
|
-
- test/test_baza.rb
|
189
|
+
- test/test_baza-rb.rb
|
175
190
|
homepage: http://github.com/zerocracy/baza.rb
|
176
191
|
licenses:
|
177
192
|
- MIT
|
data/lib/baza/elapsed.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2024 Zerocracy
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
13
|
-
# copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
# SOFTWARE.
|
22
|
-
|
23
|
-
require 'tago'
|
24
|
-
|
25
|
-
def elapsed(loog)
|
26
|
-
start = Time.now
|
27
|
-
begin
|
28
|
-
yield
|
29
|
-
rescue UncaughtThrowError => e
|
30
|
-
tag = e.tag
|
31
|
-
throw e unless tag.is_a?(Symbol)
|
32
|
-
loog.info("#{tag} in #{start.ago}")
|
33
|
-
end
|
34
|
-
end
|