Class: Zold::Merge

Inherits:
Object
  • Object
show all
Defined in:
lib/zold/commands/merge.rb

Overview

MERGE pulling command

Instance Method Summary collapse

Constructor Details

#initialize(wallets:, copies:, log: Log::Quiet.new) ⇒ Merge

Returns a new instance of Merge.



36
37
38
39
40
# File 'lib/zold/commands/merge.rb', line 36

def initialize(wallets:, copies:, log: Log::Quiet.new)
  @wallets = wallets
  @copies = copies
  @log = log
end

Instance Method Details

#run(args = []) ⇒ Object

Returns the array of modified wallets (IDs)



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/zold/commands/merge.rb', line 43

def run(args = [])
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
    o.banner = "Usage: zold merge [ID...] [options]
Available options:"
    o.bool '--help', 'Print instructions'
  end
  mine = Args.new(opts, @log).take || return
  mine = @wallets.all if mine.empty?
  modified = []
  mine.each do |id|
    next unless merge(Id.new(id), Copies.new(File.join(@copies, id)), opts)
    modified << Id.new(id)
    require_relative 'propagate'
    modified += Propagate.new(wallets: @wallets, log: @log).run(args)
  end
  modified
end