daytonn
7/24/2012 - 3:00 AM

Guard Listener Asynchronous

Guard Listener Asynchronous

def watch
  # This proc will be called when there are changes.
  callback = Proc.new do |modified, added, removed|
    #update defined elsewhere
    update modified, added, removed
  end
              
  @listener = Listen.to @builder.root
  @listener.ignore(/#{@settings[:build_dir]}/)
  # only look for .js, .jst, and .blueprint files
  @listener.filter(/\.jst?$|\.blueprint$/)
  @listener.change &callback
  # start asynchronous watcher
  @listener.start false
end