Module: Pullr::SCM::Rsync

Includes:
CommandLine
Defined in:
lib/pullr/scm/rsync.rb

Instance Method Summary collapse

Methods included from CommandLine

#cd, #sh

Instance Method Details

#rsync_uri(uri) ⇒ String

Converts a given URI to one compatible with rsync.

Parameters:

  • uri (URI::Generic)

    The URI to convert.

Returns:

  • (String)

    The rsync compatible URI.



51
52
53
54
55
56
57
58
# 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) ⇒ Object

Pulls down a copy of a Rsync source repository.

Parameters:

  • uri (Addressable::URI)

    The URI of the Rsync repository.

  • dest (String) (defaults to: nil)

    Optional destination to pull the repository down into.



17
18
19
20
21
22
23
# 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) ⇒ Object

Updates a local Rsync repository.

Parameters:

  • path (String)

    Path to the local repository to update.

  • uri (Addressable::URI) (defaults to: nil)

    Optional URI of the remote Rsync repository to update from.



34
35
36
37
38
39
40
# 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