Class: RsyncCron::Host

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, remote: nil) ⇒ Host

Returns a new instance of Host.



9
10
11
12
# File 'lib/rsync_cron/host.rb', line 9

def initialize(path:, remote: nil)
  @path = path
  @remote = remote
end

Class Method Details

.factory(s) ⇒ Object



3
4
5
6
7
# File 'lib/rsync_cron/host.rb', line 3

def self.factory(s)
  return new(path: s) unless s.index(":")
  remote, path = s.split(":")
  new(path: path, remote: remote)
end

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/rsync_cron/host.rb', line 18

def exist?
  return FileTest.exist?(path) unless remote?
  %x[ssh #{remote} "test -e #{path}"]
  $?.exitstatus.zero?
end

#to_sObject



14
15
16
# File 'lib/rsync_cron/host.rb', line 14

def to_s
  [remote, path].compact.join(":")
end