Module: ArchUnit::Metrics::Reporting::MetricsExporter

Defined in:
lib/archunit/metrics/reporting/metrics_exporter.rb

Overview

Renders caller-supplied metric data as a complete offline HTML document.

Constant Summary collapse

DEFAULT_CSS =
<<~CSS
  :root { color-scheme: light dark; font-family: system-ui, sans-serif; }
  body { max-width: 960px; margin: 0 auto; padding: 2rem; }
  h1 { margin-bottom: .25rem; }
  .timestamp { color: #666; margin-top: 0; }
  table { border-collapse: collapse; margin-top: 1.5rem; width: 100%; }
  th, td { border: 1px solid #bbb; padding: .6rem .8rem; text-align: left; }
  th { background: rgba(127, 127, 127, .14); }
  tr:nth-child(even) { background: rgba(127, 127, 127, .07); }
  footer { color: #666; font-size: .85rem; margin-top: 2rem; }
CSS

Class Method Summary collapse

Class Method Details

.export_as_html(data, options = nil) ⇒ Object

Raises:

  • (ArgumentError)


28
29
30
31
32
33
34
35
# File 'lib/archunit/metrics/reporting/metrics_exporter.rb', line 28

def export_as_html(data, options = nil)
  raise ArgumentError, 'data must be a Hash' unless data.is_a?(Hash)

  options = MetricsExportOptions.resolve(options)
  html = render(data, options).freeze
  write(options.output_path, html) if options.output_path
  html
end