Class: Grably::SyncJob

Inherits:
Object
  • Object
show all
Includes:
Job
Defined in:
lib/grably/jobs/sync.rb

Overview

TBD

Constant Summary collapse

PROTO_SSH =
%r{^ssh://(.*)$}
SSH_HOST =
/(.+?):(.+?)@(.+)/
DEFAULT_RSYNC_PARAMS =
%w(-avz --progress --delete).freeze

Instance Method Summary collapse

Methods included from Job

included, jobs

Instance Method Details

#buildObject



38
39
40
41
42
43
# File 'lib/grably/jobs/sync.rb', line 38

def build
  trace "Syncing products to #{dst}"
  cp_smart(files, dst, log: proto == :file)
  ssh_sync if proto == :ssh
  proto == :ssh ? [] : dst
end

#changed?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/grably/jobs/sync.rb', line 34

def changed?
  true
end

#setup(srcs, dst = nil, _p = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/grably/jobs/sync.rb', line 20

def setup(srcs, dst = nil, _p = {})
  @files = srcs
  @dst = dst || job_dir

  @proto = :file

  unpack_dst_hash(@dst) unless @dst.is_a?(String)
  @dst.match(PROTO_SSH) do |m|
    @proto = :ssh
    @dst = m[1]
  end
  setup_ssh_opts if @proto == :ssh
end