Sha256: 64cbda73d1d19d40ee3394197b6bb5f58f0a0fc25e354efcc7898694e91b6266

Contents?: true

Size: 1.78 KB

Versions: 20

Compression:

Stored size: 1.78 KB

Contents

module Nanoc::Deploying::Deployers
  # 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
  class Rsync < ::Nanoc::Deploying::Deployer
    identifier :rsync

    # Default rsync options
    DEFAULT_OPTIONS = [
      '--group',
      '--links',
      '--perms',
      '--partial',
      '--progress',
      '--recursive',
      '--times',
      '--verbose',
      '--compress',
      '--exclude=".hg"',
      '--exclude=".svn"',
      '--exclude=".git"',
    ].freeze

    # @see Nanoc::Deploying::Deployer#run
    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

    def run_shell_cmd(cmd)
      piper = Nanoc::Extra::Piper.new(stdout: $stdout, stderr: $stderr)
      piper.run(cmd, nil)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
nanoc-4.7.9 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.7.8 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.7.7 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.7.6 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.7.5 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.7.4 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.7.3 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.7.2 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.7.1 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.7.0 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.6.4 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.6.3 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.6.2 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.6.1 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.6.0 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.5.4 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.5.3 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.5.2 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.5.1 lib/nanoc/deploying/deployers/rsync.rb
nanoc-4.5.0 lib/nanoc/deploying/deployers/rsync.rb