zold 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zold/copies.rb +2 -2
- data/lib/zold/id.rb +1 -1
- data/lib/zold/version.rb +1 -1
- data/lib/zold/wallet.rb +3 -3
- data/lib/zold/wallets.rb +1 -1
- data/test/fake_home.rb +1 -0
- data/test/test_wallet.rb +0 -1
- data/test/test_wallets.rb +9 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c40986afca66ce8e25fa3d5f541d08f86f1a8d7
|
4
|
+
data.tar.gz: f298fd1349836b966c67737f0be441d64d9f2d1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dccd8983578baaa765f8dcb05ec8db7bb6ea5682c05061a8f5419599494383a9ed8b83aa6097c433e0bcff01ca6bdd17d7d01e3c7c5190696849728510c8c5e
|
7
|
+
data.tar.gz: f42970b98d36f24bd10b3d249830f8b08b718b96e6a63ab4192b47ca08b299677f6095efce74df6efa61f98db1392dd085e55869f556e3c81bdd6b233e43c7b6
|
data/lib/zold/copies.rb
CHANGED
@@ -44,7 +44,7 @@ module Zold
|
|
44
44
|
list = load
|
45
45
|
list.reject! { |s| s[:time] < Time.now - 24 * 60 * 60 }
|
46
46
|
save(list)
|
47
|
-
Dir.new(@dir).select { |f| f =~
|
47
|
+
Dir.new(@dir).select { |f| f =~ /^[0-9]+$/ }.each do |f|
|
48
48
|
File.delete(File.join(@dir, f)) if list.find { |s| s[:name] == f }.nil?
|
49
49
|
end
|
50
50
|
end
|
@@ -66,7 +66,7 @@ module Zold
|
|
66
66
|
target = list.find { |s| File.read(File.join(@dir, s[:name])) == content }
|
67
67
|
if target.nil?
|
68
68
|
max = Dir.new(@dir)
|
69
|
-
.select { |f| f =~
|
69
|
+
.select { |f| f =~ /^[0-9]+$/ }
|
70
70
|
.map(&:to_i)
|
71
71
|
.max
|
72
72
|
max = 0 if max.nil?
|
data/lib/zold/id.rb
CHANGED
data/lib/zold/version.rb
CHANGED
data/lib/zold/wallet.rb
CHANGED
@@ -57,13 +57,13 @@ module Zold
|
|
57
57
|
|
58
58
|
def network
|
59
59
|
n = lines[0].strip
|
60
|
-
raise "Invalid network name '#{n}'" unless n =~
|
60
|
+
raise "Invalid network name '#{n}'" unless n =~ /^[a-z]{4,16}$/
|
61
61
|
n
|
62
62
|
end
|
63
63
|
|
64
64
|
def version
|
65
65
|
v = lines[1].strip
|
66
|
-
raise "Invalid version name '#{v}'" unless v =~
|
66
|
+
raise "Invalid version name '#{v}'" unless v =~ /^[0-9]+(\.[0-9]+){1,2}$/
|
67
67
|
v
|
68
68
|
end
|
69
69
|
|
@@ -77,7 +77,7 @@ module Zold
|
|
77
77
|
|
78
78
|
def init(id, pubkey, overwrite: false, network: 'test')
|
79
79
|
raise "File '#{@file}' already exists" if File.exist?(@file) && !overwrite
|
80
|
-
raise "Invalid network name '#{network}'" unless network =~
|
80
|
+
raise "Invalid network name '#{network}'" unless network =~ /^[a-z]{4,16}$/
|
81
81
|
File.write(@file, "#{network}\n#{VERSION}\n#{id}\n#{pubkey.to_pub}\n\n")
|
82
82
|
end
|
83
83
|
|
data/lib/zold/wallets.rb
CHANGED
data/test/fake_home.rb
CHANGED
data/test/test_wallet.rb
CHANGED
data/test/test_wallets.rb
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
21
|
require 'minitest/autorun'
|
22
|
-
|
22
|
+
require_relative 'fake_home'
|
23
23
|
require_relative '../lib/zold/key'
|
24
24
|
require_relative '../lib/zold/id'
|
25
25
|
require_relative '../lib/zold/wallets'
|
@@ -31,23 +31,23 @@ require_relative '../lib/zold/amount'
|
|
31
31
|
# License:: MIT
|
32
32
|
class TestWallets < Minitest::Test
|
33
33
|
def test_adds_wallet
|
34
|
-
|
35
|
-
wallets =
|
34
|
+
FakeHome.new.run do |home|
|
35
|
+
wallets = home.wallets
|
36
36
|
id = Zold::Id.new
|
37
37
|
wallet = wallets.find(id)
|
38
38
|
wallet.init(id, Zold::Key.new(file: 'fixtures/id_rsa.pub'))
|
39
|
-
|
39
|
+
assert_equal(1, wallets.all.count)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
44
|
-
|
45
|
-
wallets =
|
46
|
-
FileUtils.touch(File.join(dir, '
|
43
|
+
def test_lists_wallets_and_ignores_garbage
|
44
|
+
FakeHome.new.run do |home|
|
45
|
+
wallets = home.wallets
|
46
|
+
FileUtils.touch(File.join(home.dir, '0xaaaaaaaaaaaaaaaaaaahello'))
|
47
47
|
id = Zold::Id.new
|
48
48
|
wallet = wallets.find(id)
|
49
49
|
wallet.init(id, Zold::Key.new(file: 'fixtures/id_rsa.pub'))
|
50
|
-
|
50
|
+
assert_equal(1, wallets.all.count)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|