Class: I18n::Processes::Scanners::Files::CachingFileFinder
- Inherits:
-
FileFinder
- Object
- FileFinder
- I18n::Processes::Scanners::Files::CachingFileFinder
- Defined in:
- lib/i18n/processes/scanners/files/caching_file_finder.rb
Overview
Note:
This class is thread-safe. All methods are cached.
Finds the files in the specified search paths with support for exclusion / inclusion patterns. Wraps a FileFinder and caches the results.
Constant Summary
Constants included from Logging
Logging::MUTEX, Logging::PROGRAM_NAME
Instance Method Summary collapse
-
#find_files ⇒ Array<String>
Found files.
-
#initialize(**args) ⇒ CachingFileFinder
constructor
A new instance of CachingFileFinder.
-
#traverse_files {|path| ... } ⇒ Array<of block results>
Traverse the paths and yield the matching ones.
Methods included from Logging
log_error, log_stderr, log_verbose, log_warn, program_name, warn_deprecated
Constructor Details
#initialize(**args) ⇒ CachingFileFinder
Returns a new instance of CachingFileFinder.
12 13 14 15 16 |
# File 'lib/i18n/processes/scanners/files/caching_file_finder.rb', line 12 def initialize(**args) super @mutex = Mutex.new @cached_paths = nil end |
Instance Method Details
#find_files ⇒ Array<String>
Note:
This method is cached, it will only access the filesystem on the first invocation.
Returns found files.
30 31 32 |
# File 'lib/i18n/processes/scanners/files/caching_file_finder.rb', line 30 def find_files @cached_paths || @mutex.synchronize { @cached_paths ||= super } end |
#traverse_files {|path| ... } ⇒ Array<of block results>
Note:
This method is cached, it will only access the filesystem on the first invocation.
Traverse the paths and yield the matching ones.
24 25 26 |
# File 'lib/i18n/processes/scanners/files/caching_file_finder.rb', line 24 def traverse_files super end |