Class: DocGuard::AssessDocumentationRelevance::Subprocesses::AssessRelevance

Inherits:
Object
  • Object
show all
Defined in:
lib/doc_guard/assess_documentation_relevance/subprocesses/assess_relevance.rb

Overview

Determines if documentation is outdated based on digest mismatches.

This subprocess receives a mapping of documentation files to the source files they describe, and compares that with a list of source files that have changed. If any documentation file references at least one changed file, it’s considered outdated.

Class Method Summary collapse

Class Method Details

.run(tracked_files: {}, mismatches: []) ⇒ Hash{Symbol => Object}

Assesses which documentation files are outdated based on file digest mismatches.

Parameters:

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

    Mapping of documentation file paths to the source files they reference.

  • mismatches (Array<String>) (defaults to: [])

    List of source files whose digests have changed.

Returns:

  • (Hash{Symbol => Object})
    • :relevant [Boolean] ‘true` if any documentation files are affected.

    • :mismatches [Hash=> Array<String>] Mapping of documentation files to the list of changed source files they reference.



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/doc_guard/assess_documentation_relevance/subprocesses/assess_relevance.rb', line 20

def self.run(tracked_files: {}, mismatches: [])
  documentation_mismatches = tracked_files.each_with_object({}) do |(documentation_file, source_files), acc|
    changed = source_files.select { |file| mismatches.include?(file) }
    acc[documentation_file] = changed unless changed.empty?
  end

  {
    relevant: documentation_mismatches.any?,
    mismatches: documentation_mismatches
  }
end