lib/zold/copies.rb in zold-0.31.5 vs lib/zold/copies.rb in zold-0.31.6
- old
+ new
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-# Copyright (c) 2018-2023 Zerocracy, Inc.
+# Copyright (c) 2018-2023 Zerocracy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -122,11 +122,11 @@
.select { |f| File.basename(f, Copies::EXT) =~ /^[0-9]+$/ }
.map(&:to_i)
.max
max = 0 if max.nil?
name = (max + 1).to_s
- IO.write(File.join(@dir, "#{name}#{Copies::EXT}"), content)
+ File.write(File.join(@dir, "#{name}#{Copies::EXT}"), content)
else
name = target[:name]
end
list.reject! { |s| s[:host] == host && s[:port] == port }
list << {
@@ -148,11 +148,11 @@
{
name: name,
path: File.join(@dir, "#{name}#{Copies::EXT}"),
total: scores.count,
master: scores.any? { |s| s[:master] },
- score: scores.select { |s| s[:time] > Time.now - 24 * 60 * 60 }
+ score: scores.select { |s| s[:time] > Time.now - (24 * 60 * 60) }
.map { |s| s[:score] }
.inject(&:+) || 0
}
end.select { |c| File.exist?(c[:path]) }
if masters_first
@@ -180,10 +180,10 @@
end
private
def save(list)
- IO.write(
+ File.write(
file,
list.map do |r|
[
r[:name],
r[:host],