Class: FileScanner::Worker
- Inherits:
-
Object
- Object
- FileScanner::Worker
- Defined in:
- lib/file_scanner/worker.rb
Constant Summary collapse
- ALL =
:all?
- ANY =
:any?
Instance Attribute Summary collapse
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(path:, filters: Filters::defaults, all: false, filecheck: false, logger: Logger.new(nil)) ⇒ Worker
constructor
A new instance of Worker.
Constructor Details
#initialize(path:, filters: Filters::defaults, all: false, filecheck: false, logger: Logger.new(nil)) ⇒ Worker
Returns a new instance of Worker.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/file_scanner/worker.rb', line 12 def initialize(path:, filters: Filters::defaults, all: false, filecheck: false, logger: Logger.new(nil)) @path = File.(path) << File::SEPARATOR @filters = filters @mode = mode(all) @filecheck = filecheck @logger = logger end |
Instance Attribute Details
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
10 11 12 |
# File 'lib/file_scanner/worker.rb', line 10 def filters @filters end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/file_scanner/worker.rb', line 10 def path @path end |
Instance Method Details
#call ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/file_scanner/worker.rb', line 24 def call @logger.info { "scanning \e[1m#{@path}\e[0m..." } @logger.debug { "skipping directories" } if @filecheck @logger.debug { "applying \e[36m#{@filters.size}\e[0m filters by \e[35m#{@mode}\e[0m" } paths.lazy.select { |file| valid?(file) && filter(file) } rescue StandardError => e @logger.error { e. } raise e end |