Class: DocGuard::RecordDocumentationRelevance::Subprocesses::RecordDigests

Inherits:
Object
  • Object
show all
Defined in:
lib/doc_guard/record_documentation_relevance/subprocesses/record_digests.rb

Overview

Records the current file digests into a configured file path.

Class Method Summary collapse

Class Method Details

.run(digests: {}, config: ::DocGuard::Config.new) ⇒ Hash{Symbol => Symbol, Object}

Writes the given digests as pretty-printed JSON to the configured file path.

Parameters:

  • digests (Hash<String, Hash<String, String?>>) (defaults to: {})

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

  • config (DocGuard::Config) (defaults to: ::DocGuard::Config.new)

    Configuration object with ‘digests_store_file_path`.

Returns:

  • (Hash{Symbol => Symbol, Object})

    Status result:

    • On success: { status: :ok }

    • On failure: { status: :error, error: error_object }



18
19
20
21
22
23
# File 'lib/doc_guard/record_documentation_relevance/subprocesses/record_digests.rb', line 18

def self.run(digests: {}, config: ::DocGuard::Config.new)
  File.write(config.digests_store_file_path, JSON.pretty_generate(digests))
  { status: :ok }
rescue StandardError => error
  { status: :error, error: error }
end