class I18n::Tasks::Scanners::Files::CachingFileReader

Reads the files in ‘rb’ mode and UTF-8 encoding. Wraps a {FileReader} and caches the results.

@note This class is thread-safe. All methods are cached. @since 0.9.0

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/i18n/tasks/scanners/files/caching_file_reader.rb, line 13
def initialize
  super
  @cache = ::I18n::Tasks::Concurrent::Cache.new
end

Public Instance Methods

read_file(path) click to toggle source

Return the contents of the file at the given path. The file is read in the ‘rb’ mode and UTF-8 encoding.

@param (see FileReader#read_file) @return (see FileReader#read_file) @note This method is cached, it will only access the filesystem on the first invocation.

Calls superclass method
# File lib/i18n/tasks/scanners/files/caching_file_reader.rb, line 24
def read_file(path)
  @cache.fetch(File.expand_path(path)) { super }
end