baza.rb 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +4 -4
- data/lib/baza-rb/version.rb +1 -1
- data/lib/baza-rb.rb +50 -5
- data/test/test_baza-rb.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cec6d23dff978b5dcf080a6940a875ee1f9a67eb07b61ee5ee4b8a98348113c4
|
4
|
+
data.tar.gz: 98eb41907e61acc9beeb0397da3b1ec0c9cbb8a1ebd7c8f57422f8be18947cf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1df697ec1d35721c3d23e6ef0b05d0d1c7e99b47c959b8150e413b18f5fd131efb9d3ca28bbdff4343ab4f012ce86217f4b1ffc8508c92eec2842633b6bef354
|
7
|
+
data.tar.gz: 9f74b8782d6a5ad2bfa1f0d8450e1c033cf5c8ad22c2a083f20fb2d96f94a8abbdd572b612a9440edf74f1d40d3b09356c471e2befd85fdd8c020b69884f60f3
|
data/Gemfile
CHANGED
@@ -24,12 +24,12 @@ source 'https://rubygems.org'
|
|
24
24
|
gemspec
|
25
25
|
|
26
26
|
gem 'factbase', '>0', require: false
|
27
|
-
gem 'minitest', '5.
|
27
|
+
gem 'minitest', '5.25.1', require: false
|
28
28
|
gem 'minitest-reporters', '1.7.1', require: false
|
29
29
|
gem 'net-ping', '2.0.8', require: false
|
30
30
|
gem 'rake', '13.2.1', require: false
|
31
31
|
gem 'random-port', '>0', require: false
|
32
|
-
gem 'rspec-rails', '6.1.
|
32
|
+
gem 'rspec-rails', '6.1.4', require: false
|
33
33
|
gem 'rubocop', '1.65.1', require: false
|
34
34
|
gem 'rubocop-performance', '1.21.1', require: false
|
35
35
|
gem 'rubocop-rspec', '3.0.4', require: false
|
data/Gemfile.lock
CHANGED
@@ -104,7 +104,7 @@ GEM
|
|
104
104
|
crass (~> 1.0.2)
|
105
105
|
nokogiri (>= 1.12.0)
|
106
106
|
loog (0.6.0)
|
107
|
-
minitest (5.
|
107
|
+
minitest (5.25.1)
|
108
108
|
minitest-reporters (1.7.1)
|
109
109
|
ansi
|
110
110
|
builder
|
@@ -173,7 +173,7 @@ GEM
|
|
173
173
|
rspec-mocks (3.13.1)
|
174
174
|
diff-lcs (>= 1.2.0, < 2.0)
|
175
175
|
rspec-support (~> 3.13.0)
|
176
|
-
rspec-rails (6.1.
|
176
|
+
rspec-rails (6.1.4)
|
177
177
|
actionpack (>= 6.1)
|
178
178
|
activesupport (>= 6.1)
|
179
179
|
railties (>= 6.1)
|
@@ -242,12 +242,12 @@ PLATFORMS
|
|
242
242
|
DEPENDENCIES
|
243
243
|
baza.rb!
|
244
244
|
factbase (> 0)
|
245
|
-
minitest (= 5.
|
245
|
+
minitest (= 5.25.1)
|
246
246
|
minitest-reporters (= 1.7.1)
|
247
247
|
net-ping (= 2.0.8)
|
248
248
|
rake (= 13.2.1)
|
249
249
|
random-port (> 0)
|
250
|
-
rspec-rails (= 6.1.
|
250
|
+
rspec-rails (= 6.1.4)
|
251
251
|
rubocop (= 1.65.1)
|
252
252
|
rubocop-performance (= 1.21.1)
|
253
253
|
rubocop-rspec (= 3.0.4)
|
data/lib/baza-rb/version.rb
CHANGED
data/lib/baza-rb.rb
CHANGED
@@ -55,6 +55,10 @@ class BazaRb
|
|
55
55
|
# @param [Array<String>] meta List of metas, possibly empty
|
56
56
|
# @return [Integer] Job ID on the server
|
57
57
|
def push(name, data, meta)
|
58
|
+
raise 'The "name" of the job is nil' if name.nil?
|
59
|
+
raise 'The "name" of the job may not be empty' if name.empty?
|
60
|
+
raise 'The "data" of the job is nil' if data.nil?
|
61
|
+
raise 'The "meta" of the job is nil' if meta.nil?
|
58
62
|
id = 0
|
59
63
|
hdrs = headers.merge(
|
60
64
|
'Content-Type' => 'application/octet-stream',
|
@@ -89,6 +93,8 @@ class BazaRb
|
|
89
93
|
# @param [Integer] id The ID of the job on the server
|
90
94
|
# @return [Bytes] Binary data pulled
|
91
95
|
def pull(id)
|
96
|
+
raise 'The ID of the job is nil' if id.nil?
|
97
|
+
raise 'The ID of the job must be a positive integer' unless id.positive?
|
92
98
|
data = 0
|
93
99
|
elapsed(@loog) do
|
94
100
|
Tempfile.open do |file|
|
@@ -97,8 +103,9 @@ class BazaRb
|
|
97
103
|
home.append('pull').append("#{id}.fb").to_s,
|
98
104
|
method: :get,
|
99
105
|
headers: headers.merge(
|
100
|
-
'Accept' => 'application/
|
106
|
+
'Accept' => 'application/zip, application/factbase'
|
101
107
|
),
|
108
|
+
accept_encoding: 'gzip',
|
102
109
|
connecttimeout: @timeout,
|
103
110
|
timeout: @timeout
|
104
111
|
)
|
@@ -121,6 +128,8 @@ class BazaRb
|
|
121
128
|
# @param [Integer] id The ID of the job on the server
|
122
129
|
# @return [Boolean] TRUE if the job is already finished
|
123
130
|
def finished?(id)
|
131
|
+
raise 'The ID of the job is nil' if id.nil?
|
132
|
+
raise 'The ID of the job must be a positive integer' unless id.positive?
|
124
133
|
finished = false
|
125
134
|
elapsed(@loog) do
|
126
135
|
ret =
|
@@ -142,6 +151,8 @@ class BazaRb
|
|
142
151
|
# @param [Integer] id The ID of the job on the server
|
143
152
|
# @return [String] The stdout, as a text
|
144
153
|
def stdout(id)
|
154
|
+
raise 'The ID of the job is nil' if id.nil?
|
155
|
+
raise 'The ID of the job must be a positive integer' unless id.positive?
|
145
156
|
stdout = ''
|
146
157
|
elapsed(@loog) do
|
147
158
|
ret =
|
@@ -163,6 +174,8 @@ class BazaRb
|
|
163
174
|
# @param [Integer] id The ID of the job on the server
|
164
175
|
# @return [Integer] The exit code
|
165
176
|
def exit_code(id)
|
177
|
+
raise 'The ID of the job is nil' if id.nil?
|
178
|
+
raise 'The ID of the job must be a positive integer' unless id.positive?
|
166
179
|
code = 0
|
167
180
|
elapsed(@loog) do
|
168
181
|
ret =
|
@@ -184,6 +197,8 @@ class BazaRb
|
|
184
197
|
# @param [Integer] id The ID of the job on the server
|
185
198
|
# @return [String] The verdict
|
186
199
|
def verified(id)
|
200
|
+
raise 'The ID of the job is nil' if id.nil?
|
201
|
+
raise 'The ID of the job must be a positive integer' unless id.positive?
|
187
202
|
verdict = 0
|
188
203
|
elapsed(@loog) do
|
189
204
|
ret =
|
@@ -205,6 +220,9 @@ class BazaRb
|
|
205
220
|
# @param [String] name The name of the job on the server
|
206
221
|
# @param [String] owner The owner of the lock (any string)
|
207
222
|
def lock(name, owner)
|
223
|
+
raise 'The "name" of the job is nil' if name.nil?
|
224
|
+
raise 'The "name" of the job may not be empty' if name.empty?
|
225
|
+
raise 'The "owner" of the lock is nil' if owner.nil?
|
208
226
|
elapsed(@loog) do
|
209
227
|
with_retries(max_tries: @retries) do
|
210
228
|
checked(
|
@@ -223,6 +241,9 @@ class BazaRb
|
|
223
241
|
# @param [String] name The name of the job on the server
|
224
242
|
# @param [String] owner The owner of the lock (any string)
|
225
243
|
def unlock(name, owner)
|
244
|
+
raise 'The "name" of the job is nil' if name.nil?
|
245
|
+
raise 'The "name" of the job may not be empty' if name.empty?
|
246
|
+
raise 'The "owner" of the lock is nil' if owner.nil?
|
226
247
|
elapsed(@loog) do
|
227
248
|
with_retries(max_tries: @retries) do
|
228
249
|
checked(
|
@@ -241,6 +262,8 @@ class BazaRb
|
|
241
262
|
# @param [String] name The name of the job on the server
|
242
263
|
# @return [Integer] The ID of the job on the server
|
243
264
|
def recent(name)
|
265
|
+
raise 'The "name" of the job is nil' if name.nil?
|
266
|
+
raise 'The "name" of the job may not be empty' if name.empty?
|
244
267
|
job = 0
|
245
268
|
elapsed(@loog) do
|
246
269
|
ret =
|
@@ -262,6 +285,8 @@ class BazaRb
|
|
262
285
|
# @param [String] name The name of the job on the server
|
263
286
|
# @return [Boolean] TRUE if such name exists
|
264
287
|
def name_exists?(name)
|
288
|
+
raise 'The "name" of the job is nil' if name.nil?
|
289
|
+
raise 'The "name" of the job may not be empty' if name.empty?
|
265
290
|
exists = 0
|
266
291
|
elapsed(@loog) do
|
267
292
|
ret =
|
@@ -283,7 +308,10 @@ class BazaRb
|
|
283
308
|
# @param [String] jname The name of the job on the server
|
284
309
|
# @param [String] file The file name
|
285
310
|
def durable_place(jname, file)
|
286
|
-
raise "
|
311
|
+
raise 'The "jname" of the durable is nil' if jname.nil?
|
312
|
+
raise 'The "jname" of the durable may not be empty' if jname.empty?
|
313
|
+
raise 'The "file" of the durable is nil' if file.nil?
|
314
|
+
raise "The file '#{file}' is absent" unless File.exist?(file)
|
287
315
|
id = nil
|
288
316
|
elapsed(@loog) do
|
289
317
|
ret =
|
@@ -313,7 +341,10 @@ class BazaRb
|
|
313
341
|
# @param [Integer] id The ID of the durable
|
314
342
|
# @param [String] file The file to upload
|
315
343
|
def durable_save(id, file)
|
316
|
-
raise
|
344
|
+
raise 'The ID of the durable is nil' if id.nil?
|
345
|
+
raise 'The ID of the durable must be a positive integer' unless id.positive?
|
346
|
+
raise 'The "file" of the durable is nil' if file.nil?
|
347
|
+
raise "The file '#{file}' is absent" unless File.exist?(file)
|
317
348
|
elapsed(@loog) do
|
318
349
|
with_retries(max_tries: @retries) do
|
319
350
|
checked(
|
@@ -334,6 +365,9 @@ class BazaRb
|
|
334
365
|
# @param [Integer] id The ID of the durable
|
335
366
|
# @param [String] file The file to upload
|
336
367
|
def durable_load(id, file)
|
368
|
+
raise 'The ID of the durable is nil' if id.nil?
|
369
|
+
raise 'The ID of the durable must be a positive integer' unless id.positive?
|
370
|
+
raise 'The "file" of the durable is nil' if file.nil?
|
337
371
|
FileUtils.mkdir_p(File.dirname(file))
|
338
372
|
elapsed(@loog) do
|
339
373
|
File.open(file, 'wb') do |f|
|
@@ -362,6 +396,10 @@ class BazaRb
|
|
362
396
|
# @param [Integer] id The ID of the durable
|
363
397
|
# @param [String] owner The owner of the lock
|
364
398
|
def durable_lock(id, owner)
|
399
|
+
raise 'The ID of the durable is nil' if id.nil?
|
400
|
+
raise 'The ID of the durable must be a positive integer' unless id.positive?
|
401
|
+
raise 'The "owner" of the lock is nil' if owner.nil?
|
402
|
+
raise 'The "owner" of the lock may not be empty' if owner.empty?
|
365
403
|
elapsed(@loog) do
|
366
404
|
with_retries(max_tries: @retries) do
|
367
405
|
checked(
|
@@ -380,6 +418,10 @@ class BazaRb
|
|
380
418
|
# @param [Integer] id The ID of the durable
|
381
419
|
# @param [String] owner The owner of the lock
|
382
420
|
def durable_unlock(id, owner)
|
421
|
+
raise 'The ID of the durable is nil' if id.nil?
|
422
|
+
raise 'The ID of the durable must be a positive integer' unless id.positive?
|
423
|
+
raise 'The "owner" of the lock is nil' if owner.nil?
|
424
|
+
raise 'The "owner" of the lock may not be empty' if owner.empty?
|
383
425
|
elapsed(@loog) do
|
384
426
|
with_retries(max_tries: @retries) do
|
385
427
|
checked(
|
@@ -449,7 +491,11 @@ class BazaRb
|
|
449
491
|
allowed = [allowed] unless allowed.is_a?(Array)
|
450
492
|
mtd = (ret.request.original_options[:method] || '???').upcase
|
451
493
|
url = ret.effective_url
|
452
|
-
|
494
|
+
if ret.return_code == :operation_timedout
|
495
|
+
msg = "#{mtd} #{url} timed out in #{ret.total_time}s"
|
496
|
+
@loog.debug(msg)
|
497
|
+
raise msg
|
498
|
+
end
|
453
499
|
log = "#{mtd} #{url} -> #{ret.code} (#{format('%0.2f', ret.total_time)}s)"
|
454
500
|
if allowed.include?(ret.code)
|
455
501
|
@loog.debug(log)
|
@@ -457,7 +503,6 @@ class BazaRb
|
|
457
503
|
end
|
458
504
|
@loog.debug("#{log}\n #{(ret.headers || {}).map { |k, v| "#{k}: #{v}" }.join("\n ")}")
|
459
505
|
headers = ret.headers || {}
|
460
|
-
p ret
|
461
506
|
msg = [
|
462
507
|
"Invalid response code ##{ret.code} ",
|
463
508
|
"at #{mtd} #{url}",
|
data/test/test_baza-rb.rb
CHANGED
@@ -196,7 +196,6 @@ class TestBazaRb < Minitest::Test
|
|
196
196
|
end
|
197
197
|
|
198
198
|
def test_push_compressed_content
|
199
|
-
skip # this test is not stable, see https://github.com/yegor256/judges/issues/105
|
200
199
|
req =
|
201
200
|
with_http_server(200, 'yes') do |baza|
|
202
201
|
baza.push('simple', 'hello, world!', %w[meta1 meta2 meta3])
|
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.7
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|