Class: Henitai::Reporter::Html
- Inherits:
-
Base
- Object
- Base
- Henitai::Reporter::Html
show all
- Defined in:
- lib/henitai/reporter.rb,
sig/henitai.rbs
Overview
Instance Attribute Summary
Attributes inherited from Base
#config, #history_store
Instance Method Summary
collapse
Methods inherited from Base
#authoritative?, #canonical_path, #initialize
Instance Method Details
#escaped_report_json(schema) ⇒ String
459
460
461
462
463
464
|
# File 'lib/henitai/reporter.rb', line 459
def escaped_report_json(schema)
JSON.pretty_generate(schema)
.gsub("&", "\\u0026")
.gsub("<", "\\u003c")
.gsub(">", "\\u003e")
end
|
#html_document(schema) ⇒ String
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
|
# File 'lib/henitai/reporter.rb', line 428
def html_document(schema)
<<~HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Henitai mutation report</title>
</head>
<body>
<mutation-test-report-app titlePostfix="Henitai"></mutation-test-report-app>
<script src="https://www.unpkg.com/mutation-testing-elements"></script>
<script type="application/json" id="henitai-report-data">#{escaped_report_json(schema)}</script>
<script>
const report = JSON.parse(
document.getElementById("henitai-report-data").textContent
);
document.querySelector("mutation-test-report-app").report = report;
</script>
</body>
</html>
HTML
end
|
#report(result) ⇒ void
This method returns an undefined value.
413
414
415
|
# File 'lib/henitai/reporter.rb', line 413
def report(result)
report_schema(schema_for(result))
end
|
#report_path ⇒ String
424
425
426
|
# File 'lib/henitai/reporter.rb', line 424
def report_path
File.join(config.reports_dir, "mutation-report.html")
end
|
#report_schema(schema) ⇒ void
This method returns an undefined value.
417
418
419
420
|
# File 'lib/henitai/reporter.rb', line 417
def report_schema(schema)
FileUtils.mkdir_p(File.dirname(report_path))
File.write(report_path, html_document(schema))
end
|
#schema_for(result) ⇒ Hash[untyped, untyped]
452
453
454
455
456
457
|
# File 'lib/henitai/reporter.rb', line 452
def schema_for(result)
schema = result.to_stryker_schema
return schema if authoritative?(result)
CanonicalReportMerger.merge(schema, canonical_path, prune_missing: true)
end
|