baza.rb 0.0.1 → 0.0.2
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/.github/workflows/rake.yml +1 -1
- data/Gemfile.lock +20 -16
- data/baza.rb.gemspec +4 -1
- data/lib/baza/version.rb +1 -1
- data/lib/baza.rb +129 -4
- data/test/test_baza.rb +28 -1
- metadata +19 -4
- 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: 014c248d64a458634ae5e0230dbffb3efe583b3290ba939b8dce3ed1f91f502b
|
|
4
|
+
data.tar.gz: 735858245c3ab0bf9d362d325a47e5304813a3b281e4cc78cafaf6ee066086cb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: da30b50601a6354138e593fffc3680cd2648b6c7b9eeb62d949301ef72e89c9446643f9b15dbca0b252d4e062af8a4b63f5ab3b71cf1ab2abad632427c7f7254
|
|
7
|
+
data.tar.gz: 3b394b41273005c73431ca4e191e6f3a653db0498504d59422ef5dacb4d8b8bc59d5cc4ee8c890a79cd2d05100109e8e6151e9f82686ede138bb0f00109bb0bd
|
data/.github/workflows/rake.yml
CHANGED
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,7 @@ 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)
|
|
221
225
|
webmock (3.23.1)
|
|
222
226
|
addressable (>= 2.8.0)
|
|
223
227
|
crack (>= 0.3.2)
|
data/baza.rb.gemspec
CHANGED
|
@@ -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/version.rb
CHANGED
data/lib/baza.rb
CHANGED
|
@@ -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/version'
|
|
29
30
|
|
|
30
31
|
# Interface to the API of zerocracy.com.
|
|
31
32
|
#
|
|
@@ -37,8 +38,6 @@ require_relative 'baza/elapsed'
|
|
|
37
38
|
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
|
38
39
|
# License:: MIT
|
|
39
40
|
class Baza
|
|
40
|
-
VERSION = '0.0.0'
|
|
41
|
-
|
|
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,118 @@ 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
|
+
id = nil
|
|
266
|
+
elapsed(@loog) do
|
|
267
|
+
ret =
|
|
268
|
+
with_retries(max_tries: @retries) do
|
|
269
|
+
checked(
|
|
270
|
+
Typhoeus::Request.post(
|
|
271
|
+
home.append('durables').append('place').to_s,
|
|
272
|
+
body: {
|
|
273
|
+
'jname' => jname,
|
|
274
|
+
'file' => File.basename(file),
|
|
275
|
+
'zip' => File.open(file, 'r')
|
|
276
|
+
},
|
|
277
|
+
headers:,
|
|
278
|
+
connecttimeout: @timeout,
|
|
279
|
+
timeout: @timeout
|
|
280
|
+
),
|
|
281
|
+
302
|
|
282
|
+
)
|
|
283
|
+
end
|
|
284
|
+
id = ret.headers['X-Zerocracy-DurableId'].to_i
|
|
285
|
+
throw :"Durable ##{id} placed for job \"#{jname}\" at #{@host}"
|
|
286
|
+
end
|
|
287
|
+
id
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
# Save a single durable from local file to server.
|
|
291
|
+
# @param [Integer] id The ID of the durable
|
|
292
|
+
# @param [String] file The file to upload
|
|
293
|
+
def durable_save(id, file)
|
|
294
|
+
elapsed(@loog) do
|
|
295
|
+
with_retries(max_tries: @retries) do
|
|
296
|
+
checked(
|
|
297
|
+
Typhoeus::Request.put(
|
|
298
|
+
home.append('durables').append(id).to_s,
|
|
299
|
+
body: File.binread(file),
|
|
300
|
+
headers:,
|
|
301
|
+
connecttimeout: @timeout,
|
|
302
|
+
timeout: @timeout
|
|
303
|
+
)
|
|
304
|
+
)
|
|
305
|
+
end
|
|
306
|
+
throw :"Durable ##{id} saved #{File.size(file)} bytes to #{@host}"
|
|
307
|
+
end
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
# Load a single durable from server to local file.
|
|
311
|
+
# @param [Integer] id The ID of the durable
|
|
312
|
+
# @param [String] file The file to upload
|
|
313
|
+
def durable_load(id, file)
|
|
314
|
+
elapsed(@loog) do
|
|
315
|
+
File.open(file, 'wb') do |f|
|
|
316
|
+
request = Typhoeus::Request.new(
|
|
317
|
+
home.append('durables').append(id).to_s,
|
|
318
|
+
method: :get,
|
|
319
|
+
headers: headers.merge(
|
|
320
|
+
'Accept' => 'application/octet-stream'
|
|
321
|
+
),
|
|
322
|
+
connecttimeout: @timeout,
|
|
323
|
+
timeout: @timeout
|
|
324
|
+
)
|
|
325
|
+
request.on_body do |chunk|
|
|
326
|
+
f.write(chunk)
|
|
327
|
+
end
|
|
328
|
+
with_retries(max_tries: @retries) do
|
|
329
|
+
request.run
|
|
330
|
+
end
|
|
331
|
+
checked(request.response)
|
|
332
|
+
end
|
|
333
|
+
throw :"Durable ##{id} loaded #{File.size(file)} bytes from #{@host}"
|
|
334
|
+
end
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
# Lock a single durable.
|
|
338
|
+
# @param [Integer] id The ID of the durable
|
|
339
|
+
# @param [String] owner The owner of the lock
|
|
340
|
+
def durable_lock(id, owner)
|
|
341
|
+
elapsed(@loog) do
|
|
342
|
+
with_retries(max_tries: @retries) do
|
|
343
|
+
checked(
|
|
344
|
+
Typhoeus::Request.get(
|
|
345
|
+
home.append('durables').append(id).append('lock').add(owner:).to_s,
|
|
346
|
+
headers:
|
|
347
|
+
),
|
|
348
|
+
302
|
|
349
|
+
)
|
|
350
|
+
end
|
|
351
|
+
throw :"Durable ##{id} locked at #{@host}"
|
|
352
|
+
end
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
# Unlock a single durable.
|
|
356
|
+
# @param [Integer] id The ID of the durable
|
|
357
|
+
# @param [String] owner The owner of the lock
|
|
358
|
+
def durable_unlock(id, owner)
|
|
359
|
+
elapsed(@loog) do
|
|
360
|
+
with_retries(max_tries: @retries) do
|
|
361
|
+
checked(
|
|
362
|
+
Typhoeus::Request.get(
|
|
363
|
+
home.append('durables').append(id).append('unlock').add(owner:).to_s,
|
|
364
|
+
headers:
|
|
365
|
+
),
|
|
366
|
+
302
|
|
367
|
+
)
|
|
368
|
+
end
|
|
369
|
+
throw :"Durable ##{id} unlocked at #{@host}"
|
|
370
|
+
end
|
|
371
|
+
end
|
|
372
|
+
|
|
259
373
|
private
|
|
260
374
|
|
|
261
375
|
def headers
|
|
@@ -280,6 +394,17 @@ class Baza
|
|
|
280
394
|
params.merge(body:, headers:)
|
|
281
395
|
end
|
|
282
396
|
|
|
397
|
+
def elapsed(loog)
|
|
398
|
+
start = Time.now
|
|
399
|
+
begin
|
|
400
|
+
yield
|
|
401
|
+
rescue UncaughtThrowError => e
|
|
402
|
+
tag = e.tag
|
|
403
|
+
throw e unless tag.is_a?(Symbol)
|
|
404
|
+
loog.info("#{tag} in #{start.ago}")
|
|
405
|
+
end
|
|
406
|
+
end
|
|
407
|
+
|
|
283
408
|
def gzip(data)
|
|
284
409
|
''.dup.tap do |result|
|
|
285
410
|
io = StringIO.new(result)
|
data/test/test_baza.rb
CHANGED
|
@@ -40,7 +40,7 @@ class TestBaza < Minitest::Test
|
|
|
40
40
|
TOKEN = '00000000-0000-0000-0000-000000000000'
|
|
41
41
|
HOST = 'api.zerocracy.com'
|
|
42
42
|
PORT = 443
|
|
43
|
-
LIVE = Baza.new(HOST, PORT, TOKEN)
|
|
43
|
+
LIVE = Baza.new(HOST, PORT, TOKEN, loog: Loog::VERBOSE)
|
|
44
44
|
|
|
45
45
|
def test_live_recent_check
|
|
46
46
|
WebMock.enable_net_connect!
|
|
@@ -110,6 +110,33 @@ class TestBaza < Minitest::Test
|
|
|
110
110
|
assert(!LIVE.unlock(n, owner).nil?)
|
|
111
111
|
end
|
|
112
112
|
|
|
113
|
+
def test_live_durable_lock_unlock
|
|
114
|
+
WebMock.enable_net_connect!
|
|
115
|
+
skip unless we_are_online
|
|
116
|
+
Dir.mktmpdir do |dir|
|
|
117
|
+
file = File.join(dir, 'test.bin')
|
|
118
|
+
File.binwrite(file, 'hello')
|
|
119
|
+
id = LIVE.durable_place(fake_name, file)
|
|
120
|
+
owner = 'judges teesting'
|
|
121
|
+
LIVE.durable_lock(id, owner)
|
|
122
|
+
LIVE.durable_load(id, file)
|
|
123
|
+
LIVE.durable_save(id, file)
|
|
124
|
+
LIVE.durable_unlock(id, owner)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def test_durable_place
|
|
129
|
+
WebMock.disable_net_connect!
|
|
130
|
+
stub_request(:post, 'https://example.org/durables/place').to_return(
|
|
131
|
+
status: 302, headers: { 'X-Zerocracy-DurableId' => '42' }
|
|
132
|
+
)
|
|
133
|
+
Dir.mktmpdir do |dir|
|
|
134
|
+
file = File.join(dir, 'test.bin')
|
|
135
|
+
File.binwrite(file, 'hello')
|
|
136
|
+
assert_equal(42, Baza.new('example.org', 443, '000').durable_place('simple', file))
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
113
140
|
def test_simple_push
|
|
114
141
|
WebMock.disable_net_connect!
|
|
115
142
|
stub_request(:put, 'https://example.org/push/simple').to_return(
|
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.2
|
|
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-10 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: []
|
|
@@ -167,7 +183,6 @@ files:
|
|
|
167
183
|
- Rakefile
|
|
168
184
|
- baza.rb.gemspec
|
|
169
185
|
- lib/baza.rb
|
|
170
|
-
- lib/baza/elapsed.rb
|
|
171
186
|
- lib/baza/version.rb
|
|
172
187
|
- renovate.json
|
|
173
188
|
- test/test__helper.rb
|
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
|