5 # Copyright © 2014 Guillem Jover <guillem@debian.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <https://www.gnu.org/licenses/>.
30 chdir $dir or die "cannot switch to $dir\n";
32 my $db = Devel
::Cover
::DB
->new(db
=> 'cover_db');
33 $db = $db->merge_runs();
34 $db->calculate_summary(map { $_ => 1 } $db->collected());
36 chdir $cwd or die "cannot switch to $cwd\n";
38 my $s = $db->{summary
}{Total
};
41 <td class="coverFile"><a href="%s">%s</a></td>
42 <td class="coverBar" align="center">
43 <table border=0 cellspacing=0 cellpadding=1>
44 <tr><td class="coverBarOutline">%s</td></tr>
52 ', "$dir/coverage.html", $dir, bar_html
($s->{total
}{percentage
}),
53 box_html
($s->{total
}), box_html
($s->{subroutine
}), box_html
($s->{branch
});
56 s/^(.*<td .*href="utils\/index\.html">.*)$/$tmpl$1/;
63 return 'emerald.png' if $num >= 90;
64 return 'ruby.png' if $num < 75;
71 my $html = sprintf '<img src="%s" width=%.0f height=10 alt="%.1f">',
72 bar_image
($num), $num, $num;
75 $html .= sprintf '<img src="snow.png" width=%.0f height=10 alt="%.1f">',
85 return 'Hi' if $num >= 90;
86 return 'Lo' if $num < 75;
93 return sprintf '<td class="coverPer%s">%.1f %%</td>' . "\n" .
94 '<td class="coverNum%s">%d / %d</td>',
95 box_rating
($stats->{percentage
}), $stats->{percentage
},
96 box_rating
($stats->{percentage
}), $stats->{covered
}, $stats->{total
};