Makes the proper tree, needs to be traversed and run via cpanm to test each case
This commit is contained in:
parent
be98186beb
commit
eadb3eaadd
1 changed files with 18 additions and 4 deletions
22
test.pl
22
test.pl
|
@ -3,12 +3,13 @@ use 5.22.0;
|
|||
|
||||
package Module;
|
||||
use Moose;
|
||||
use Module::CoreList;
|
||||
|
||||
has 'name' => (is => 'ro');
|
||||
has 'version' => (is => 'ro');
|
||||
|
||||
has 'depends' => (
|
||||
default => sub {my $self=shift; get_deps($self->name)},
|
||||
builder => 'get_deps',
|
||||
is => 'ro',
|
||||
isa => 'ArrayRef[Module]',
|
||||
lazy => 1,
|
||||
|
@ -27,14 +28,26 @@ sub new_module {
|
|||
$cache{$name} = Module->new(name => $name);
|
||||
}
|
||||
|
||||
sub get_deps {
|
||||
sub _is_core {
|
||||
my $module = shift;
|
||||
chomp $module;
|
||||
my ($name, $version) = split (/[\-~]/, $module);
|
||||
|
||||
return [] if $module eq 'perl';
|
||||
my $ret = ($name eq 'perl' || Module::CoreList->first_release($name)) // 0;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
sub get_deps {
|
||||
my $self=shift;
|
||||
my $module = $self->name;
|
||||
|
||||
# skip perl, or core modules
|
||||
return [] if _is_core($module);
|
||||
|
||||
open(my $ph, "-|", qw/cpanm --quiet --showdeps/, $module);
|
||||
|
||||
return [map {Module->new_module($_)} <$ph>];
|
||||
return [map {Module->new_module($_)} grep {!_is_core($_)} <$ph>];
|
||||
}
|
||||
|
||||
sub print_deps {
|
||||
|
@ -54,3 +67,4 @@ use Data::Dumper;
|
|||
|
||||
my $foo = Module->new_module('Moose');
|
||||
$foo->print_deps(0, []);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue