Sha256: 2b09813219173dcda72fbcc67882987e3389078b33dfcdd66f48ce3dc992ad02

Contents?: true

Size: 717 Bytes

Versions: 3

Compression:

Stored size: 717 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 @io.puts "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

3 entries across 3 versions & 1 rubygems

Version Path
rsync_cron-1.1.2 lib/rsync_cron/command.rb
rsync_cron-1.1.1 lib/rsync_cron/command.rb
rsync_cron-1.1.0 lib/rsync_cron/command.rb