class Nanoc::Extra::Deployers::Rsync

A deployer that deploys a site using rsync.

The configuration has should include a `:dst` value, a string containing the destination to where rsync should upload its data. It will likely be in `host:path` format. It should not end with a slash. For example, `“example.com:/var/www/sites/mysite/html”`.

@example A deployment configuration with public and staging configurations

deploy:
  public:
    kind: rsync
    dst: "ectype:sites/stoneship/public"
  staging:
    kind: rsync
    dst: "ectype:sites/stoneship-staging/public"
    options: [ "-glpPrtvz" ]

@api private

Constants

DEFAULT_OPTIONS

Default rsync options

Public Instance Methods

run() click to toggle source

@see Nanoc::Extra::Deployer#run

# File lib/nanoc/extra/deployers/rsync.rb, line 39
def run
  # Get params
  src = source_path + '/'
  dst = config[:dst]
  options = config[:options] || DEFAULT_OPTIONS

  # Validate
  raise 'No dst found in deployment configuration' if dst.nil?
  raise 'dst requires no trailing slash' if dst[-1, 1] == '/'

  # Run
  if dry_run
    warn 'Performing a dry-run; no actions will actually be performed'
    run_shell_cmd(['echo', 'rsync', options, src, dst].flatten)
  else
    run_shell_cmd(['rsync', options, src, dst].flatten)
  end
end

Private Instance Methods

run_shell_cmd(cmd) click to toggle source
# File lib/nanoc/extra/deployers/rsync.rb, line 60
def run_shell_cmd(cmd)
  piper = Nanoc::Extra::Piper.new(stdout: $stdout, stderr: $stderr)
  piper.run(cmd, nil)
end