Permalink
Browse files

start to rework how the listener is created to better handle globing …

…for guard/listen
  • Loading branch information...
1 parent 7840abc commit dc7697613c3bee4d21cf917016c860b8f4d4afc7 @teknofire teknofire committed May 10, 2012
Showing with 25 additions and 5 deletions.
  1. +21 −5 lib/conveyor/foreman.rb
  2. +4 −0 lib/conveyor/worker.rb
View
@@ -49,13 +49,17 @@ def read_configs
end
def watch(*args, &block)
- opts = args.extract_options!
+ @listener_opts = args.extract_options!
+ @listener_dir = File.expand_path(args.first)
+ raise "Directory #{dir} not found" unless File.directory? dir
- dir = File.expand_path(args.first)
+ yield
+ end
- raise "Directory #{dir} not found" unless File.directory? dir
-
- listener = Listen.to(dir)
+ def match(*args, &block)
+ opts = args.extract_options!
+
+ listener = Listen.to(@listener_dir)
listener.latency(0.5)
listener.ignore(opts[:ignore]) if opts[:ignore]
listener.force_polling(opts[:force_polling]) if opts[:force_polling]
@@ -78,6 +82,18 @@ def watch(*args, &block)
error e.backtrace
end
+ def file(glob)
+ "**/#{glob}"
+ end
+
+ def extension(glob)
+ "*.#{glob}"
+ end
+
+ def any
+ '*'
+ end
+
def notify_list
@notify_list.flatten!
@notify_list.uniq!
View
@@ -18,6 +18,10 @@ def initialize(file, worker_def, log = MSGLVLS[:debug])
# @glob = escape_glob(glob)
end
+ def file(glob)
+ "**/#{glob}"
+ end
+
def extension(glob)
"*.#{glob}"
end

0 comments on commit dc76976

Please sign in to comment.