Sha256: 15f9458bdba8e965e3dfd1200ed959f84765f26f6a9709bf671d7c9207d39daa

Contents?: true

Size: 778 Bytes

Versions: 73

Compression:

Stored size: 778 Bytes

Contents

class KuberKit::Shell::Commands::RsyncCommands
  def rsync(shell, source_path, target_path, target_host: nil, exclude: nil, delete: true)
    # 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
      Array(exclude).each do |e|
        args << "--exclude=#{e}"
      end
    end

    if delete
      args << "--delete"
    end

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

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

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
kuber_kit-0.5.0 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.4.9 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.4.8 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.4.7 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.4.6 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.4.5 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.4.4 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.4.3 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.4.2 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.4.1 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.4.0 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.3.11 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.3.10 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.3.9 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.3.8 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.3.7 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.3.6 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.3.5 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.3.4 lib/kuber_kit/shell/commands/rsync_commands.rb
kuber_kit-0.3.3 lib/kuber_kit/shell/commands/rsync_commands.rb