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
449
450
451
452
453
454
|
# File 'lib/henitai/reporter.rb', line 449
def escaped_report_json(schema)
JSON.pretty_generate(schema)
.gsub("&", "\\u0026")
.gsub("<", "\\u003c")
.gsub(">", "\\u003e")
end
|
#html_document(schema) ⇒ String
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
|
# File 'lib/henitai/reporter.rb', line 418
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.
403
404
405
|
# File 'lib/henitai/reporter.rb', line 403
def report(result)
report_schema(schema_for(result))
end
|
#report_path ⇒ String
414
415
416
|
# File 'lib/henitai/reporter.rb', line 414
def report_path
File.join(config.reports_dir, "mutation-report.html")
end
|
#report_schema(schema) ⇒ void
This method returns an undefined value.
407
408
409
410
|
# File 'lib/henitai/reporter.rb', line 407
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]
442
443
444
445
446
447
|
# File 'lib/henitai/reporter.rb', line 442
def schema_for(result)
schema = result.to_stryker_schema
return schema if authoritative?(result)
CanonicalReportMerger.merge(schema, canonical_path, prune_missing: true)
end
|