class FseventsToVm::SshEmit

Public Class Methods

new(identity_file, ip, username) click to toggle source
# File lib/fsevents_to_vm/ssh_emit.rb, line 7
def initialize(identity_file, ip, username)
  @identity_file = identity_file
  @ip = ip
  @username = username
end

Public Instance Methods

event(event) click to toggle source
# File lib/fsevents_to_vm/ssh_emit.rb, line 13
def event(event)
  ssh.exec!("touch -m -c -t #{event.mtime} #{Shellwords.escape event.path}".force_encoding(Encoding::BINARY))
rescue SystemCallError => e
  $stderr.puts "Error sending event: #{e}"
  $stderr.puts "\t#{e.backtrace.join("\n\t")}"
  disconnect!
end

Protected Instance Methods

disconnect!() click to toggle source
# File lib/fsevents_to_vm/ssh_emit.rb, line 31
def disconnect!
  @ssh = nil
end
ssh() click to toggle source
# File lib/fsevents_to_vm/ssh_emit.rb, line 23
def ssh
  @ssh ||= Net::SSH.start(@ip, @username,
    config: false,
    keys: [@identity_file],
    keys_only: true,
    paranoid: false)
end