module Pullr::SCM::Rsync

Public Instance Methods

rsync_uri(uri) click to toggle source

Converts a given URI to one compatible with ‘rsync`.

@param [URI::Generic] uri

The URI to convert.

@return [String]

The `rsync` compatible URI.
# File lib/pullr/scm/rsync.rb, line 51
def rsync_uri(uri)
  new_uri = uri.host

  new_uri = "#{uri.user}@#{new_uri}" if uri.user
  new_uri = "#{new_uri}:#{uri.path}" unless uri.path.empty?

  return new_uri
end
scm_pull(uri,dest=nil) click to toggle source

Pulls down a copy of a Rsync source repository.

@param [Addressable::URI] uri

The URI of the Rsync repository.

@param [String] dest

Optional destination to pull the repository down into.
# File lib/pullr/scm/rsync.rb, line 17
def scm_pull(uri,dest=nil)
  unless dest
    raise(ArgumentError,"the destination argument for clone is missing",caller)
  end

  sh 'rsync', '-a', rsync_uri(uri), dest
end
scm_update(path,uri=nil) click to toggle source

Updates a local Rsync repository.

@param [String] path

Path to the local repository to update.

@param [Addressable::URI] uri

Optional URI of the remote Rsync repository to update from.
# File lib/pullr/scm/rsync.rb, line 34
def scm_update(path,uri=nil)
  unless uri
    raise(ArgumentError,"must specify the 'uri' argument to pull from",caller)
  end

  sh 'rsync', '-v', '-a', '--delete-after', rsync_uri(uri), path
end