Sha256: b2b5bf1b4e123f00d4d5cd4a6c2dd4d866a4b18ca4a5fe89317afdf92f1607b5

Contents?: true

Size: 1.39 KB

Versions: 4

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.info(
            "#{ 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

4 entries across 4 versions & 1 rubygems

Version Path
backup-3.1.3 lib/backup/syncer/rsync/local.rb
backup-3.1.2 lib/backup/syncer/rsync/local.rb
backup-3.1.1 lib/backup/syncer/rsync/local.rb
backup-3.1.0 lib/backup/syncer/rsync/local.rb