judges 0.16.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db0130833063b43aab8a1dacec3106566da9c398fe539eea33eb8e76529d9d09
4
- data.tar.gz: 2ced92ba9c8896742ad493dc75be234864cef5690d0313a6a581ee7e12cb427a
3
+ metadata.gz: 6fde2252d089419bf5cb20dabc6368db3b70b7a7e6fb116624b3ec2f04811544
4
+ data.tar.gz: 80accd532717b42f176b2bcfc9510610e1dc43d9396ed670196782b923ef2c70
5
5
  SHA512:
6
- metadata.gz: d4393433a51dfdbabec4e6b8c09d9a02255fc18f76022f571a9633abf73c9f4bc9783ef1b4175dca14f35a939f5cc043f6052f928c5798206d40bda22667e6d7
7
- data.tar.gz: b4e7653eb03bec4c3ec08a4060c594d1ded0bbe63e24357bce24bab52e4dee1d74615ac7199bbbf09b485c51072c997f513d71011c3fef4147a46c378bf786cd
6
+ metadata.gz: 3bbdd338bea78fe3d8890b7f581d80081828e3391b738fdbf7a507751f5fab1897764e13dea952ecb5fa2c210c2baa577fb72b1b4d5b6e3994aec49d78eea1b4
7
+ data.tar.gz: 1e514af2b34b531fbdc70337d3183aeb54d47f8127cda4145ce735724dc7a029e237e09b3c445876c413c1e3c0c660015c648bceef20661fb8b430e00d739692
data/Gemfile CHANGED
@@ -31,7 +31,7 @@ gem 'random-port', '~>0.0', require: false
31
31
  gem 'rspec-rails', '6.1.3', require: false
32
32
  gem 'rubocop', '1.65.0', require: false
33
33
  gem 'rubocop-performance', '1.21.1', require: false
34
- gem 'rubocop-rspec', '3.0.2', require: false
34
+ gem 'rubocop-rspec', '3.0.3', require: false
35
35
  gem 'simplecov', '0.22.0', require: false
36
36
  gem 'simplecov-cobertura', '2.1.0', require: false
37
37
  gem 'webmock', '3.23.1', require: false
data/Gemfile.lock CHANGED
@@ -216,7 +216,7 @@ GEM
216
216
  rubocop-performance (1.21.1)
217
217
  rubocop (>= 1.48.1, < 2.0)
218
218
  rubocop-ast (>= 1.31.1, < 2.0)
219
- rubocop-rspec (3.0.2)
219
+ rubocop-rspec (3.0.3)
220
220
  rubocop (~> 1.61)
221
221
  ruby-progressbar (1.13.0)
222
222
  simplecov (0.22.0)
@@ -267,7 +267,7 @@ DEPENDENCIES
267
267
  rspec-rails (= 6.1.3)
268
268
  rubocop (= 1.65.0)
269
269
  rubocop-performance (= 1.21.1)
270
- rubocop-rspec (= 3.0.2)
270
+ rubocop-rspec (= 3.0.3)
271
271
  simplecov (= 0.22.0)
272
272
  simplecov-cobertura (= 2.1.0)
273
273
  webmock (= 3.23.1)
data/bin/judges CHANGED
@@ -179,6 +179,8 @@ class App
179
179
  c.flag([:owner], default_value: 'default', type: String)
180
180
  c.desc 'Supplementary meta information about the upload (key:value)'
181
181
  c.flag([:meta], type: String, multiple: true)
182
+ c.desc 'How many times to retry'
183
+ c.flag([:retries], type: Integer, default_value: 3)
182
184
  c.action do |global, options, args|
183
185
  require_relative '../lib/judges/commands/push'
184
186
  Judges::Push.new(loog).run(options, args)
@@ -201,6 +203,8 @@ class App
201
203
  c.switch([:ssl], default_value: true)
202
204
  c.desc 'A unique name to use for a lock/unlock'
203
205
  c.flag([:owner], default_value: 'default', type: String)
206
+ c.desc 'How many times to retry'
207
+ c.flag([:retries], type: Integer, default_value: 3)
204
208
  c.action do |global, options, args|
205
209
  require_relative '../lib/judges/commands/pull'
206
210
  Judges::Pull.new(loog).run(options, args)
@@ -6,6 +6,6 @@ Feature: Push
6
6
  Given I make a temp directory
7
7
  Then I run bin/judges with "--verbose eval simple.fb '(0..1000).each { $fb.insert.foo = 42 }'"
8
8
  And Exit code is zero
9
- Then I run bin/judges with "push --token 00000000-0000-0000-0000-000000000000 --meta a:b --meta foo:bar simple simple.fb"
9
+ Then I run bin/judges with "push --token 00000000-0000-0000-0000-000000000000 --meta a:b --meta foo:bar --meta=pages_url:https://zerocracy.github.io/zerocracy.html --meta=duration:1055 simple simple.fb"
10
10
  Then Stdout contains "Pushed"
11
11
  And Exit code is zero
data/judges.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
27
27
  s.required_ruby_version = '>=3.2'
28
28
  s.name = 'judges'
29
- s.version = '0.16.0'
29
+ s.version = '0.17.0'
30
30
  s.license = 'MIT'
31
31
  s.summary = 'Command-Line Tool for a Factbase'
32
32
  s.description =
data/lib/judges/baza.rb CHANGED
@@ -34,7 +34,7 @@ require_relative '../judges/elapsed'
34
34
  # License:: MIT
35
35
  class Judges::Baza
36
36
  # rubocop:disable Metrics/ParameterLists
