#!perl
my
@modules
=
qw(
Carp
ExtUtils::MakeMaker
POE::Filter
Scalar::Util
Test::Deep
Test::More
parent
perl
strictures
)
;
my
$cpan_meta
=
"CPAN::Meta"
;
if
( -f
"MYMETA.json"
&&
eval
"require $cpan_meta"
) {
if
(
my
$meta
=
eval
{ CPAN::Meta->load_file(
"MYMETA.json"
) } ) {
my
$prereqs
=
$meta
->prereqs;
delete
$prereqs
->{develop};
my
%uniq
=
map
{
$_
=> 1}
map
{
keys
%$_
}
map
{
values
%$_
}
values
%$prereqs
;
$uniq
{
$_
} = 1
for
@modules
;
@modules
=
sort
keys
%uniq
;
}
}
my
@reports
= [
qw/Version Module/
];
for
my
$mod
(
@modules
) {
next
if
$mod
eq
'perl'
;
my
$file
=
$mod
;
$file
=~ s{::}{/}g;
$file
.=
".pm"
;
my
(
$prefix
) =
grep
{ -e catfile(
$_
,
$file
) }
@INC
;
if
(
$prefix
) {
my
$ver
= MM->parse_version( catfile(
$prefix
,
$file
) );
$ver
=
"undef"
unless
defined
$ver
;
push
@reports
, [
$ver
,
$mod
];
}
else
{
push
@reports
, [
"missing"
,
$mod
];
}
}
if
(
@reports
) {
my
$vl
= max
map
{
length
$_
->[0] }
@reports
;
my
$ml
= max
map
{
length
$_
->[1] }
@reports
;
splice
@reports
, 1, 0, [
"-"
x
$vl
,
"-"
x
$ml
];
diag
"Prerequisite Report:\n"
,
map
{
sprintf
(
" %*s %*s\n"
,
$vl
,
$_
->[0],-
$ml
,
$_
->[1])}
@reports
;
}
pass;