lib/rivendell/import/base.rb in rivendell-import-0.0.4 vs lib/rivendell/import/base.rb in rivendell-import-0.0.5
- old
+ new
@@ -20,15 +20,18 @@
def listen(directory, options = {})
workers << Worker.new(self).start unless options[:dry_run]
Rivendell::Import.logger.info "Listen files in #{directory}"
- Listen.to(directory) do |modified, added, removed|
+
+ callback = Proc.new do |modified, added, removed|
added.each do |file|
Rivendell::Import.logger.debug "Detected file '#{file}'"
file(file, directory)
end
end
+
+ Listen.to(directory).change(&callback).start!
end
def process(*paths)
paths.flatten.each do |path|
method = ::File.directory?(path) ? :directory : :file