37
- def initialize(host, port, token, ssl: true, timeout: 30, loog: Loog::NULL)
37
+ def initialize(host, port, token, ssl: true, timeout: 30, retries: 3, loog: Loog::NULL)
38
38
  # rubocop:enable Metrics/ParameterLists
39
39
  @host = host
40
40
  @port = port
@@ -42,6 +42,7 @@ class Judges::Baza
42
42
  @token = token
43
43
  @timeout = timeout
44
44
  @loog = loog
45
+ @retries = retries
45
46
  end
46
47
 
47
48
  def push(name, data, meta)
@@ -50,9 +51,11 @@ class Judges::Baza
50
51
  'Content-Type' => 'application/octet-stream',
51
52
  'Content-Length' => data.size
52
53
  )
53
- hdrs = hdrs.merge('X-Zerocracy-Meta' => meta.map { |v| Base64.encode64(v).strip }.join(' ')) unless meta.empty?
54
+ unless meta.empty?
55
+ hdrs = hdrs.merge('X-Zerocracy-Meta' => meta.map { |v| Base64.encode64(v).gsub("\n", '') }.join(' '))
56
+ end
54
57
  elapsed(@loog) do
55
- ret = with_retries do
58
+ ret = with_retries(max_tries: @retries) do
56
59
  checked(
57
60
  Typhoeus::Request.put(
58
61
  home.append('push').append(name).to_s,
@@ -85,7 +88,9 @@ class Judges::Baza
85
88
  request.on_body do |chunk|
86
89
  f.write(chunk)
87
90
  end
88
- request.run
91
+ with_retries(max_tries: @retries) do
92
+ request.run
93
+ end
89
94
  checked(request.response)
90
95
  end
91
96
  data = File.binread(file)
@@ -99,7 +104,7 @@ class Judges::Baza
99
104
  def finished?(id)
100
105
  finished = false
101
106
  elapsed(@loog) do
102
- ret = with_retries do
107
+ ret = with_retries(max_tries: @retries) do
103
108
  checked(
104
109
  Typhoeus::Request.get(
105
110
  home.append('finished').append(id).to_s,
@@ -116,7 +121,7 @@ class Judges::Baza
116
121
  # Lock the name.
117
122
  def lock(name, owner)
118
123
  elapsed(@loog) do
119
- with_retries do
124
+ with_retries(max_tries: @retries) do
120
125
  checked(
121
126
  Typhoeus::Request.get(
122
127
  home.append('lock').append(name).add(owner:).to_s,
@@ -131,7 +136,7 @@ class Judges::Baza
131
136
  # Unlock the name.
132
137
  def unlock(name, owner)
133
138
  elapsed(@loog) do
134
- with_retries do
139
+ with_retries(max_tries: @retries) do
135
140
  checked(
136
141
  Typhoeus::Request.get(
137
142
  home.append('unlock').append(name).add(owner:).to_s,
@@ -146,7 +151,7 @@ class Judges::Baza
146
151
  def recent(name)
147
152
  job = 0
148
153
  elapsed(@loog) do
149
- ret = with_retries do
154
+ ret = with_retries(max_tries: @retries) do
150
155
  checked(
151
156
  Typhoeus::Request.get(
152
157
  home.append('recent').append("#{name}.txt").to_s,
@@ -163,7 +168,7 @@ class Judges::Baza
163
168
  def name_exists?(name)
164
169
  exists = 0
165
170
  elapsed(@loog) do
166
- ret = with_retries do
171
+ ret = with_retries(max_tries: @retries) do
167
172
  checked(
168
173
  Typhoeus::Request.get(
169
174
  home.append('exists').append(name).to_s,
@@ -42,7 +42,8 @@ class Judges::Pull
42
42
  opts['host'], opts['port'].to_i, opts['token'],
43
43
  ssl: opts['ssl'],
44
44
  timeout: (opts['timeout'] || 30).to_i,
45
- loog: @loog
45
+ loog: @loog,
46
+ retries: (opts['retries'] || 3).to_i
46
47
  )
47
48
  name = args[0]
48
49
  elapsed(@loog) do
@@ -43,7 +43,8 @@ class Judges::Push
43
43
  opts['host'], opts['port'].to_i, opts['token'],
44
44
  ssl: opts['ssl'],
45
45
  timeout: (opts['timeout'] || 30).to_i,
46
- loog: @loog
46
+ loog: @loog,
47
+ retries: (opts['retries'] || 3).to_i
47
48
  )
48
49
  elapsed(@loog) do
49
50
  baza.lock(name, opts['owner'])
data/lib/judges.rb CHANGED
@@ -25,5 +25,5 @@
25
25
  # Copyright:: Copyright (c) 2024 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Judges
28
- VERSION = '0.16.0'
28
+ VERSION = '0.17.0'
29
29
  end
data/test/test_baza.rb CHANGED
@@ -89,6 +89,21 @@ class TestBaza < Minitest::Test
89
89
  assert(req.include?("X-Zerocracy-Meta: Ym9vbSE= 0YXQtdC5IQ==\r\n"))
90
90
  end
91
91
 
92
+ def test_push_with_big_meta
93
+ req = with_http_server(200, 'yes') do |baza|
94
+ baza.push(
95
+ 'simple',
96
+ 'hello, world!',
97
+ [
98
+ 'pages_url:https://zerocracy.github.io/zerocracy.html',
99
+ 'others:https://zerocracy.github.io/zerocracy.html',
100
+ 'duration:59595'
101
+ ]
102
+ )
103
+ end
104
+ assert(req.join.include?('X-Zerocracy-Meta: '))
105
+ end
106
+
92
107
  private
93
108
 
94
109
  def with_http_server(code, response)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judges
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko