Devel-CoverReport

 view release on metacpan or  search on metacpan

lib/Devel/CoverReport.pm  view on Meta::CPAN

                }

                last;
            }
            push @rows, reverse @folders_sub_summary;
        }

        push @rows, $file_summary;
    }

    # Rows are now prepared, and can be added to the table.
    foreach my $row (reverse @rows) {
        $covered_table->add_row($row);
    }

    # Add total summary as well:
    $covered_table->add_summary($total_summary);
    
    return $self->{'formatter'}->close_report('Summary');
} # }}}

################################################################################
#                     Version Control System support                           #
################################################################################

# Purpose:
#   Get metadata from Version Control System, about the file.
#
#   Returns undef, if the file is not controled by VCS or if metadata can not be extracted.
# 
# Returns:
#   Hashref = {
#       current => {                    # File's metadata (currently unused!)
#           vcs    => 'git',                    # What VCS controls the file
#           author => 'ntnl',                   # Username, that made the change
#           cid    => '2fdddeeaa7ef5e9ddc90',   # Commit ID or Revision
#           date   => 1278492553                # Unix timestamp, when the change was made.
#       },
#       lines => [                      # Per-line information (index in table = line number, counter from 0)
#           {                               # Information about first line in the file.
#               author => 'ntnl',
#               cid    => '2fdddeeaa7ef5e9ddc90'
#           },
#           ...
#       ],
#   }
#   Note: to conserve memory, references in @lines can re-use their targets, so please - clone them before doing changes!
sub _get_vcs_metadata { # {{{
    my ( $self, $filename ) = @_;

    # Detect what VCS handles the file...
    my ( $basedir ) = ( $filename =~ m{^(.*?)/[^/]+$}s );
    my $vcs;

    # Probe for Subversion
    if (-d $basedir .q{/.svn}) {
        $vcs = 'SVN';
    }

    # Probe for Git
    my @dir_parts = split m{/}, $basedir;
    while (1) {
        my $tmp_path = join q{/}, @dir_parts, q{.git};

        if (-d $tmp_path) {
            $vcs = 'Git';
            last;
        }

        if (not scalar @dir_parts) {
            last;
        }

        shift @dir_parts;
    }

    # Not under VCS? OK - I can live with it :)
    if (not $vcs) {
        return;
    }

    # Try to load proper plugin...
    my $r_path = q{Devel/CoverReport/VCS/} . $vcs .q{.pm};

    require $r_path;
    
    # Query the plugin for data...
    my $sub_name = q{Devel::CoverReport::VCS::} . $vcs .q{::inspect};

    my $metadata = &{ \&{ $sub_name } }($filename);

    if (not $metadata) {
        return;
    }

#    use Data::Dumper; die Dumper $metadata;

    foreach my $line (@{ $metadata->{'lines'} }) {
        $self->{'vcs_cache'}->{ $line->{'_id'} } = $line;
    }

    return $metadata;
} # }}}


sub make_vcs_commits_report { # {{{
    my ( $self ) = @_;

    my $vcs_report = $self->{'formatter'}->add_report(
        code     => 'VCS',
        basename => 'vcs_report',
        title    => 'Version Control System summary'
    );

    my $vcs_table = $self->{'formatter'}->add_table(
        'VCS',
        'Commits',
        {
            label => 'Version Control System summary:',

            headers => {



( run in 0.529 second using v1.01-cache-2.11-cpan-71847e10f99 )