Class: Grifork::Executor::Carrier

Inherits:
Object
  • Object
show all
Includes:
Grifork::Executable
Defined in:
lib/grifork/executor/carrier.rb

Instance Method Summary collapse

Methods included from Grifork::Executable

#sh, #ssh

Methods included from Loggable

#logger

Methods included from Configured

#config

Constructor Details

#initialize(type, &task) ⇒ Carrier

Initialize with task

Parameters:

  • &task (Proc)

    task to execute



6
7
8
9
# File 'lib/grifork/executor/carrier.rb', line 6

def initialize(type, &task)
  @type = type
  @task = task
end

Instance Method Details

#dstObject (private)



26
27
28
# File 'lib/grifork/executor/carrier.rb', line 26

def dst
  Thread.current[:dst]
end

#rsync(from, to = nil) ⇒ Object (private)



31
32
33
# File 'lib/grifork/executor/carrier.rb', line 31

def rsync(from, to = nil)
  super(dst, from, to)
end

#rsync_remote(from, to = nil) ⇒ Object (private)

Note:

This is for remote task on :standalone mode

Wrapper for Grifork::Executable#rsync_remote



37
38
39
# File 'lib/grifork/executor/carrier.rb', line 37

def rsync_remote(from, to = nil)
  super(src, dst, from, to)
end

#run(src, dst) ⇒ Object

Run the task

Parameters:

  • src (String)

    Source hostname

  • dst (String)

    Target hostname



14
15
16
17
18
# File 'lib/grifork/executor/carrier.rb', line 14

def run(src, dst)
  Thread.current[:src] = src
  Thread.current[:dst] = dst
  instance_eval(&@task)
end

#srcObject (private)



22
23
24
# File 'lib/grifork/executor/carrier.rb', line 22

def src
  Thread.current[:src]
end