Class: RsyncCron::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/rsync_cron/command.rb

Constant Summary collapse

NAME =
`which rsync`.strip

Instance Method Summary collapse

Constructor Details

#initialize(src:, dest:, options: Options.new, name: NAME, log: nil, io: STDOUT) ⇒ Command

Returns a new instance of Command.



7
8
9
10
11
12
13
14
# File 'lib/rsync_cron/command.rb', line 7

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

Instance Method Details

#to_sObject



16
17
18
19
# File 'lib/rsync_cron/command.rb', line 16

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

#valid?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'lib/rsync_cron/command.rb', line 21

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