zold 0.14.24 → 0.14.25

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
  SHA1:
3
- metadata.gz: e8d71880e2c5c0b0d18b9af54c062dc5782bdca4
4
- data.tar.gz: b25ac38601d91489b7da16813a96784edd57bcb7
3
+ metadata.gz: 9b9ff618493d8f11a6c1afde18902fd7a314646f
4
+ data.tar.gz: f71b0e5dfc59c87984577c4b89177b67553d67ac
5
5
  SHA512:
6
- metadata.gz: fd62a234221ae8733f83d090637c66730fb694743a63bd126604f92384986d6db36d1cd865cc6002ff384fb68411e4cfcae929abe478a3a7932b3687c193ca3d
7
- data.tar.gz: 89f71e08e1dfa5ca33cd63f2274c78f2441098053d5145dfdbf01cb0b9f0dc19a5179b58bbe317476a70eb7eaaa62cadaf19e2d130da7bb4880eeaf56079c516
6
+ metadata.gz: '038d20d582f5367e772aa240812a5bf4367417bf350417bec4d2cc206005ff128f77acb64aa1a2fe43c31ce9621b4639be0cbb43eedb2977ff0140628893eea8'
7
+ data.tar.gz: c868c40269b7cb3504acb629ef40f7b24c3cd17ca9e2341ecaa0d1b2d61ce52fc031ddbac868b86c2abfae4dba03756d73141bbf411fa1bde044bb1cc6d4adcc
@@ -155,7 +155,7 @@ while #{settings.address} is in '#{settings.network}'"
155
155
  score: score.to_h,
156
156
  pid: Process.pid,
157
157
  cpus: Concurrent.processor_count,
158
- memory: GetProcessMem.new.inspect.bytes,
158
+ memory: GetProcessMem.new.bytes,
159
159
  platform: RUBY_PLATFORM,
160
160
  uptime: `uptime`.strip,
161
161
  threads: "#{Thread.list.select { |t| t.status == 'run' }.count}/#{Thread.list.count}",
data/lib/zold/remotes.rb CHANGED
@@ -112,14 +112,16 @@ module Zold
112
112
  end
113
113
 
114
114
  def all
115
- list = load
116
- max_score = list.map { |r| r[:score] }.max || 0
117
- max_score = 1 if max_score.zero?
118
- max_errors = list.map { |r| r[:errors] }.max || 0
119
- max_errors = 1 if max_errors.zero?
120
- list.sort_by do |r|
121
- (1 - r[:errors] / max_errors) * 5 + (r[:score] / max_score)
122
- end.reverse
115
+ @mutex.synchronize do
116
+ list = load
117
+ max_score = list.map { |r| r[:score] }.max || 0
118
+ max_score = 1 if max_score.zero?
119
+ max_errors = list.map { |r| r[:errors] }.max || 0
120
+ max_errors = 1 if max_errors.zero?
121
+ list.sort_by do |r|
122
+ (1 - r[:errors] / max_errors) * 5 + (r[:score] / max_score)
123
+ end.reverse
124
+ end
123
125
  end
124
126
 
125
127
  def clean
@@ -206,9 +208,11 @@ in #{(Time.now - start).round}s; errors=#{errors}")
206
208
  raise 'Host can\'t be nil' if host.nil?
207
209
  raise 'Port can\'t be nil' if port.nil?
208
210
  raise 'Port has to be of type Integer' unless port.is_a?(Integer)
209
- list = load
210
- raise "#{host}:#{port} is absent among #{list.count} remotes" unless exists?(host, port)
211
- list.find { |r| r[:host] == host.downcase && r[:port] == port }[:errors]
211
+ @mutex.synchronize do
212
+ list = load
213
+ raise "#{host}:#{port} is absent among #{list.count} remotes" unless exists?(host, port)
214
+ list.find { |r| r[:host] == host.downcase && r[:port] == port }[:errors]
215
+ end
212
216
  end
213
217
 
214
218
  def error(host, port = Remotes::PORT)
data/lib/zold/version.rb CHANGED
@@ -25,6 +25,6 @@
25
25
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Zold
28
- VERSION = '0.14.24'
28
+ VERSION = '0.14.25'
29
29
  PROTOCOL = 2
30
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.24
4
+ version: 0.14.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko