class FseventsToVm::Cli

Public Instance Methods

start(listen_dir = ENV['HOME']) click to toggle source
# File lib/fsevents_to_vm/cli.rb, line 12
def start(listen_dir = ENV['HOME'])
  debug = options[:debug]

  watcher = FseventsToVm::Watch.new(listen_dir)
  path_filter = FseventsToVm::PathFilter.new
  recursion_filter = FseventsToVm::RecursionFilter.new
  forwarder = FseventsToVm::SshEmit.new(options[:ssh_identity_file], options[:ssh_ip], options[:ssh_username])

  if debug
    puts "Watching #{listen_dir} and forwarding events to Dinghy VM..."
  end

  watcher.run do |event|
    next if path_filter.ignore?(event)
    next if recursion_filter.ignore?(event)
    if debug
      puts "touching #{event.mtime}:#{event.path}"
    end
    forwarder.event(event)
  end
end