class Grably::SyncJob
TBD
Constants
- DEFAULT_RSYNC_PARAMS
- PROTO_SSH
- SSH_HOST
Public Instance Methods
build()
click to toggle source
# 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?()
click to toggle source
# File lib/grably/jobs/sync.rb, line 34 def changed? true end
setup(srcs, dst = nil, _p = {})
click to toggle source
# 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
Private Instance Methods
rsync_params()
click to toggle source
# File lib/grably/jobs/sync.rb, line 73 def rsync_params params = DEFAULT_RSYNC_PARAMS.dup params << '--partial' unless no_partial params end
setup_ssh_opts()
click to toggle source
# File lib/grably/jobs/sync.rb, line 80 def setup_ssh_opts @host = @dst # '/' at the end will cause to sync internal file structure @dst = job_dir('files') + '/' @host.match(SSH_HOST) do |m| @ssh_pass = m[2] @host = [m[1], m[2]].join('@') end end
ssh_cmd()
click to toggle source
# File lib/grably/jobs/sync.rb, line 47 def ssh_cmd cmd = %w(ssh) cmd += ['-i', ssh_key] if ssh_key cmd += ['-p', ssh_port] if ssh_port cmd = ['sshpass', '-p', ssh_pass] + cmd if ssh_pass "'#{cmd.join(' ')}'" end
ssh_sync()
click to toggle source
# File lib/grably/jobs/sync.rb, line 64 def ssh_sync if files.empty? warn 'Nothing to sync' if files.empty? end log "Syncing #{files.size} files to #{host}" ['rsync', *rsync_params, @dst, '-e', ssh_cmd, host].run_log end
unpack_dst_hash(dst)
click to toggle source
# File lib/grably/jobs/sync.rb, line 55 def unpack_dst_hash(dst) @proto = :ssh @no_partial = dst[:no_partial] @ssh_key = dst[:ssh_key] @ssh_pass = dst[:ssh_pass] @ssh_port = dst[:ssh_port] @dst = dst[:host] end