lib/fde/file_crawler.rb in fde-file_crawler-0.3.0 vs lib/fde/file_crawler.rb in fde-file_crawler-0.4.0
- old
+ new
@@ -16,20 +16,25 @@
yield self.config
end
def self.watch(query = nil, &block)
unless query.nil?
- yield self.crawl(query)
+ self.crawl(query).each do |file|
+ yield file
+ end
else
- yield self.crawl
+ self.crawl.each do |file|
+ yield file
+ end
end
end
def self.crawl(query = /.*\.*/i)
path = self.config.path_in_directory
files = Dir.entries(path)
files -= %w[. ..]
- files.select { |file| query.match(file) }
+ files.select! { |file| query.match(file) }
+ files
end
def self.copy(file, target = nil)
if self.config.path_out_directory && target.nil?
FileUtils.copy(path_for(file), self.config.path_out_directory)