Sha256: 4970234513a89c162b3d4f35802d729b563ff2cda0865fe96a883cd401835caa

Contents?: true

Size: 715 Bytes

Versions: 4

Compression:

Stored size: 715 Bytes

Contents

require "rsync_cron/options"

module RsyncCron
  class Command
    NAME = `which rsync`.strip

    def initialize(src:, dest:, options: Options.new, name: NAME, log: nil, io: STDOUT)
      @src = src
      @dest = dest
      @options = options
      @name = name
      @log = log
      @io = io
    end

    def to_s
      return "echo 'rsync not installed'" if @name.empty?
      "#{@name} #{@options} #{@src} #{@dest}#{log}"
    end

    def valid?
      [@src, @dest].all? do |host|
        host.exist?.tap do |check|
          @io.puts "#{host} does not exist" unless check
        end
      end
    end

    private def log
      return unless @log
      " >> #{File.expand_path(@log)} 2>&1"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rsync_cron-1.0.8 lib/rsync_cron/command.rb
rsync_cron-1.0.7 lib/rsync_cron/command.rb
rsync_cron-1.0.6 lib/rsync_cron/command.rb
rsync_cron-1.0.5 lib/rsync_cron/command.rb