vpsadmin-client 3.0.0.master.20221118.pre.0.99dcc6de → 3.0.0.master.20231229.pre.0.51d41b07

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: be8e44144778361fe0bd564030b80f66efcdf734c6b81a1ae13c816c5d6ad853
4
- data.tar.gz: e6e0ed82d681b2c7f980430a4f141e687e867784a9a941ae66a6901ce6b1e1c6
3
+ metadata.gz: 2425fa19ffbaede49e519824309db37f814c21f983de4236fd607b018f47dc38
4
+ data.tar.gz: 8ce68f705e8e9faaa743ebafbf7f97b4552aee9f0ab84a9b727dd29f6d12a952
5
5
  SHA512:
6
- metadata.gz: 9f5ae2ef0e02b51ada7bc284457f3fb9ffadadcc0636a42ef8c82465642d2bd5c616b333f40769ed49d4ce4ac38db7f16a884ccf62e0abc33f9194e72db1930e
7
- data.tar.gz: fb68a389dc4602e2891d0b44d3e03556ca523cb2e647094fbedb1d0a069bdb16fee0508deaa7037ed25c708c7b2483a8b3b3d1a722b65cdc0ed9d14988d412f5
6
+ metadata.gz: da618f3160a4e45666076eec413da133637d3ae98a82ba27c4d3e552b325e8ee20efd7e88e86a09e0b382c65f84f6d5bace2382d6bd5daff3c40e5d7412c0df7
7
+ data.tar.gz: 6447e952db49a501e5b632a3cf7df223a1af1a76dbe4e7774abc9313977271ee7506d6259a9fab76ad274511247e79d693ead6e21cf3ebd1c8121a28d9e28786
@@ -292,7 +292,7 @@ END
292
292
  def safe_download(ds, snapshot, from_snapshot = nil)
293
293
  part, full = snapshot_tmp_file(snapshot, from_snapshot)
294
294
 
295
- if !File.exists?(full)
295
+ if !File.exist?(full)
296
296
  attempts = 0
297
297
 
298
298
  begin
@@ -212,7 +212,7 @@ module VpsAdmin::CLI::Commands
212
212
  p = c[:name]
213
213
 
214
214
  attron(A_BOLD) if p == @sort_param
215
- addstr(sprintf(" %#{c[:width]}s", unitize(data.send(p), data.delta)))
215
+ addstr(sprintf(" %#{c[:width]}s", unitize_param(p, data.send(p), data.delta)))
216
216
  attroff(A_BOLD) if p == @sort_param
217
217
  end
218
218
  end
@@ -259,18 +259,18 @@ module VpsAdmin::CLI::Commands
259
259
  ))
260
260
 
261
261
  setpos(lines-3, 0)
262
- addstr(sprintf(fmt, 'In', *fields.map { |f| unitize(stats[:"#{f}_in"], avg_delta) }))
262
+ addstr(sprintf(fmt, 'In', *fields.map { |f| unitize_param(f, stats[:"#{f}_in"], avg_delta) }))
263
263
 
264
264
  setpos(lines-2, 0)
265
- addstr(sprintf(fmt, 'Out', *fields.map { |f| unitize(stats[:"#{f}_out"], avg_delta) }))
265
+ addstr(sprintf(fmt, 'Out', *fields.map { |f| unitize_param(f, stats[:"#{f}_out"], avg_delta) }))
266
266
 
267
267
  setpos(lines-1, 0)
268
268
  attron(A_BOLD)
269
- addstr(sprintf(fmt, 'Total', *fields.map { |f| unitize(stats[:"#{f}_in"] + stats[:"#{f}_out"], avg_delta) }))
269
+ addstr(sprintf(fmt, 'Total', *fields.map { |f| unitize_param(f, stats[:"#{f}_in"] + stats[:"#{f}_out"], avg_delta) }))
270
270
  attroff(A_BOLD)
271
271
  end
272
272
 
273
- def unitize(n, delta)
273
+ def unitize_bytes(n, delta)
274
274
  if @opts[:unit] == :bytes
275
275
  per_s = n / delta.to_f
276
276
  else
@@ -278,7 +278,7 @@ module VpsAdmin::CLI::Commands
278
278
  end
279
279
 
280
280
  bits = 39
281
- units = %i(T G M K)
281
+ units = %w(T G M k)
282
282
 
283
283
  units.each do |u|
284
284
  threshold = 2 << bits
@@ -291,6 +291,31 @@ module VpsAdmin::CLI::Commands
291
291
  per_s.round(2).to_s
292
292
  end
293
293
 
294
+ def unitize_number(n, delta)
295
+ per_s = n / delta.to_f
296
+ threshold = 1_000_000_000_000
297
+ units = %w(T G M k)
298
+
299
+ units.each do |u|
300
+ return "#{(per_s / threshold).round(2)}#{u}" if per_s >= threshold
301
+
302
+ threshold /= 1000
303
+ end
304
+
305
+ per_s.round(2).to_s
306
+ end
307
+
308
+ def unitize_param(param, n, delta)
309
+ case param
310
+ when :bytes, :bytes_in, :bytes_out
311
+ unitize_bytes(n, delta)
312
+ when :packets, :packets_in, :packets_out
313
+ unitize_number(n, delta)
314
+ else
315
+ fail "unknown param to unitize: #{param.inspect}"
316
+ end
317
+ end
318
+
294
319
  def sort_next(n)
295
320
  cur_i = @params.index(@sort_param)
296
321
  next_i = cur_i + n
@@ -126,7 +126,7 @@ module VpsAdmin::CLI::Commands
126
126
  f = action = nil
127
127
  pos = 0
128
128
 
129
- if File.exists?(path) && File.size(path) > 0
129
+ if File.exist?(path) && File.size(path) > 0
130
130
  if @opts[:resume]
131
131
  action = :resume
132
132
 
@@ -1,5 +1,5 @@
1
1
  module VpsAdmin
2
2
  module Client
3
- VERSION = '3.0.0.master.20221118-0.99dcc6de'
3
+ VERSION = '3.0.0.master.20231229-0.51d41b07'
4
4
  end
5
5
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency 'bundler'
22
22
  spec.add_development_dependency 'rake'
23
23
 
24
- spec.add_runtime_dependency 'haveapi-client', '~> 0.15.1'
24
+ spec.add_runtime_dependency 'haveapi-client', '~> 0.19.0'
25
25
  spec.add_runtime_dependency 'json'
26
26
  spec.add_runtime_dependency 'curses'
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vpsadmin-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.master.20221118.pre.0.99dcc6de
4
+ version: 3.0.0.master.20231229.pre.0.51d41b07
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Skokan
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.15.1
47
+ version: 0.19.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.15.1
54
+ version: 0.19.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: json
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  - !ruby/object:Gem::Version
130
130
  version: 1.3.1
131
131
  requirements: []
132
- rubygems_version: 3.2.26
132
+ rubygems_version: 3.4.22
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: Ruby API and CLI for vpsAdmin API