zold 0.9.6 → 0.9.7
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 -6
- data/lib/zold/commands/invoice.rb +3 -2
- data/lib/zold/commands/node.rb +2 -0
- data/lib/zold/commands/pull.rb +46 -0
- data/lib/zold/id.rb +2 -0
- data/lib/zold/node/entrance.rb +1 -1
- data/lib/zold/version.rb +1 -1
- data/lib/zold/wallets.rb +7 -0
- data/test/commands/test_pay.rb +16 -1
- metadata +2 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: c7c1b5e4219998688aaec4f6ca49d4f417d472fd
         | 
| 4 | 
            +
              data.tar.gz: 1773d14213af2c9aa5548c3a98ae255243978432
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: e39ad8edca90cf93a11f6fddc204175491b42ec1f3f1e178c744a2f9bd1393f28d6ee29476d84f31bd80e087d06a76a047e580cf7b07d82d906c606b32fefeca
         | 
| 7 | 
            +
              data.tar.gz: b2ab87529c40fc152e7a9cb4d87a8d911723161040185606173e50a95a0e793091dd4cc39399e7d82c76751ec7a9908110061c3704b18660d16235dcdfbb6d10
         | 
    
        data/bin/zold
    CHANGED
    
    | @@ -156,12 +156,8 @@ Available options:" | |
| 156 156 | 
             
                require_relative '../lib/zold/commands/propagate'
         | 
| 157 157 | 
             
                Zold::Propagate.new(wallets: wallets, log: log).run(args)
         | 
| 158 158 | 
             
              when 'pull'
         | 
| 159 | 
            -
                require_relative '../lib/zold/commands/ | 
| 160 | 
            -
                Zold:: | 
| 161 | 
            -
                require_relative '../lib/zold/commands/merge'
         | 
| 162 | 
            -
                Zold::Merge.new(wallets: wallets, copies: copies, log: log).run(args)
         | 
| 163 | 
            -
                require_relative '../lib/zold/commands/clean'
         | 
| 164 | 
            -
                Zold::Clean.new(wallets: wallets, copies: copies, log: log).run(args)
         | 
| 159 | 
            +
                require_relative '../lib/zold/commands/pull'
         | 
| 160 | 
            +
                Zold::Pull.new(wallets: wallets, remotes: remotes, copies: copies, log: log).run(args)
         | 
| 165 161 | 
             
              when 'taxes'
         | 
| 166 162 | 
             
                require_relative '../lib/zold/commands/taxes'
         | 
| 167 163 | 
             
                Zold::Taxes.new(wallets: wallets, log: log).run(args)
         | 
| @@ -48,8 +48,9 @@ Available options:" | |
| 48 48 | 
             
                  end
         | 
| 49 49 | 
             
                  mine = Args.new(opts, @log).take || return
         | 
| 50 50 | 
             
                  raise 'Receiver wallet ID is required' if mine[0].nil?
         | 
| 51 | 
            -
                   | 
| 52 | 
            -
                   | 
| 51 | 
            +
                  id = Zold::Id.new(mine[0])
         | 
| 52 | 
            +
                  wallet = @wallets.find(id)
         | 
| 53 | 
            +
                  raise "Wallet #{id} doesn\'t exist in #{@wallets}, do 'fetch' first" unless wallet.exists?
         | 
| 53 54 | 
             
                  invoice(wallet, opts)
         | 
| 54 55 | 
             
                end
         | 
| 55 56 |  | 
    
        data/lib/zold/commands/node.rb
    CHANGED
    
    | @@ -96,6 +96,8 @@ module Zold | |
| 96 96 | 
             
                  Zold::Front.set(:port, opts['bind-port'])
         | 
| 97 97 | 
             
                  invoice = opts[:invoice]
         | 
| 98 98 | 
             
                  unless invoice.include?('@')
         | 
| 99 | 
            +
                    require_relative 'pull'
         | 
