baza.rb 0.0.2 → 0.0.3
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 +4 -4
- data/.rubocop.yml +2 -0
- data/.rultor.yml +2 -2
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/baza.rb.gemspec +1 -1
- data/lib/{baza → baza-rb}/version.rb +1 -1
- data/lib/{baza.rb → baza-rb.rb} +5 -2
- data/test/{test_baza.rb → test_baza-rb.rb} +34 -71
- metadata +5 -5
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/.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
@@ -222,6 +222,7 @@ GEM
|
|
222
222
|
unicode-display_width (2.5.0)
|
223
223
|
uri (0.13.0)
|
224
224
|
useragent (0.16.10)
|
225
|
+
wait_for (0.1.1)
|
225
226
|
webmock (3.23.1)
|
226
227
|
addressable (>= 2.8.0)
|
227
228
|
crack (>= 0.3.2)
|
@@ -252,6 +253,7 @@ DEPENDENCIES
|
|
252
253
|
rubocop-rspec (= 3.0.4)
|
253
254
|
simplecov (= 0.22.0)
|
254
255
|
simplecov-cobertura (= 2.1.0)
|
256
|
+
wait_for (~> 0)
|
255
257
|
webmock (= 3.23.1)
|
256
258
|
yard (= 0.9.36)
|
257
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=
|
data/lib/{baza.rb → baza-rb.rb}
RENAMED
@@ -26,7 +26,7 @@ require 'iri'
|
|
26
26
|
require 'loog'
|
27
27
|
require 'base64'
|
28
28
|
require 'tago'
|
29
|
-
require_relative 'baza/version'
|
29
|
+
require_relative 'baza-rb/version'
|
30
30
|
|
31
31
|
# Interface to the API of zerocracy.com.
|
32
32
|
#
|
@@ -37,7 +37,7 @@ require_relative 'baza/version'
|
|
37
37
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
38
38
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
39
39
|
# License:: MIT
|
40
|
-
class
|
40
|
+
class BazaRb
|
41
41
|
def initialize(host, port, token, ssl: true, timeout: 30, retries: 3, loog: Loog::NULL, compression: true)
|
42
42
|
@host = host
|
43
43
|
@port = port
|
@@ -262,6 +262,7 @@ class Baza
|
|
262
262
|
# @param [String] jname The name of the job on the server
|
263
263
|
# @param [String] file The file name
|
264
264
|
def durable_place(jname, file)
|
265
|
+
raise "File '#{file}' is absent" unless File.exist?(file)
|
265
266
|
id = nil
|
266
267
|
elapsed(@loog) do
|
267
268
|
ret =
|
@@ -291,6 +292,7 @@ class Baza
|
|
291
292
|
# @param [Integer] id The ID of the durable
|
292
293
|
# @param [String] file The file to upload
|
293
294
|
def durable_save(id, file)
|
295
|
+
raise "File '#{file}' is absent" unless File.exist?(file)
|
294
296
|
elapsed(@loog) do
|
295
297
|
with_retries(max_tries: @retries) do
|
296
298
|
checked(
|
@@ -311,6 +313,7 @@ class Baza
|
|
311
313
|
# @param [Integer] id The ID of the durable
|
312
314
|
# @param [String] file The file to upload
|
313
315
|
def durable_load(id, file)
|
316
|
+
FileUtils.mkdir_p(File.dirname(file))
|
314
317
|
elapsed(@loog) do
|
315
318
|
File.open(file, 'wb') do |f|
|
316
319
|
request = Typhoeus::Request.new(
|
@@ -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,55 +69,18 @@ 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 test_live_pull
|
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
|
98
|
-
WebMock.enable_net_connect!
|
99
|
-
skip unless we_are_online
|
100
|
-
id = LIVE.recent('zerocracy')
|
101
|
-
assert(!LIVE.exit_code(id).nil?)
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_live_lock_unlock
|
105
|
-
WebMock.enable_net_connect!
|
106
|
-
skip unless we_are_online
|
107
|
-
n = fake_name
|
108
|
-
owner = 'judges teesting'
|
109
|
-
assert(!LIVE.lock(n, owner).nil?)
|
110
|
-
assert(!LIVE.unlock(n, owner).nil?)
|
111
|
-
end
|
112
|
-
|
113
76
|
def test_live_durable_lock_unlock
|
114
77
|
WebMock.enable_net_connect!
|
115
78
|
skip unless we_are_online
|
116
79
|
Dir.mktmpdir do |dir|
|
117
|
-
file = File.join(dir,
|
80
|
+
file = File.join(dir, "#{fake_name}.bin")
|
118
81
|
File.binwrite(file, 'hello')
|
119
82
|
id = LIVE.durable_place(fake_name, file)
|
120
|
-
owner =
|
83
|
+
owner = fake_name
|
121
84
|
LIVE.durable_lock(id, owner)
|
122
85
|
LIVE.durable_load(id, file)
|
123
86
|
LIVE.durable_save(id, file)
|
@@ -133,7 +96,7 @@ class TestBaza < Minitest::Test
|
|
133
96
|
Dir.mktmpdir do |dir|
|
134
97
|
file = File.join(dir, 'test.bin')
|
135
98
|
File.binwrite(file, 'hello')
|
136
|
-
assert_equal(42,
|
99
|
+
assert_equal(42, BazaRb.new('example.org', 443, '000').durable_place('simple', file))
|
137
100
|
end
|
138
101
|
end
|
139
102
|
|
@@ -144,7 +107,7 @@ class TestBaza < Minitest::Test
|
|
144
107
|
)
|
145
108
|
assert_equal(
|
146
109
|
42,
|
147
|
-
|
110
|
+
BazaRb.new('example.org', 443, '000').push('simple', 'hello, world!', [])
|
148
111
|
)
|
149
112
|
end
|
150
113
|
|
@@ -155,7 +118,7 @@ class TestBaza < Minitest::Test
|
|
155
118
|
.to_return(status: 200, body: '42')
|
156
119
|
assert_equal(
|
157
120
|
42,
|
158
|
-
|
121
|
+
BazaRb.new('example.org', 443, '000').recent('simple')
|
159
122
|
)
|
160
123
|
end
|
161
124
|
|
@@ -165,7 +128,7 @@ class TestBaza < Minitest::Test
|
|
165
128
|
status: 200, body: 'yes'
|
166
129
|
)
|
167
130
|
assert(
|
168
|
-
|
131
|
+
BazaRb.new('example.org', 443, '000').name_exists?('simple')
|
169
132
|
)
|
170
133
|
end
|
171
134
|
|
@@ -175,7 +138,7 @@ class TestBaza < Minitest::Test
|
|
175
138
|
status: 200, body: '0'
|
176
139
|
)
|
177
140
|
assert(
|
178
|
-
|
141
|
+
BazaRb.new('example.org', 443, '000').exit_code(42).zero?
|
179
142
|
)
|
180
143
|
end
|
181
144
|
|
@@ -185,7 +148,7 @@ class TestBaza < Minitest::Test
|
|
185
148
|
status: 200, body: 'hello!'
|
186
149
|
)
|
187
150
|
assert(
|
188
|
-
!
|
151
|
+
!BazaRb.new('example.org', 443, '000').stdout(42).empty?
|
189
152
|
)
|
190
153
|
end
|
191
154
|
|
@@ -195,7 +158,7 @@ class TestBaza < Minitest::Test
|
|
195
158
|
status: 200, body: 'hello, world!'
|
196
159
|
)
|
197
160
|
assert(
|
198
|
-
|
161
|
+
BazaRb.new('example.org', 443, '000').pull(333).start_with?('hello')
|
199
162
|
)
|
200
163
|
end
|
201
164
|
|
@@ -269,7 +232,7 @@ class TestBaza < Minitest::Test
|
|
269
232
|
socket.puts "HTTP/1.1 #{code} OK\r\nContent-Length: #{response.length}\r\n\r\n#{response}"
|
270
233
|
socket.close
|
271
234
|
end
|
272
|
-
yield
|
235
|
+
yield BazaRb.new(host, port, '0000', **opts)
|
273
236
|
t.join
|
274
237
|
end
|
275
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
|
@@ -182,11 +182,11 @@ files:
|
|
182
182
|
- README.md
|
183
183
|
- Rakefile
|
184
184
|
- baza.rb.gemspec
|
185
|
-
- lib/baza.rb
|
186
|
-
- lib/baza/version.rb
|
185
|
+
- lib/baza-rb.rb
|
186
|
+
- lib/baza-rb/version.rb
|
187
187
|
- renovate.json
|
188
188
|
- test/test__helper.rb
|
189
|
-
- test/test_baza.rb
|
189
|
+
- test/test_baza-rb.rb
|
190
190
|
homepage: http://github.com/zerocracy/baza.rb
|
191
191
|
licenses:
|
192
192
|
- MIT
|