Sha256: 9412e6cba426f171933ccfcfc8785d316f1363b390b5f7b3c5105543a3d61f7f

Contents?: true

Size: 947 Bytes

Versions: 29

Compression:

Stored size: 947 Bytes

Contents

# frozen_string_literal: true

require 'i18n/tasks/concurrent/cache'
require 'i18n/tasks/scanners/files/caching_file_finder'

module I18n::Tasks::Scanners::Files
  # Finds the files and provides their contents.
  #
  # @note This class is thread-safe. All methods are cached.
  # @since 0.9.0
  class CachingFileFinderProvider
    # @param exclude [Array<String>]
    def initialize(exclude: [])
      @cache = ::I18n::Tasks::Concurrent::Cache.new
      @defaults = { exclude: exclude }
    end

    # Initialize a {CachingFileFinder} or get one from cache based on the constructor arguments.
    #
    # @param (see FileFinder#initialize)
    # @return [CachingFileFinder]
    def get(**file_finder_args)
      @cache.fetch(file_finder_args) do
        args = file_finder_args.dup
        args[:exclude] = @defaults[:exclude] + (args[:exclude] || [])
        args[:exclude].uniq!
        CachingFileFinder.new(**args)
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 3 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/i18n-tasks-1.0.14/lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-1.0.13 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-1.0.12 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-1.0.11 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-1.0.10 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-1.0.9 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-1.0.8 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-1.0.7 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-1.0.6 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-1.0.5 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-1.0.4 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-1.0.3 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-1.0.2 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-1.0.1 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-1.0.0 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-youdao-tasks-0.9.37 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-0.9.37 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-0.9.36 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-0.9.35 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb
i18n-tasks-0.9.34 lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb