lib/file_scanner/worker.rb in file_scanner-3.2.1 vs lib/file_scanner/worker.rb in file_scanner-3.2.2
- old
+ new
@@ -10,20 +10,21 @@
attr_reader :filters
def initialize(path:,
filters: Filters::defaults,
all: false,
- check: false,
+ filecheck: false,
logger: Logger.new(nil))
@path = File.expand_path(path)
@filters = filters
@mode = mode(all)
- @check = check
+ @filecheck = filecheck
@logger = logger
end
def call
+ @logger.debug { "skipping directories" } if @filecheck
paths.lazy.select { |file| valid?(file) && filter(file) }
rescue StandardError => e
@logger.error { e.message }
raise e
end
@@ -31,16 +32,17 @@
private def mode(all)
all ? ALL : ANY
end
private def valid?(file)
- return true unless @check
+ return true unless @filecheck
FileTest.file?(file)
end
private def filter(file)
+ @logger.debug { "filters applied by \e[35m#{@mode}\e[0m" }
@filters.send(@mode) do |filter|
- @logger.debug { "filtering by \e[33m#{@mode}\e[0m with \e[33m#{filter}\e[0m on #{File.basename(file)}" }
+ @logger.debug { "filtering on \e[33m#{File.basename(file)}\e[0m" }
filter.call(file)
end
end
private def paths