Class: DocGuard::Shared::Subprocesses::CalculateCurrentDigests

Inherits:
Object
  • Object
show all
Defined in:
lib/doc_guard/shared/subprocesses/calculate_current_digests.rb

Overview

Calculates SHA256 digests for a map of documentation files and their tracked source files.

Input: { "docs/user.md" => ["app/models/user.rb", "app/services/authenticator.rb"], "docs/admin.md" => ["app/models/admin.rb"] }

Output: { "docs/user.md" => { "app/models/user.rb" => "abcd1234...", "app/services/authenticator.rb" => "efgh5678..." }, "docs/admin.md" => { "app/models/admin.rb" => nil # file missing } }

Class Method Summary collapse

Class Method Details

.run(tracked_files: {}) ⇒ Hash<String, Hash<String, String?>>

Runs the subprocess to calculate SHA256 digests per documentation file and its tracked source files.

Parameters:

  • tracked_files (Hash<String, Array<String>>) (defaults to: {})

    Mapping of documentation files to lists of tracked source file paths.

Returns:

  • (Hash<String, Hash<String, String?>>)

    Mapping of documentation files to tracked source files and their SHA256 digests (or nil if missing).



30
31
32
33
34
35
36
# File 'lib/doc_guard/shared/subprocesses/calculate_current_digests.rb', line 30

def self.run(tracked_files: {})
  tracked_files.transform_values do |source_files|
    source_files.each_with_object({}) do |file, digest_map|
      digest_map[file] = File.exist?(file) ? Digest::SHA256.hexdigest(File.read(file)) : nil
    end
  end
end