App-EPAN
view release on metacpan or search on metacpan
lib/App/EPAN.pm view on Meta::CPAN
$self->_index_for($basedir);
},
'output', # configuration key to look output file
$basedir->file(qw< modules 02packages.details.txt.gz >) # default
);
$self->_save(
'03modlist.data', # name
<<'END_OF_03_MODLIST_DATA',
File: 03modlist.data
Description: These are the data that are published in the module
list, but they may be more recent than the latest posted
modulelist. Over time we'll make sure that these data
can be used to print the whole part two of the
modulelist. Currently this is not the case.
Modcount: 0
Written-By: PAUSE version 1.005
Date: Sun, 28 Jul 2013 07:41:15 GMT
package CPAN::Modulelist;
# Usage: print Data::Dumper->new([CPAN::Modulelist->data])->Dump or similar
# cannot 'use strict', because we normally run under Safe
# use strict;
sub data {
my $result = {};
my $primary = "modid";
for (@$CPAN::Modulelist::data){
my %hash;
@hash{@$CPAN::Modulelist::cols} = @$_;
$result->{$hash{$primary}} = \%hash;
}
return $result;
}
$CPAN::Modulelist::cols = [ ];
$CPAN::Modulelist::data = [ ];
END_OF_03_MODLIST_DATA
'modlist', # configuration key to look output file
$basedir->file(qw< modules 03modlist.data.gz >) # default
);
} ## end sub _do_index
sub _save2 {
my ($self, $path, $contents) = @_;
my ($fh, $is_gz);
if (ref($path) eq 'GLOB') {
$fh = $path;
$is_gz = 0;
}
else {
$path->dir()->mkpath() unless -d $path->dir()->stringify();
$fh = $path->open('>');
$is_gz = $path->stringify() =~ m{\.gz$}mxs;
}
if ($is_gz) {
my $gz = Compress::Zlib::gzopen($fh, 'wb');
$gz->gzwrite($contents);
$gz->gzclose();
}
else {
binmode $fh;
print {$fh} $contents;
}
return;
} ## end sub _save2
sub _index_for {
my ($self, $path) = @_;
$path //= $self->target_dir;
my @index = $self->_index_body_for($path);
our $VERSION ||= 'whateva';
my $header = <<"END_OF_HEADER";
File: 02packages.details.txt
URL: http://cpan.perl.org/modules/02packages.details.txt.gz
Description: Package names found in directory \$CPAN/authors/id/
Columns: package name, version, path
Intended-For: Automated fetch routines, namespace documentation.
Written-By: epan $VERSION
Line-Count: ${ \ scalar @index }
Last-Updated: ${ \ scalar localtime() }
END_OF_HEADER
return join "\n", $header, @index, '';
} ## end sub _index_for
sub _collect_index_for {
my ($self, $path) = @_;
$path //= $self->target_dir;
$path = dir($path);
LOGDIE "path '$path' does not exist (wrong -t option?)" unless -d $path;
my $idpath = $path->subdir(qw< authors id >);
my %data_for;
for my $file (File::Find::Rule->extras({follow => 1})->file()
->in($idpath->stringify()))
{
INFO "indexing $file";
my $index_path =
file($file)->relative($idpath)->as_foreign('Unix')->stringify();
my $dm = Dist::Metadata->new(file => $file);
my $version_for = $dm->package_versions();
$data_for{distro}{$index_path} = $version_for;
(my $bare_index_path = $index_path) =~
s{^(.)/(\1.)/(\2.*?)/}{$3/}mxs;
$data_for{bare_distro}{$bare_index_path} = $version_for;
my %_localdata_for;
my $score = 0;
my $previous;
while (my ($module, $version) = each %$version_for) {
my $print_version = $version // 'undef';
DEBUG "data for $module: [$print_version] [$index_path]";
$_localdata_for{$module} = {
version => $version,
distro => $index_path,
_file => $file,
};
next if $score != 0;
next unless exists($data_for{module}{$module});
$previous = $data_for{module}{$module};
DEBUG 'some previous version exists';
( run in 0.884 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )