zold 0.9.8 → 0.9.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a1fe0556c59991b4873cb362661f1219a802045a
4
- data.tar.gz: 9161e7ea2aaf095a0aef9786976e4945374eecae
3
+ metadata.gz: 7c40986afca66ce8e25fa3d5f541d08f86f1a8d7
4
+ data.tar.gz: f298fd1349836b966c67737f0be441d64d9f2d1f
5
5
  SHA512:
6
- metadata.gz: 4c64ca5bcc066626a4284f1c7d2a862bf4cac4c0f2e47a1389d41627514f5f3a41051461c3a0d22bc65a443579af6db10884573d10dabc1422dd845e8ee85628
7
- data.tar.gz: 4f84a775746b409d45e2c36f7c67afe9a8b6696ab8ba78a7afafa0e29c7aa265ad465d9563a9bce18a4dc0f5daf2e5018771a98a29bd3d3454c9aa6e0180ad70
6
+ metadata.gz: 5dccd8983578baaa765f8dcb05ec8db7bb6ea5682c05061a8f5419599494383a9ed8b83aa6097c433e0bcff01ca6bdd17d7d01e3c7c5190696849728510c8c5e
7
+ data.tar.gz: f42970b98d36f24bd10b3d249830f8b08b718b96e6a63ab4192b47ca08b299677f6095efce74df6efa61f98db1392dd085e55869f556e3c81bdd6b233e43c7b6
@@ -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 =~ /[0-9]+/ }.each do |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 =~ /[0-9]+/ }
69
+ .select { |f| f =~ /^[0-9]+$/ }
70
70
  .map(&:to_i)
71
71
  .max
72
72
  max = 0 if max.nil?
@@ -29,7 +29,7 @@ module Zold
29
29
  if id.nil?
30
30
  @id = rand(2**32..2**64 - 1)
31
31
  else
32
- raise "Invalid wallet ID '#{id}'" unless id =~ /[0-9a-fA-F]{16}/
32
+ raise "Invalid wallet ID '#{id}'" unless id =~ /^[0-9a-fA-F]{16}$/
33
33
  @id = Integer("0x#{id}", 16)
34
34
  end
35
35
  end
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Zold
26
- VERSION = '0.9.8'.freeze
26
+ VERSION = '0.9.9'.freeze
27
27
  end
@@ -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 =~ /[a-z]{4,16}/
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 =~ /[0-9]+(\.[0-9]+){1,2}/
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 =~ /[a-z]{4,16}/
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
 
@@ -50,7 +50,7 @@ module Zold
50
50
  file = File.join(@dir, f)
51
51
  File.file?(file) &&
52
52
  !File.directory?(file) &&
53
- f =~ /[0-9a-fA-F]{16}/ &&
53
+ f =~ /^[0-9a-fA-F]{16}$/ &&
54
54
  Id.new(f).to_s == f
55
55
  end
56
56
  end
@@ -28,6 +28,7 @@ require_relative '../lib/zold/key'
28
28
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
29
29
  # License:: MIT
30
30
  class FakeHome
31
+ attr_reader :dir
31
32
  def initialize(dir = Dir.pwd)
32
33
  @dir = dir
33
34
  end
@@ -19,7 +19,6 @@
19
19
  # SOFTWARE.
20
20
 
21
21
  require 'minitest/autorun'
22
- require 'tmpdir'
23
22
  require_relative 'fake_home'
24
23
  require_relative '../lib/zold/key'
25
24
  require_relative '../lib/zold/id'
@@ -19,7 +19,7 @@
19
19
  # SOFTWARE.
20
20
 
21
21
  require 'minitest/autorun'
22
- require 'tmpdir'
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
- Dir.mktmpdir 'test' do |dir|
35
- wallets = Zold::Wallets.new(dir)
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
- assert(wallets.all.count == 1, "#{wallets.all.count} is not equal to 1")
39
+ assert_equal(1, wallets.all.count)
40
40
  end
41
41
  end
42
42
 
43
- def test_lists_wallets
44
- Dir.mktmpdir 'z1' do |dir|
45
- wallets = Zold::Wallets.new(dir)
46
- FileUtils.touch(File.join(dir, 'hello'))
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
- assert(wallets.all.count == 1, "#{wallets.all.count} is not equal to 1")
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.8
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-27 00:00:00.000000000 Z
11
+ date: 2018-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby