sub print_details_hash { my $self = shift; my (@files) = @_; @files = sort keys %{$self->{cover}} unless @files; for my $file (@files) { print "$file\n\n"; my $lines = $self->{cover}{$file}{statement}; my $fmt = "%-5d: %6s %s\n";

    open F, $file or carp("Unable to open $file: $!"), next;

    while (<F>)
    {
        if (exists $lines->{$.})
        {
            my @c = @{$lines->{$.}};
            printf "%5d: %6d %s", $., shift(@c)->[0], $_;
            printf "     : %6d\n", shift(@c)->[0] while @c;
        }
        else
        {
            printf "%5d:        %s", $., $_;
        }
    }

    close F or croak "Unable to close $file: $!";
    print "\n\n";
}
}

sub print_details { my $self = shift; my (@files) = @_; my $cover = $self->cover; @files = sort $cover->items unless @files; for my $file (@files) { print "$file\n\n"; my $f = $cover->file($file); my $statement = $f->statement; my $fmt = "%-5d: %6s %s\n";

    open F, $file or carp("Unable to open $file: $!"), next;

    while (<F>)
    {
        if (defined (my $location = $statement->location($.)))
        {
            my @c = @{$location};
            printf "%5d: %6d %s", $., shift(@c)->[0], $_;
            printf "     : %6d\n", shift(@c)->[0] while @c;
        }
        else
        {
            printf "%5d:        %s", $., $_;
        }
    }

    close F or croak "Unable to close $file: $!";
    print "\n\n";
}
}

NAME

Devel::Cover::DB - Code coverage metrics for Perl

SYNOPSIS

use Devel::Cover::DB;

my $db = Devel::Cover::DB->new(db => "my_coverage_db");
$db->print_summary(statement => 1, pod => 1);
$db->print_details;

DESCRIPTION

This module provides access to a database of code coverage information.

SEE ALSO

Devel::Cover

METHODS

new

my $db = Devel::Cover::DB->new(db => "my_coverage_db");

Contructs the DB from the specified database.

cover

my $cover = $db->cover;

Returns a Devel::Cover::DB::Cover object. From here all the coverage data may be accessed.

my $cover = $db->cover;
for my $file ($cover->items)
{
    print "$file\n";
    my $f = $cover->file($file);
    for my $criterion ($f->items)
    {
        print "  $criterion\n";
        my $c = $f->criterion($criterion);
        for my $location ($c->items)
        {
            my $l = $c->location($location);
            print "    $location @$l\n";
        }
    }
}

Data for different criteria will be in different formats, so that will need special handling, but I'll deal with that when we have the data for different criteria.

If you don't want to remember all the method names, use values() instead of files(), criteria() and locations() and get() instead of file(), criterion() and location().

Instead of calling $file->criterion("x") you can also call $file->x.

BUGS

Huh?

VERSION

Version 0.32 - 4th January 2004

LICENCE

Copyright 2001-2004, Paul Johnson (pjcj@cpan.org)

This software is free. It is licensed under the same terms as Perl itself.

The latest version of this software should be available from my homepage: http://www.pjcj.net