Class: Henitai::CoverageReportReader
- Inherits:
-
Object
- Object
- Henitai::CoverageReportReader
- Defined in:
- lib/henitai/coverage_report_reader.rb
Overview
Reads coverage report formats used by Henitai.
Constant Summary collapse
- DEFAULT_COVERAGE_REPORT_PATH =
"coverage/.resultset.json"- DEFAULT_PER_TEST_COVERAGE_REPORT_PATH =
"coverage/henitai_per_test.json"
Instance Method Summary collapse
- #coverage_lines_by_file(path = DEFAULT_COVERAGE_REPORT_PATH) ⇒ Object
- #test_lines_by_file(path = DEFAULT_PER_TEST_COVERAGE_REPORT_PATH) ⇒ Object
Instance Method Details
#coverage_lines_by_file(path = DEFAULT_COVERAGE_REPORT_PATH) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/henitai/coverage_report_reader.rb', line 11 def coverage_lines_by_file(path = DEFAULT_COVERAGE_REPORT_PATH) return {} unless File.exist?(path) coverage = Hash.new { |hash, key| hash[key] = [] } JSON.parse(File.read(path)).each_value do |result| result.fetch("coverage", {}).each do |file, file_coverage| coverage[normalize_path(file)].concat(covered_lines(file_coverage)) end end coverage.transform_values(&:uniq).transform_values(&:sort) end |
#test_lines_by_file(path = DEFAULT_PER_TEST_COVERAGE_REPORT_PATH) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/henitai/coverage_report_reader.rb', line 24 def test_lines_by_file(path = DEFAULT_PER_TEST_COVERAGE_REPORT_PATH) return {} unless File.exist?(path) parsed = JSON.parse(File.read(path)) return {} unless parsed.is_a?(Hash) parsed.transform_values do |coverage| normalize_test_coverage(coverage) end end |