zold 0.14.48 → 0.14.49

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
  SHA256:
3
- metadata.gz: 8f5b7d31f8bfda085dd9b8e8eed00aff31ce4d70c32458508e9cfb9f3057b93e
4
- data.tar.gz: 3baeace7cbb639c8c789e0d7131f2fb9c5a2d5a46f32f202ecd98e0ec1fb1300
3
+ metadata.gz: b3a66103ede11237d2ccfcdd1ce46a4e59eedd713a601443440459677c7f665e
4
+ data.tar.gz: 177d88b0030850e1d6848a7ef92b10873e23342b77f50ff2b2344c29dac4d99a
5
5
  SHA512:
6
- metadata.gz: 69c2ce749f200770aada7c0bd5d9afdde9574012b652597dd0b650f2a749fde65de16e7c8493b405f25de5c95775c211345cbb8fd3d8d8e6b566ff6967bd982f
7
- data.tar.gz: 3c6d7228040fb58970d9f96961e1db7efd3ea2468de61b30008dd280508e907e07110b13c24e81da5252ee83f7af38e3d9b36cf368958f9af37c390d6e8afc1b
6
+ metadata.gz: 7d8ede15f27a062b31ffa705fc3ccf4f387a7884dd5d3b18527cb24b9d3baa1e31715420412a385f41d1f98735b3de7ff017218d5c21fec301fcc0f7e3a31a50
7
+ data.tar.gz: c9d21059a4093c33677c81b1402b217ff8cbe1aff453f6682fc815681a938b584ae5b52d7b5ca5e7ec21f763aa96ec611fe66bee3c5d69cc360f93ee590ae1af
@@ -112,9 +112,15 @@ module Zold
112
112
  end
113
113
 
114
114
  def *(other)
115
+ raise '* may only work with a number' unless other.is_a?(Integer) || other.is_a?(Float)
115
116
  c = (@coins * other).to_i
116
117
  raise "Overflow, can't multiply #{@coins} by #{m}" if c > Amount::MAX
117
118
  Amount.new(coins: c)
118
119
  end
120
+
121
+ def /(other)
122
+ raise '/ may only work with a number' unless other.is_a?(Integer) || other.is_a?(Float)
123
+ Amount.new(coins: (@coins / other).to_i)
124
+ end
119
125
  end
120
126
  end
@@ -55,8 +55,7 @@ Available options:"
55
55
  end
56
56
  mine = Args.new(opts, @log).take || return
57
57
  raise 'Receiver wallet ID is required' if mine[0].nil?
58
- id = Zold::Id.new(mine[0])
59
- invoice(id, opts)
58
+ invoice(Id.new(mine[0]), opts)
60
59
  end
61
60
 
62
61
  private
@@ -49,7 +49,7 @@ module Zold
49
49
  end
50
50
  ids = @wallets.all.sample(10)
51
51
  Push.new(wallets: @wallets, remotes: @remotes, log: @log).run(
52
- ['push', "--network=#{@opts['network']}"] + ids
52
+ ['push', "--network=#{@opts['network']}"] + ids.map(&:to_s)
53
53
  )
54
54
  if ids.empty?
55
55
  @log.info("Spread didn't push any wallets, we are empty")
@@ -51,7 +51,7 @@ module Zold
51
51
  !File.directory?(f) &&
52
52
  basename =~ /^[0-9a-fA-F]{16}$/ &&
53
53
  Id.new(basename).to_s == basename
54
- end.map { |w| File.basename(w, Wallet::EXTENSION) }
54
+ end.map { |w| Id.new(File.basename(w, Wallet::EXTENSION)) }
55
55
  end
56
56
 
57
57
  def find(id)
@@ -25,6 +25,6 @@
25
25
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Zold
28
- VERSION = '0.14.48'
28
+ VERSION = '0.14.49'
29
29
  PROTOCOL = 2
30
30
  end
@@ -57,7 +57,7 @@ module Zold
57
57
  !File.directory?(file) &&
58
58
  basename =~ /^[0-9a-fA-F]{16}$/ &&
59
59
  Id.new(basename).to_s == basename
60
- end.map { |w| File.basename(w, Wallet::EXTENSION) }
60
+ end.map { |w| Id.new(File.basename(w, Wallet::EXTENSION)) }
61
61
  end
62
62
 
63
63
  def find(id)
@@ -65,4 +65,14 @@ class TestAmount < Minitest::Test
65
65
  "#{amount} is not greater than zero"
66
66
  )
67
67
  end
68
+
69
+ def test_multiplies
70
+ amount = Zold::Amount.new(zld: 1.2)
71
+ assert(Zold::Amount.new(zld: 2.4), amount * 2)
72
+ end
73
+
74
+ def test_divides
75
+ amount = Zold::Amount.new(zld: 8.2)
76
+ assert(Zold::Amount.new(zld: 4.1), amount / 2)
77
+ end
68
78
  end
@@ -38,7 +38,7 @@ class TestTreeWallets < Minitest::Test
38
38
  wallets.find(id) do |wallet|
39
39
  wallet.init(id, Zold::Key.new(file: 'fixtures/id_rsa.pub'))
40
40
  assert_equal(1, wallets.all.count)
41
- assert_equal(id.to_s, wallets.all[0])
41
+ assert_equal(id, wallets.all[0])
42
42
  assert(wallet.path.end_with?('/a/b/c/d/abcd0123abcd0123.z'), wallet.path)
43
43
  end
44
44
  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.48
4
+ version: 0.14.49
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko