baza.rb 0.10.2 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b2d727175020c56bb2a387f2bb60a5c1b6eac92bf0f67721df00db6f43ff1c7
4
- data.tar.gz: 96fd929cc995cf0c5e1eb7112f13b510abc2e32891092cf74f1daa57ae851fb3
3
+ metadata.gz: c3f6b8fd3d4ae976677a1b3307a3c5c3279b61aae5469ffb0f113103dae1c8b5
4
+ data.tar.gz: 6954c6b824ac00e1951b6dc43cc4ee0824739f7a73370599cd4ac5a1081a885d
5
5
  SHA512:
6
- metadata.gz: 02a28ce9c2d38bad3a6b4eb06e807a27f5f8386b028236ed7f21ab2ff0403b938ab867b4d1b7ff179dc62118b8419a45f5dd0dcd81f1d8ab1ac0f0c8c2b76602
7
- data.tar.gz: 244010e6fea8abe37457db3cac8341362b3663c03828b60a0c9973befa3a65352109a7e8abea8050e17f31381525f31a72e8658ea7df7c3056f76a477b60eb78
6
+ metadata.gz: 5eccf68db6789c2e02861917eb036c6da42970182c2d92dfbf2d1c646c193e29479e2eadc11ca1eadf1cb3ea24bdfd95397f194771496a275d2d80b9dc641f4a
7
+ data.tar.gz: d229ff82c8c01651d5dc5c46f62c4b373651624e91c8a126de8888ec098c30374fad72254c86998c4a5c5f16a9f6fb09e03c29be1fd6d0fd7f14855d64fbf6f8
data/Gemfile.lock CHANGED
@@ -36,7 +36,7 @@ GEM
36
36
  ellipsized (0.3.0)
37
37
  ethon (0.15.0)
38
38
  ffi (>= 1.15.0)
39
- factbase (0.16.3)
39
+ factbase (0.16.7)
40
40
  backtrace (~> 0.4)
41
41
  decoor (~> 0.1)
42
42
  ellipsized (~> 0.3)
@@ -65,7 +65,7 @@ GEM
65
65
  ffi (1.17.2-x86_64-linux-gnu)
66
66
  hashdiff (1.2.1)
67
67
  iri (0.11.2)
68
- json (2.13.2)
68
+ json (2.15.0)
69
69
  language_server-protocol (3.17.0.5)
70
70
  lint_roller (1.1.0)
71
71
  logger (1.7.0)
@@ -83,13 +83,13 @@ GEM
83
83
  net-http (0.6.0)
84
84
  uri
85
85
  nio4r (2.7.4)
86
- nokogiri (1.18.9-arm64-darwin)
86
+ nokogiri (1.18.10-arm64-darwin)
87
87
  racc (~> 1.4)
88
- nokogiri (1.18.9-x64-mingw-ucrt)
88
+ nokogiri (1.18.10-x64-mingw-ucrt)
89
89
  racc (~> 1.4)
90
- nokogiri (1.18.9-x86_64-darwin)
90
+ nokogiri (1.18.10-x86_64-darwin)
91
91
  racc (~> 1.4)
92
- nokogiri (1.18.9-x86_64-linux-gnu)
92
+ nokogiri (1.18.10-x86_64-linux-gnu)
93
93
  racc (~> 1.4)
94
94
  online (0.1.0)
95
95
  timeout (~> 0.4)
@@ -99,9 +99,9 @@ GEM
99
99
  parser (3.3.9.0)
100
100
  ast (~> 2.4.1)
101
101
  racc
102
- prism (1.4.0)
102
+ prism (1.5.1)
103
103
  public_suffix (6.0.2)
104
- puma (7.0.2)
104
+ puma (7.0.3)
105
105
  nio4r (~> 2.0)
106
106
  qbash (0.4.5)
107
107
  backtrace (> 0)
@@ -121,9 +121,9 @@ GEM
121
121
  rack (>= 3)
122
122
  rainbow (3.1.1)
123
123
  rake (13.3.0)
124
- random-port (0.7.5)
125
- tago (> 0)
126
- regexp_parser (2.11.2)
124
+ random-port (0.7.6)
125
+ tago (~> 0.0)
126
+ regexp_parser (2.11.3)
127
127
  retries (0.0.5)
128
128
  rexml (3.4.4)
129
129
  rubocop (1.80.2)
@@ -137,7 +137,7 @@ GEM
137
137
  rubocop-ast (>= 1.46.0, < 2.0)
138
138
  ruby-progressbar (~> 1.7)
139
139
  unicode-display_width (>= 2.4.0, < 4.0)
140
- rubocop-ast (1.46.0)
140
+ rubocop-ast (1.47.1)
141
141
  parser (>= 3.3.7.2)
142
142
  prism (~> 1.4)
143
143
  rubocop-minitest (0.38.2)
@@ -13,5 +13,5 @@
13
13
  # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
14
14
  # License:: MIT
15
15
  class BazaRb
16
- VERSION = '0.10.2'
16
+ VERSION = '0.11.0'
17
17
  end
data/lib/baza-rb.rb CHANGED
@@ -102,21 +102,21 @@ class BazaRb
102
102
 
103
103
  # Push factbase to the server to create a new job.
104
104
  #
105
- # @param [String] name The unique name of the job on the server
105
+ # @param [String] name The unique name of the product on the server
106
106
  # @param [String] data The binary data to push to the server (factbase content)
107
107
  # @param [Array<String>] meta List of metadata strings to attach to the job
108
108
  # @param [Integer] chunk_size Maximum size of one chunk
109
109
  # @raise [ServerFailure] If the push operation fails
110
- def push(name, data, meta, chunk_size: DEFAULT_CHUNK_SIZE)
111
- raise 'The "name" of the job is nil' if name.nil?
112
- raise 'The "name" of the job may not be empty' if name.empty?
110
+ def push(pname, data, meta, chunk_size: DEFAULT_CHUNK_SIZE)
111
+ raise 'The "name" of the job is nil' if pname.nil?
112
+ raise 'The "name" of the job may not be empty' if pname.empty?
113
113
  raise 'The "data" of the job is nil' if data.nil?
114
114
  raise 'The "meta" of the job is nil' if meta.nil?
115
115
  elapsed(@loog) do
116
116
  Tempfile.open do |file|
117
117
  File.binwrite(file.path, data)
118
118
  upload(
119
- home.append('push').append(name),
119
+ home.append('push').append(pname),
120
120
  file.path,
121
121
  headers.merge(
122
122
  'X-Zerocracy-Meta' => meta.map { |v| Base64.encode64(v).delete("\n") }.join(' ')
@@ -217,41 +217,41 @@ class BazaRb
217
217
 
218
218
  # Lock the name.
219
219
  #
220
- # @param [String] name The name of the job on the server
220
+ # @param [String] pname The name of the product on the server
221
221
  # @param [String] owner The owner of the lock (any string)
222
222
  # @raise [RuntimeError] If the name is already locked
223
223
  # @raise [ServerFailure] If the lock operation fails
224
- def lock(name, owner)
225
- raise 'The "name" of the job is nil' if name.nil?
226
- raise 'The "name" of the job may not be empty' if name.empty?
224
+ def lock(pname, owner)
225
+ raise 'The "pname" of the product is nil' if pname.nil?
226
+ raise 'The "pname" of the product may not be empty' if pname.empty?
227
227
  raise 'The "owner" of the lock is nil' if owner.nil?
228
228
  elapsed(@loog) do
229
229
  ret = post(
230
- home.append('lock').append(name),
230
+ home.append('lock').append(pname),
231
231
  { 'owner' => owner },
232
232
  [302, 409]
233
233
  )
234
- throw :"Job name '#{name}' locked at #{@host}" if ret.code == 302
235
- raise "Failed to lock '#{name}' job at #{@host}, it's already locked"
234
+ throw :"Product name #{pname.inspect} locked at #{@host}" if ret.code == 302
235
+ raise "Failed to lock #{pname.inspect} product at #{@host}, it's already locked"
236
236
  end
237
237
  end
238
238
 
239
239
  # Unlock the name.
240
240
  #
241
- # @param [String] name The name of the job on the server
241
+ # @param [String] pname The name of the job on the server
242
242
  # @param [String] owner The owner of the lock (any string)
243
243
  # @raise [ServerFailure] If the unlock operation fails
244
- def unlock(name, owner)
245
- raise 'The "name" of the job is nil' if name.nil?
246
- raise 'The "name" of the job may not be empty' if name.empty?
244
+ def unlock(pname, owner)
245
+ raise 'The "pname" of the job is nil' if pname.nil?
246
+ raise 'The "pname" of the job may not be empty' if pname.empty?
247
247
  raise 'The "owner" of the lock is nil' if owner.nil?
248
248
  raise 'The "owner" of the lock may not be empty' if owner.empty?
249
249
  elapsed(@loog) do
250
250
  post(
251
- home.append('unlock').append(name),
251
+ home.append('unlock').append(pname),
252
252
  { 'owner' => owner }
253
253
  )
254
- throw :"Job name '#{name}' unlocked at #{@host}"
254
+ throw :"Job name #{pname.inspect} unlocked at #{@host}"
255
255
  end
256
256
  end
257
257
 
@@ -274,16 +274,16 @@ class BazaRb
274
274
 
275
275
  # Check whether the name of the job exists on the server.
276
276
  #
277
- # @param [String] name The name of the job on the server
277
+ # @param [String] name The name of the product on the server
278
278
  # @return [Boolean] TRUE if such name exists
279
- def name_exists?(name)
280
- raise 'The "name" of the job is nil' if name.nil?
281
- raise 'The "name" of the job may not be empty' if name.empty?
279
+ def name_exists?(pname)
280
+ raise 'The "pname" of the product is nil' if pname.nil?
281
+ raise 'The "pname" of the product may not be empty' if pname.empty?
282
282
  exists = false
283
283
  elapsed(@loog) do
284
- ret = get(home.append('exists').append(name))
284
+ ret = get(home.append('exists').append(pname))
285
285
  exists = ret.body == 'yes'
286
- throw :"The name \"#{name}\" #{exists ? 'exists' : "doesn't exist"} at #{@host}"
286
+ throw :"The name #{pname.inspect} #{exists ? 'exists' : "doesn't exist"} at #{@host}"
287
287
  end
288
288
  exists
289
289
  end
@@ -295,13 +295,13 @@ class BazaRb
295
295
  # ignored. It is expected to use only small placeholder files, not real
296
296
  # data.
297
297
  #
298
- # @param [String] jname The name of the job on the server
298
+ # @param [String] pname The name of the product on the server
299
299
  # @param [String] file The path to the file to upload
300
300
  # @return [Integer] The ID of the created durable
301
301
  # @raise [ServerFailure] If the upload fails
302
- def durable_place(jname, file)
303
- raise 'The "jname" of the durable is nil' if jname.nil?
304
- raise 'The "jname" of the durable may not be empty' if jname.empty?
302
+ def durable_place(pname, file)
303
+ raise 'The "pname" of the durable is nil' if pname.nil?
304
+ raise 'The "pname" of the durable may not be empty' if pname.empty?
305
305
  raise 'The "file" of the durable is nil' if file.nil?
306
306
  raise "The file '#{file}' is absent" unless File.exist?(file)
307
307
  if File.size(file) > 1024
@@ -312,13 +312,14 @@ class BazaRb
312
312
  ret = post(
313
313
  home.append('durables').append('place'),
314
314
  {
315
- 'jname' => jname,
315
+ 'pname' => pname,
316
+ 'jname' => pname,
316
317
  'file' => File.basename(file),
317
318
  'zip' => File.open(file, 'rb')
318
319
  }
319
320
  )
320
321
  id = ret.headers['X-Zerocracy-DurableId'].to_i
321
- throw :"Durable ##{id} (#{file}, #{File.size(file)} bytes) placed for job \"#{jname}\" at #{@host}"
322
+ throw :"Durable ##{id} (#{file}, #{File.size(file)} bytes) placed for job \"#{pname}\" at #{@host}"
322
323
  end
323
324
  id
324
325
  end
@@ -399,22 +400,22 @@ class BazaRb
399
400
 
400
401
  # Find a durable by job name and file name.
401
402
  #
402
- # @param [String] jname The name of the job
403
+ # @param [String] pname The name of the job
403
404
  # @param [String] file The file name
404
405
  # @return [Integer, nil] The ID of the durable if found, nil if not found
405
- def durable_find(jname, file)
406
- raise 'The "jname" is nil' if jname.nil?
407
- raise 'The "jname" may not be empty' if jname.empty?
406
+ def durable_find(pname, file)
407
+ raise 'The "pname" is nil' if pname.nil?
408
+ raise 'The "pname" may not be empty' if pname.empty?
408
409
  raise 'The "file" is nil' if file.nil?
409
410
  raise 'The "file" may not be empty' if file.empty?
410
411
  id = nil
411
412
  elapsed(@loog) do
412
- ret = get(home.append('durables').append('find').add(jname:, file:), [200, 404])
413
+ ret = get(home.append('durables').append('find').add(jname: pname, pname:, file:), [200, 404])
413
414
  if ret.code == 200
414
415
  id = ret.body.to_i
415
- throw :"Found durable ##{id} for job \"#{jname}\" file \"#{file}\" at #{@host}"
416
+ throw :"Found durable ##{id} for job \"#{pname}\" file \"#{file}\" at #{@host}"
416
417
  else
417
- throw :"Durable not found for job \"#{jname}\" file \"#{file}\" at #{@host}"
418
+ throw :"Durable not found for job \"#{pname}\" file \"#{file}\" at #{@host}"
418
419
  end
419
420
  end
420
421
  id
@@ -530,15 +531,15 @@ class BazaRb
530
531
  # for the given badge already exists, it's returned. Otherwise, the block
531
532
  # is executed and its result is cached.
532
533
  #
533
- # @param [String] name Name of the job
534
+ # @param [String] name Name of the product
534
535
  # @param [String] badge Unique identifier for this valve/computation
535
536
  # @param [String] why The reason/description for entering this valve
536
537
  # @param [nil|Integer] job Optional job ID to associate with this valve
537
538
  # @yield Block that computes the result if not cached
538
539
  # @return [String] The cached result or newly computed result from the block
539
540
  # @raise [ServerFailure] If the valve operation fails
540
- def enter(name, badge, why, job)
541
- elapsed(@loog, good: "Entered valve #{badge} to #{name}") do
541
+ def enter(pname, badge, why, job)
542
+ elapsed(@loog, good: "Entered valve #{badge} to #{pname}") do
542
543
  retry_it do
543
544
  ret = get(home.append('valves').append('result').add(badge:), [200, 204])
544
545
  return ret.body if ret.code == 200
@@ -548,7 +549,8 @@ class BazaRb
548
549
  post(
549
550
  uri,
550
551
  {
551
- 'name' => name,
552
+ 'name' => pname,
553
+ 'pname' => pname,
552
554
  'badge' => badge,
553
555
  'why' => why,
554
556
  'result' => r.to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baza.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko