Skip to content

Commit

Permalink
Add -restrict option to html_basic..
Browse files Browse the repository at this point in the history
Option defaults to on.
  • Loading branch information
pjcj committed Jan 20, 2013
1 parent af603bf commit 3848cae
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Changes
Expand Up @@ -3,6 +3,8 @@ Devel::Cover history
{{$NEXT}}
- Fix segv in constant folding of xor ops (gitbub 40).
- Fix various problems running Devel::Cover under tainting (github 41).
- Add JavaScript to filter results in html_basic (David Cantrell) (github 42).
Use -norestrict option to keep previous behaviour.

Release 0.99 - 31 December 2012
- Improve documentation (Olaf Alders) (github 34).
Expand Down
2 changes: 2 additions & 0 deletions bin/cover
Expand Up @@ -419,6 +419,8 @@ The following reports are currently available:
text - detailed textual summary
html - detailed HTML reports
html_basic - detailed HTML reports with syntax highlighting
compilation - output in a format similar to Perl
=head1 OPTIONS
Expand Down
41 changes: 30 additions & 11 deletions lib/Devel/Cover/Report/Html_basic.pm
Expand Up @@ -379,12 +379,14 @@ sub get_options
{
my ($self, $opt) = @_;
$opt->{option}{outputfile} = "coverage.html";
$opt->{option}{restrict} = 1;
$threshold->{$_} = $opt->{"report_$_"} for
grep { defined $opt->{"report_$_"} } qw( c0 c1 c2 );
die "Invalid command line options" unless
GetOptions($opt->{option},
qw(
outputfile=s
restrict!
));
}

Expand Down Expand Up @@ -569,25 +571,35 @@ $Templates{summary} = <<'EOT';
</table>
<div><br></br></div>
[% IF R.options.option.restrict %]
<script language=javascript>
function filter_files(filter_by) {
var allelements = document.getElementsByTagName("tr");
var re_now = new RegExp(filter_by, 'i');
for(var i = 0; i < allelements.length; i++) {
if(allelements[i].className) {
if(filter_by == "" || allelements[i].className == "Total" || (filter_by.length && re_now.test(allelements[i].className))) {
allelements[i].style.display = "table-row";
} else if(filter_by.length && !re_now.test(allelements[i].className)) {
allelements[i].style.display = "none";
}
function filter_files(filter_by) {
var allelements = document.getElementsByTagName("tr");
var re_now = new RegExp(filter_by, "i");
for (var i = 0; i < allelements.length; i++) {
if (allelements[i].className) {
if (filter_by == "" || allelements[i].className == "Total" ||
(filter_by.length && re_now.test(allelements[i].className))) {
allelements[i].style.display = "table-row";
} else if (filter_by.length &&
!re_now.test(allelements[i].className)) {
allelements[i].style.display = "none";
}
}
}
}
</script>
<form name=filterform action='javascript:filter_files(document.forms["filterform"]["filterfield"].value)'>Restrict to regex: <input type=text name=filterfield><input type=submit></form>
<form name=filterform
action='javascript:filter_files(document.forms["filterform"]["filterfield"].value)'>
Restrict to regex:
<input type=text name=filterfield><input type=submit>
</form>
<br />
[% END %]
<table class="sortable" id="coverage_table">
<thead>
Expand Down Expand Up @@ -816,6 +828,13 @@ This module provides a HTML reporting mechanism for coverage data. It
is designed to be called from the C<cover> program. It will add syntax
highlighting if C<PPI::HTML> or C<Perl::Tidy> is installed.
=head1 OPTIONS
The following command line options are supported:
-outputfile - name of output file (default coverage.html)
-restrict - add restrict to regex form (default on)
=head1 SEE ALSO
Devel::Cover
Expand Down

0 comments on commit 3848cae

Please sign in to comment.