danmayer/coverband

View on GitHub
lib/coverband/utils/file_hasher.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module Coverband
  module Utils
    class FileHasher
      @cache = {}

      def self.hash_file(file, path_converter: AbsoluteFileConverter.instance)
        @cache[file] ||= begin
          file = path_converter.convert(file)
          Digest::MD5.file(file).hexdigest if File.exist?(file)
        end
      end
    end
  end
end