Class: Gem::Guardian::ReportBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/gem/guardian/report_builder.rb

Overview

Builds machine-readable verification reports.

Instance Method Summary collapse

Constructor Details

#initialize(version:) ⇒ ReportBuilder

Returns a new instance of ReportBuilder.

Parameters:

  • version (String)

    gem-guardian version string



8
9
10
# File 'lib/gem/guardian/report_builder.rb', line 8

def initialize(version:)
  @version = version
end

Instance Method Details

#build(results, lockfile_data:, provenance_results: [], lockfile_path: nil) ⇒ Object

Returns a JSON-friendly hash for the current verification run.



13
14
15
16
17
18
19
20
21
22
# File 'lib/gem/guardian/report_builder.rb', line 13

def build(results, lockfile_data:, provenance_results: [], lockfile_path: nil)
  {
    version: @version,
    command: "verify",
    mode: lockfile_data ? "lockfile" : "explicit",
    lockfile: lockfile_path,
    checksums: checksum_summary(lockfile_data),
    results: results.map.with_index { |result, index| build_result(result, provenance_results[index]) }
  }
end