Meta
view release on metacpan or search on metacpan
Meta/Lang/Perl/Deps.pm view on Meta::CPAN
return($modu);
}
sub module_to_file($) {
my($modu)=@_;
$modu=~s/::/\//g;
$modu="perl/lib/".$modu.".pm";
return($modu);
}
sub file_to_module($) {
my($file)=@_;
$file=~s/\//::/g;
my($resu)=($file=~/(.*)\.pm$/);
return($resu);
}
sub module_to_deps($) {
my($modu)=@_;
return("deps/".Meta::Utils::Utils::replace_suffix($modu,".deps"));
}
sub extfile_to_module($) {
my($file)=@_;
my($path)=join(':',@INC);
my($remove)=Meta::Utils::File::Path::remove_path($path,':',$file);
return(&file_to_module($remove));
}
sub deps_to_module($) {
my($deps)=@_;
my($module)=($deps=~/deps\/(.*)\.deps$/);
if($module eq "") {
throw Meta::Error::Simple("module is nothing from deps [".$deps."]");
}
my($suff);
if($module=~/^perl\/bin/) {
$suff=".pl";
}
if($module=~/^perl\/lib/) {
$suff=".pm";
}
return($module.$suff);
}
sub deps_file_to_module($) {
my($file)=@_;
}
sub add_deps($$$$$) {
my($grap,$modu,$inte,$exte,$path)=@_;
$grap->node_insert($modu);
my($fdep)=&module_to_deps($modu);
my($deps)=Meta::Utils::File::Path::resolve($path,$fdep,":");
my($io)=Meta::IO::File->new_reader($deps);
while(!$io->eof()) {
my($line)=$io->cgetline();
if($line=~/^\/\*/) {#skip comment lines
next;
}
if($line=~/^cascade .*=$/) {#read name of module and make sure it's the one we got
my($node)=($line=~/^cascade (.*)=$/);
if($node ne $modu) {
throw Meta::Error::Simple("node [".$node."] ne modu [".$modu."]");
}
next;
}
if($line eq ";") {#skip the end line
next;
}
#otherwise - its an edge-find out if we want to add it
my($addx);
if(&is_internal($line)) {
$addx=$inte;
} else {
$addx=$exte;
}
if($addx) {#this is the actual addition
$grap->node_insert($line);
$grap->edge_insert($modu,$line);
}
}
$io->close();
}
sub add_deps_rec($$$$$) {
my($grap,$modu,$inte,$exte,$visi)=@_;
if(!(exists($visi->{$modu}))) {
$visi->{$modu}=defined;
#Meta::Utils::Output::print("visiting [".$modu."]\n");
my($path)=Meta::Baseline::Aegis::search_path();
&add_deps($grap,$modu,$inte,$exte,$path);
my($edge)=$grap->edge_ou($modu);
for(my($i)=0;$i<$edge->size();$i++) {
my($curr)=$edge->elem($i);
#Meta::Utils::Output::print("curr is [".$curr."]\n");
if(&is_internal($curr)) {
add_deps_rec($grap,$curr,$inte,$exte,$visi);
}
}
}
}
sub TEST($) {
my($context)=@_;
my($modu)="perl/lib/Meta/Utils/File/File.pm";
my($grap)=Meta::Development::Deps->new();
Meta::Lang::Perl::Deps::add_deps_rec($grap,$modu,1,1,{});
Meta::Utils::Output::print("number of nodes is [".$grap->node_size()."]\n");
Meta::Utils::Output::print("number of edges is [".$grap->edge_size()."]\n");
return(1);
}
1;
__END__
=head1 NAME
Meta::Lang::Perl::Deps - module to help you handle perl dependency information.
=head1 COPYRIGHT
( run in 3.030 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )