module TestProf::AnyFixture::Dump::Digest

Public Instance Methods

call(*paths) click to toggle source
# File lib/test_prof/any_fixture/dump/digest.rb, line 11
def call(*paths)
  files = (AnyFixture.config.default_dump_watch_paths + paths).each_with_object([]) do |path_or_glob, acc|
    if File.file?(path_or_glob)
      acc << path_or_glob
    else
      acc = acc.concat Dir[path_or_glob]
    end
    acc
  end

  return if files.empty?

  file_ids = files.sort.map { |f| "#{File.basename(f)}/#{::Digest::SHA1.file(f).hexdigest}" }
  ::Digest::SHA1.hexdigest(file_ids.join("/"))
end