Class: I18n::Tasks::Scanners::Files::CachingFileFinder

Inherits:
FileFinder
  • Object
show all
Defined in:
lib/i18n/tasks/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.

Since:

  • 0.9.0

Constant Summary

Constants included from Logging

Logging::MUTEX, Logging::PROGRAM_NAME

Instance Method Summary collapse

Methods inherited from FileFinder

#traverse_files

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.

Parameters:

  • paths (Array<String>)

    Find.find-compatible paths to traverse, absolute or relative to the working directory.

  • only (Array<String>, nil)

    File.fnmatch-compatible patterns files to include. Files not matching any of the inclusion patterns will be excluded.

  • exclude (Arry<String>)

    File.fnmatch-compatible patterns of files to exclude. Files matching any of the exclusion patterns will be excluded even if they match an inclusion pattern.

Since:

  • 0.9.0



14
15
16
17
# File 'lib/i18n/tasks/scanners/files/caching_file_finder.rb', line 14

def initialize(**args)
  super
  @cached_value = ::I18n::Tasks::Concurrent::CachedValue.new { uncached_find_files }
end

Instance Method Details

#find_filesArray<String>

Note:

This method is cached, it will only access the filesystem on the first invocation.

Returns found files.

Returns:

  • (Array<String>)

    found files

Since:

  • 0.9.0



31
32
33
# File 'lib/i18n/tasks/scanners/files/caching_file_finder.rb', line 31

def find_files
  @cached_value.get
end