Sha256: dc42515eaba549f3035ded30dbc9b4e7c1796325c4f7a1fdb66f45e72a09269d

Contents?: true

Size: 677 Bytes

Versions: 1

Compression:

Stored size: 677 Bytes

Contents

class KuberKit::Shell::Commands::RsyncCommands
  def rsync(shell, source_path, target_path, target_host: nil, exclude: nil)
    # Add a trailing slash to directory to have behavior similar to CP command
    if path_is_directory?(source_path) && !source_path.end_with?("/")
      source_path = "#{source_path}/"
    end

    if target_host
      destination = "#{target_host}:#{target_path}"
    else
      destination = target_path
    end

    args = [source_path, destination]
    if exclude
      args << "--exclude=#{exclude}"
    end

    shell.exec!(%Q{rsync -a #{args.join(' ')}})
  end

  private
    def path_is_directory?(path)
      File.directory?(path)
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kuber_kit-0.1.9 lib/kuber_kit/shell/commands/rsync_commands.rb