File: html_builder.rb

package info (click to toggle)
ruby-test-prof 0.12.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 508 kB
  • sloc: ruby: 4,075; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 494 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

require "json"

module TestProf
  module Utils
    # Generates static HTML reports with injected data
    module HTMLBuilder
      class << self
        def generate(data:, template:, output:)
          template = File.read(TestProf.asset_path(template))
          template.sub! "/**REPORT-DATA**/", data.to_json

          outpath = TestProf.artifact_path(output)
          File.write(outpath, template)
          outpath
        end
      end
    end
  end
end