Class: Zold::Routines::Reconnect

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

Overview

Reconnect to the network

Instance Method Summary collapse

Constructor Details

#initialize(opts, remotes, farm = Farm::Empty.new, log: Log::Quiet.new) ⇒ Reconnect

Returns a new instance of Reconnect.



33
34
35
36
37
38
# File 'lib/zold/commands/routines/reconnect.rb', line 33

def initialize(opts, remotes, farm = Farm::Empty.new, log: Log::Quiet.new)
  @opts = opts
  @remotes = remotes
  @farm = farm
  @log = log
end

Instance Method Details

#exec(_ = 0) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/zold/commands/routines/reconnect.rb', line 40

def exec(_ = 0)
  sleep(60) unless @opts['routine-immediately']
  unless @opts['routine-immediately']
    Remote.new(remotes: @remotes, log: @log).run(%w[remote add b1.zold.io 80 --force])
  end
  Remote.new(remotes: @remotes, log: @log).run(%w[remote trim])
  Remote.new(remotes: @remotes, farm: @farm, log: @log).run(
    %w[remote update] + (@opts['never-reboot'] ? [] : ['--reboot'])
  )
end