#!/usr/bin/perl
# Copyright 2012-2013, Paul Johnson (paul@pjcj.net)
# 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
use strict;
use warnings;
my $moddir = glob "~/.cpanm/work";
my $covdir = glob "~/cpancover";
my $lnkdir = "$covdir/modules";
my $resdir = "$covdir/results";
mkdir $covdir, 0750 unless -d $covdir;
mkdir $lnkdir, 0750 unless -d $lnkdir;
mkdir $resdir, 0750 unless -d $resdir;
for my $d (grep -d, <$moddir/*/*>)
{
print "Linking $d\n";
my ($e) = $d =~ m|/([^/]+)$| or die "Can't find module name";
my $new = "$lnkdir/$e";
unlink $new if -e $new;
symlink $d => $new;
}
my $c;
$c .= "cpancover -directory $lnkdir -outputdir $resdir ";
$c .= "-outputfile index.html -report html_basic";
# $c .= " -force";
# $c .= " -redo_html";
print "running [$c]\n";
system $c;