| 100 | 
            +
                    Pull.new(wallets: wallets, remotes: remotes, copies: copies, log: @log).run(['pull', invoice])
         | 
| 99 101 | 
             
                    require_relative 'invoice'
         | 
| 100 102 | 
             
                    invoice = Invoice.new(wallets: wallets, log: @log).run(['invoice', invoice])
         | 
| 101 103 | 
             
                  end
         | 
| @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            # Copyright (c) 2018 Yegor Bugayenko
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            # Permission is hereby granted, free of charge, to any person obtaining a copy
         | 
| 4 | 
            +
            # of this software and associated documentation files (the 'Software'), to deal
         | 
| 5 | 
            +
            # in the Software without restriction, including without limitation the rights
         | 
| 6 | 
            +
            # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         | 
| 7 | 
            +
            # copies of the Software, and to permit persons to whom the Software is
         | 
| 8 | 
            +
            # furnished to do so, subject to the following conditions:
         | 
| 9 | 
            +
            #
         | 
| 10 | 
            +
            # The above copyright notice and this permission notice shall be included in all
         | 
| 11 | 
            +
            # copies or substantial portions of the Software.
         | 
| 12 | 
            +
            #
         | 
| 13 | 
            +
            # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         | 
| 14 | 
            +
            # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         | 
| 15 | 
            +
            # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
         | 
| 16 | 
            +
            # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         | 
| 17 | 
            +
            # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         | 
| 18 | 
            +
            # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         | 
| 19 | 
            +
            # SOFTWARE.
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            require_relative '../log'
         | 
| 22 | 
            +
            require_relative 'fetch'
         | 
| 23 | 
            +
            require_relative 'merge'
         | 
| 24 | 
            +
            require_relative 'clean'
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            # PULL command.
         | 
| 27 | 
            +
            # Author:: Yegor Bugayenko (yegor256@gmail.com)
         | 
| 28 | 
            +
            # Copyright:: Copyright (c) 2018 Yegor Bugayenko
         | 
| 29 | 
            +
            # License:: MIT
         | 
| 30 | 
            +
            module Zold
         | 
| 31 | 
            +
              # PULL command
         | 
| 32 | 
            +
              class Pull
         | 
| 33 | 
            +
                def initialize(wallets:, remotes:, copies:, log: Log::Quiet.new)
         | 
| 34 | 
            +
                  @wallets = wallets
         | 
| 35 | 
            +
                  @remotes = remotes
         | 
| 36 | 
            +
                  @copies = copies
         | 
| 37 | 
            +
                  @log = log
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                def run(args = [])
         | 
| 41 | 
            +
                  Zold::Fetch.new(wallets: @wallets, remotes: @remotes, copies: @copies, log: @log).run(args)
         | 
| 42 | 
            +
                  Zold::Merge.new(wallets: @wallets, copies: @copies, log: @log).run(args)
         | 
| 43 | 
            +
                  Zold::Clean.new(wallets: @wallets, copies: @copies, log: @log).run(args)
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
            end
         | 
    
        data/lib/zold/id.rb
    CHANGED
    
    
    
        data/lib/zold/node/entrance.rb
    CHANGED
    
    | @@ -78,11 +78,11 @@ module Zold | |
| 78 78 | 
             
                  modified = Merge.new(
         | 
| 79 79 | 
             
                    wallets: @wallets, copies: copies.root, log: @log
         | 
| 80 80 | 
             
                  ).run(['merge', id.to_s])
         | 
| 81 | 
            +
                  Clean.new(wallets: @wallets, copies: copies.root, log: @log).run(['clean', id.to_s])
         | 
| 81 82 | 
             
                  copies.remove('remote', Remotes::PORT)
         | 
| 82 83 | 
             
                  Push.new(
         | 
| 83 84 | 
             
                    wallets: @wallets, remotes: @remotes, log: @log
         | 
| 84 85 | 
             
                  ).run(['push'] + modified.map(&:to_s))
         | 
| 85 | 
            -
                  Clean.new(wallets: @wallets, copies: copies.root, log: @log).run(['clean', id.to_s])
         | 
| 86 86 | 
             
                  modified
         | 
| 87 87 | 
             
                end
         | 
| 88 88 | 
             
              end
         | 
    
        data/lib/zold/version.rb
    CHANGED
    
    
    
        data/lib/zold/wallets.rb
    CHANGED
    
    | @@ -32,6 +32,13 @@ module Zold | |
| 32 32 | 
             
                  @dir = dir
         | 
| 33 33 | 
             
                end
         | 
| 34 34 |  | 
| 35 | 
            +
                # @todo #70:30min Let's make it smarter. Instead of returning
         | 
| 36 | 
            +
                #  the full path let's substract the prefix from it if it's equal
         | 
| 37 | 
            +
                #  to the current directory in Dir.pwd.
         | 
| 38 | 
            +
                def to_s
         | 
| 39 | 
            +
                  path
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 35 42 | 
             
                def path
         | 
| 36 43 | 
             
                  FileUtils.mkdir_p(@dir)
         | 
| 37 44 | 
             
                  File.expand_path(@dir)
         | 
    
        data/test/commands/test_pay.rb
    CHANGED
    
    | @@ -19,8 +19,8 @@ | |
| 19 19 | 
             
            # SOFTWARE.
         | 
| 20 20 |  | 
| 21 21 | 
             
            require 'minitest/autorun'
         | 
| 22 | 
            -
            require 'tmpdir'
         | 
| 23 22 | 
             
            require_relative '../test__helper'
         | 
| 23 | 
            +
            require_relative '../fake_home'
         | 
| 24 24 | 
             
            require_relative '../../lib/zold/wallets'
         | 
| 25 25 | 
             
            require_relative '../../lib/zold/amount'
         | 
| 26 26 | 
             
            require_relative '../../lib/zold/key'
         | 
| @@ -46,4 +46,19 @@ class TestPay < Minitest::Test | |
| 46 46 | 
             
                  assert_equal(amount * -1, source.balance)
         | 
| 47 47 | 
             
                end
         | 
| 48 48 | 
             
              end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
              def test_sends_from_root_wallet
         | 
| 51 | 
            +
                FakeHome.new.run do |home|
         | 
| 52 | 
            +
                  source = home.create_wallet(Zold::Id::ROOT)
         | 
| 53 | 
            +
                  target = home.create_wallet
         | 
| 54 | 
            +
                  amount = Zold::Amount.new(zld: 14.95)
         | 
| 55 | 
            +
                  Zold::Pay.new(wallets: home.wallets, remotes: home.remotes, log: $log).run(
         | 
| 56 | 
            +
                    [
         | 
| 57 | 
            +
                      'pay', '--private-key=fixtures/id_rsa',
         | 
| 58 | 
            +
                      source.id.to_s, target.id.to_s, amount.to_zld, 'For the car'
         | 
| 59 | 
            +
                    ]
         | 
| 60 | 
            +
                  )
         | 
| 61 | 
            +
                  assert_equal(amount * -1, source.balance)
         | 
| 62 | 
            +
                end
         | 
| 63 | 
            +
              end
         | 
| 49 64 | 
             
            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.9. | 
| 4 | 
            +
              version: 0.9.7
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Yegor Bugayenko
         | 
| @@ -290,6 +290,7 @@ files: | |
| 290 290 | 
             
            - lib/zold/commands/node.rb
         | 
| 291 291 | 
             
            - lib/zold/commands/pay.rb
         | 
| 292 292 | 
             
            - lib/zold/commands/propagate.rb
         | 
| 293 | 
            +
            - lib/zold/commands/pull.rb
         | 
| 293 294 | 
             
            - lib/zold/commands/push.rb
         | 
| 294 295 | 
             
            - lib/zold/commands/remote.rb
         | 
| 295 296 | 
             
            - lib/zold/commands/show.rb
         |