Class: DocGuard::Shared::Subprocesses::CalculateCurrentDigests
- Inherits:
-
Object
- Object
- DocGuard::Shared::Subprocesses::CalculateCurrentDigests
- 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
-
.run(tracked_files: {}) ⇒ Hash<String, Hash<String, String?>>
Runs the subprocess to calculate SHA256 digests per documentation file and its tracked source files.
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.
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 |