Class: RisksOverview

Inherits:
BaseDocument show all
Includes:
RpnRendering
Defined in:
lib/almirah/doc_types/risks_overview.rb

Overview

The all-registries summary page (ADR-219): build/risks/overview.html, the target of the top-menu Risks button. One table row per registry, in file-system order, with the columns Risk Registry (linked to the registry page), Total Risks, Open Risks, Highest RPN and Average RPN — the RPN aggregates computed over the registry's leading RPN group, ignoring records whose group value is blank. The Risk Registry cell shows the registry preface's frontmatter title, falling back to the folder name (ENH-221).

Constant Summary collapse

OPEN_EXCLUDED_STATUS =
'Closed'

Instance Attribute Summary collapse

Attributes inherited from BaseDocument

#dom, #headings, #id, #output_rel_path, #title

Instance Method Summary collapse

Methods included from RpnRendering

#format_rpn, #rpn_threshold_class

Methods inherited from BaseDocument

#decisions_link, #home_link, #index_link, #needs_chartjs?, #rel_to, #risks_link, #save_html_to_file

Constructor Details

#initialize(registries, configuration, prefaces = {}) ⇒ RisksOverview

registries is the ordered list of [name, records] pairs; prefaces maps a registry name to its parsed overview.md, when it has one.



22
23
24
25
26
27
28
29
# File 'lib/almirah/doc_types/risks_overview.rb', line 22

def initialize(registries, configuration, prefaces = {})
  super()
  @registries = registries
  @configuration = configuration
  @prefaces = prefaces
  @id = 'overview'
  @title = 'Risk Registries'
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



18
19
20
# File 'lib/almirah/doc_types/risks_overview.rb', line 18

def configuration
  @configuration
end

#prefacesObject

Returns the value of attribute prefaces.



18
19
20
# File 'lib/almirah/doc_types/risks_overview.rb', line 18

def prefaces
  @prefaces
end

#registriesObject

Returns the value of attribute registries.



18
19
20
# File 'lib/almirah/doc_types/risks_overview.rb', line 18

def registries
  @registries
end

Instance Method Details

#to_consoleObject



31
32
33
# File 'lib/almirah/doc_types/risks_overview.rb', line 31

def to_console
  puts "\e[36mRisks Overview: #{@id}\e[0m"
end

#to_html(output_file_path) ⇒ Object



35
36
37
38
39
40
# File 'lib/almirah/doc_types/risks_overview.rb', line 35

def to_html(output_file_path)
  html_rows = ['']
  html_rows.append "<h1>#{@title}</h1>\n"
  html_rows.append render_registries_table
  save_html_to_file(html_rows, nil, output_file_path)
end