diff --git a/lib/slather/coverage_service/html_output.rb b/lib/slather/coverage_service/html_output.rb index ab411c59..783e53f4 100644 --- a/lib/slather/coverage_service/html_output.rb +++ b/lib/slather/coverage_service/html_output.rb @@ -155,10 +155,10 @@ def create_html_from_file(coverage_file) next unless line_number > 0 coverage_data = data[0].strip - line_data = [line_number, data[2], hits_for_coverage_data(coverage_data)] + line_data = [line_number, data[2], hits_for_coverage_line(coverage_file, line)] classes = ["num", "src", "coverage"] - cov.tr(:class => class_for_coverage_data(coverage_data)) { + cov.tr(:class => class_for_coverage_line(coverage_file,line)) { line_data.each_with_index { |line, idx| if idx != 1 cov.td(line, :class => classes[idx]) @@ -221,19 +221,21 @@ def gem_root_path File.expand_path File.join(File.dirname(__dir__), "../..") end - def class_for_coverage_data(coverage_data) - case coverage_data - when /\d/ then "covered" - when /#/ then "missed" - else "never" + def class_for_coverage_line(coverage_file, coverage_line) + hits = coverage_file.coverage_for_line(coverage_line) + case + when hits == nil then "never" + when hits > 0 then "covered" + else "missed" end end - def hits_for_coverage_data(coverage_data) - case coverage_data - when /\d/ then (coverage_data.to_i > 0) ? "#{coverage_data}x" : "" - when /#/ then "!" - else "" + def hits_for_coverage_line(coverage_file, coverage_line) + hits = coverage_file.coverage_for_line(coverage_line) + case + when hits == nil then "" + when hits > 0 then "#{hits}x" + else "!" end end diff --git a/spec/fixtures/fixtures_html/Branches.m.html b/spec/fixtures/fixtures_html/Branches.m.html index 67cb8cd4..a77d9ba1 100644 --- a/spec/fixtures/fixtures_html/Branches.m.html +++ b/spec/fixtures/fixtures_html/Branches.m.html @@ -102,15 +102,15 @@

spec/fixtures/fixtures/more_files/Branches.m

        if (!skipBranches) {
1x - + 19
            NSLog(@"not skipped.");
- +! - + 20
        }
- +! 21 @@ -152,80 +152,80 @@

spec/fixtures/fixtures/more_files/Branches.m

    }
2x - + 29
    switch (i) {
- +! - + 30
        case 0:
- +! - + 31
            NSLog(@"0");
- +! - + 32
            break;
- +! - + 33
            
- +! - + 34
        case 1:
- +! - + 35
            NSLog(@"1");
- +! - + 36
            break;
- +! - + 37
        case 5:
- +! - + 38
            NSLog(@"5");
- +! - + 39
            break;
- +! - + 40
        default:
- +! - + 41
            break;
- +! - + 42
    }
- +! - + 43
}
- +! 44 diff --git a/spec/fixtures/fixtures_html/fixtures.m.html b/spec/fixtures/fixtures_html/fixtures.m.html index 659060c6..1bba7f97 100644 --- a/spec/fixtures/fixtures_html/fixtures.m.html +++ b/spec/fixtures/fixtures_html/fixtures.m.html @@ -102,20 +102,20 @@

spec/fixtures/fixtures/fixtures.m

- (void)untestedMethod
- + 19
{
- +! - + 20
    NSLog(@"untested");
- +! - + 21
}
- +! 22