Sha256: 3f921353e3e7e6bdd81c0fc0763b7705bd261f520c5a3a8cbfaa26b01ec0b90c

Contents?: true

Size: 1.75 KB

Versions: 19

Compression:

Stored size: 1.75 KB

Contents

module Nanoc::Extra::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::Extra::Deployer
    # Default rsync options
    DEFAULT_OPTIONS = [
      '--group',
      '--links',
      '--perms',
      '--partial',
      '--progress',
      '--recursive',
      '--times',
      '--verbose',
      '--compress',
      '--exclude=".hg"',
      '--exclude=".svn"',
      '--exclude=".git"',
    ].freeze

    # @see Nanoc::Extra::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

19 entries across 19 versions & 1 rubygems

Version Path
nanoc-4.3.7 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.3.6 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.3.5 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.3.4 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.3.3 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.3.2 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.3.1 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.3.0 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.2.4 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.2.3 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.2.2 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.2.1 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.2.0 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.1.6 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.2.0b1 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.1.5 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.1.4 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.1.3 lib/nanoc/extra/deployers/rsync.rb
nanoc-4.1.2 lib/nanoc/extra/deployers/rsync.rb