Sha256: be9d93b32c8ff5fed139fb0a77f9c9aec57a30e380b9cbfad3d755a9b79e22c6

Contents?: true

Size: 1.39 KB

Versions: 6

Compression:

Stored size: 1.39 KB

Contents

# encoding: utf-8

module Backup
  module Syncer
    module RSync
      class Local < Base

        ##
        # Instantiates a new RSync::Local Syncer.
        #
        # Pre-configured defaults specified in
        # Configuration::Syncer::RSync::Local
        # are set via a super() call to RSync::Base,
        # which in turn will invoke Syncer::Base.
        #
        # Once pre-configured defaults and RSync specific defaults are set,
        # the block from the user's configuration file is evaluated.
        def initialize(&block)
          super

          instance_eval(&block) if block_given?
        end

        ##
        # Performs the RSync::Local operation
        # debug options: -vhP
        def perform!
          Logger.message(
            "#{ syncer_name } started syncing the following directories:\n\s\s" +
            @directories.join("\n\s\s")
          )
          run("#{ utility(:rsync) } #{ options } " +
              "#{ directories_option } '#{ dest_path }'")
        end

        private

        ##
        # Return expanded @path
        def dest_path
          @dest_path ||= File.expand_path(@path)
        end

        ##
        # Returns all the specified Rsync::Local options,
        # concatenated, ready for the CLI
        def options
          ([archive_option, mirror_option] +
            additional_options).compact.join("\s")
        end

      end
    end
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
backup-agoddard-3.0.28 lib/backup/syncer/rsync/local.rb
backup-agoddard-3.0.27 lib/backup/syncer/rsync/local.rb
ey-vendored-backup-3.0.27 lib/backup/syncer/rsync/local.rb
backup-3.0.27 lib/backup/syncer/rsync/local.rb
backup-3.0.26 lib/backup/syncer/rsync/local.rb
backup-3.0.25 lib/backup/syncer/rsync/local.rb