Class: FseventsToVm::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/fsevents_to_vm/cli.rb

Instance Method Summary collapse

Instance Method Details

#start(listen_dir = ENV['HOME']) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fsevents_to_vm/cli.rb', line 9

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

  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