Module: TestProf::AnyFixture::Dump::Digest

Defined in:
lib/test_prof/any_fixture/dump/digest.rb

Class Method Summary collapse

Class Method Details

.call(*paths) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 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