Sha256: 2a8eb85b0d975667fb57c91a018cd71a0a705d7d874ae6011fe6ce5f3c2e8c5b
Contents?: true
Size: 1.79 KB
Versions: 4
Compression:
Stored size: 1.79 KB
Contents
require 'fulmar/infrastructure/service/transfer/base' module Fulmar module Infrastructure module Service module Transfer # Implements the rsync transfer class Rsync < Base DEFAULT_CONFIG = { rsync: { exclude: nil, exclude_file: nil, chown: nil, chmod: nil, delete: true, direction: 'up' } } def initialize(config) @config = DEFAULT_CONFIG.deep_merge(config) if @config[:rsync][:exclude_file].blank? && File.exist?(@config[:local_path] + '/.rsyncignore') @config[:rsync][:exclude_file] = @config[:local_path] + '/.rsyncignore' end super(@config) end def transfer prepare unless @prepared @local_shell.run rsync_command end def rsync_command options = ['-rl'] options << "--exclude='#{@config[:rsync][:exclude]}'" if @config[:rsync][:exclude] options << "--exclude-from='#{@config[:rsync][:exclude_file]}'" if @config[:rsync][:exclude_file] options << "--chown='#{@config[:rsync][:chown]}'" if @config[:rsync][:chown] options << "--chmod='#{@config[:rsync][:chmod]}'" if @config[:rsync][:chmod] options << '--delete' if @config[:rsync][:delete] if @config[:rsync][:direction] == 'up' from = @config[:local_path] to = ssh_user_and_host + ':' + @config[:remote_path] else from = ssh_user_and_host + ':' + @config[:remote_path] to = @config[:local_path] end "rsync #{options.join(' ')} '#{from}/' '#{to}'" end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems