zold 0.9.2 → 0.9.3
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/bin/zold +2 -0
- data/lib/zold/commands/clean.rb +1 -1
- data/lib/zold/copies.rb +2 -2
- data/lib/zold/node/entrance.rb +2 -0
- data/lib/zold/version.rb +1 -1
- data/test/test__helper.rb +2 -2
- data/test/test_copies.rb +19 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6811821f5b8eed50d2d11c0e972ee9a91ba1a7e
|
4
|
+
data.tar.gz: f4cfbe65254ee35788815494b7529d9cae6447e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 370fbc1d1a3b8df9369f9cfcd190849dd418e1af8f1d9a81c4257887cefac1b6427ba3072763793d29ec30864101f9268bdad7a6cedf7d55bca70441d897b3e0
|
7
|
+
data.tar.gz: 0d719f61975a5f6d7dadfe6a79b0fe40d05f98d71db97a6566b5d4c6fecc5e498f830a08f95748be5ac1332baec03b9df622f3d6b852350a7714fe18f6af0b0f
|
data/bin/zold
CHANGED
@@ -160,6 +160,8 @@ Available options:"
|
|
160
160
|
Zold::Fetch.new(wallets: wallets, remotes: remotes, copies: copies, log: log).run(args)
|
161
161
|
require_relative '../lib/zold/commands/merge'
|
162
162
|
Zold::Merge.new(wallets: wallets, copies: copies, log: log).run(args)
|
163
|
+
require_relative '../lib/zold/commands/clean'
|
164
|
+
Zold::Clean.new(copies: copies, log: log).run(args)
|
163
165
|
when 'taxes'
|
164
166
|
require_relative '../lib/zold/commands/taxes'
|
165
167
|
Zold::Taxes.new(wallets: wallets, log: log).run(args)
|
data/lib/zold/commands/clean.rb
CHANGED
data/lib/zold/copies.rb
CHANGED
@@ -91,9 +91,9 @@ module Zold
|
|
91
91
|
{
|
92
92
|
name: name,
|
93
93
|
path: File.join(@dir, name),
|
94
|
-
score: scores.select { |s| s[:time] > Time.now - 24 * 60 }
|
94
|
+
score: scores.select { |s| s[:time] > Time.now - 24 * 60 * 60 }
|
95
95
|
.map { |s| s[:score] }
|
96
|
-
.inject(&:+)
|
96
|
+
.inject(&:+) || 0
|
97
97
|
}
|
98
98
|
end
|
99
99
|
end
|
data/lib/zold/node/entrance.rb
CHANGED
@@ -28,6 +28,7 @@ require_relative '../tax'
|
|
28
28
|
require_relative '../commands/merge'
|
29
29
|
require_relative '../commands/fetch'
|
30
30
|
require_relative '../commands/push'
|
31
|
+
require_relative '../commands/clean'
|
31
32
|
|
32
33
|
# The entrance of the web front.
|
33
34
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
@@ -81,6 +82,7 @@ module Zold
|
|
81
82
|
Push.new(
|
82
83
|
wallets: @wallets, remotes: @remotes, log: @log
|
83
84
|
).run(['push'] + modified.map(&:to_s))
|
85
|
+
Clean.new(copies: copies.root, log: @log).run(['clean', id.to_s])
|
84
86
|
modified
|
85
87
|
end
|
86
88
|
end
|
data/lib/zold/version.rb
CHANGED
data/test/test__helper.rb
CHANGED
@@ -30,8 +30,8 @@ if ENV['CI'] == 'true'
|
|
30
30
|
end
|
31
31
|
|
32
32
|
require_relative '../lib/zold/log'
|
33
|
-
$log = Zold::Log::Quiet.new
|
34
|
-
|
33
|
+
# $log = Zold::Log::Quiet.new
|
34
|
+
$log = Zold::Log::Verbose.new
|
35
35
|
|
36
36
|
require 'minitest/autorun'
|
37
37
|
require_relative '../lib/zold'
|
data/test/test_copies.rb
CHANGED
@@ -62,12 +62,29 @@ class TestCopies < Minitest::Test
|
|
62
62
|
def test_cleans_copies
|
63
63
|
Dir.mktmpdir 'test' do |dir|
|
64
64
|
copies = Zold::Copies.new(dir)
|
65
|
-
copies.add('h1', 'zold.io', 50, 80, Time.now - 25 * 60)
|
66
|
-
copies.add('h1', 'zold.io', 33, 80, Time.now - 26 * 60)
|
65
|
+
copies.add('h1', 'zold.io', 50, 80, Time.now - 25 * 60 * 60)
|
66
|
+
copies.add('h1', 'zold.io', 33, 80, Time.now - 26 * 60 * 60)
|
67
67
|
assert(File.exist?(File.join(dir, '1')))
|
68
68
|
copies.clean
|
69
69
|
assert(copies.all.empty?, "#{copies.all.count} is not empty")
|
70
70
|
assert(!File.exist?(File.join(dir, '1')))
|
71
71
|
end
|
72
72
|
end
|
73
|
+
|
74
|
+
def test_ignores_garbage
|
75
|
+
Dir.mktmpdir 'test' do |dir|
|
76
|
+
copies = Zold::Copies.new(dir)
|
77
|
+
copies.add('h1', 'zold.io', 50, 80, Time.now - 25 * 60 * 60)
|
78
|
+
FileUtils.mkdir(File.join(dir, '55'))
|
79
|
+
assert_equal(1, copies.all.count)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_ignores_too_old_scores
|
84
|
+
Dir.mktmpdir 'test' do |dir|
|
85
|
+
copies = Zold::Copies.new(dir)
|
86
|
+
copies.add('h1', 'zold.io', 50, 80, Time.now - 1000 * 60 * 60)
|
87
|
+
assert_equal(0, copies.all[0][:score])
|
88
|
+
end
|
89
|
+
end
|
73
90
|
end
|