| 1 | # $Id: Info.pm 82 2020-05-30 06:14:27Z stro $ | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package CPAN::SQLite::Info; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 8 | our $VERSION = '0.218'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use English qw/-no_match_vars/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use CPAN::DistnameInfo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use File::Spec::Functions qw(catfile); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 8 | ▶ | use Compress::Zlib; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 8 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 8 | ▶ | use Safe; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | ▶ | use CPAN::SQLite::Util qw(vcmp print_debug); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 8 | my $ext = qr/\.(tar\.gz|tar\.Z|tgz|zip)$/; | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | ▶ | my ($class, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 4 | my $self = { dists => {}, auths => {}, mods => {}, info => {}, %args }; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | return bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | sub fetch_info { | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_info: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | ▶ | $self->mailrc() or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | ▶ | $self->dists_and_mods() or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | sub dists_and_mods { | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dists_and_mods: called CC=18 SCAR=30.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | my ($packages, $cpan_files) = $self->packages(); | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | my ($dists, $mods); | |||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | my $ignore = $self->{ignore}; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 4 | my $pat; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | ▶ | if ($ignore and ref($ignore) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ignore and ref $ignore eq "ARRAY"
MC/DC0%0/2
$ignore and ref $ignore eq "ARRAY"
$ignore
ref $ignore eq "ARRAY"
Truth table33%1/3
A and B
A= $ignoreB= ref $ignore eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $pat = join '|', @$ignore; | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | foreach my $cpan_file (keys %$cpan_files) { | |||||||||||||||||||||||||||||||||||||||||
| 44 | 44489 | ▶ | if ($pat and ($cpan_file =~ /^($pat)/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$pat and $cpan_file =~ /^($pat)/
MC/DC0%0/2
$pat and $cpan_file =~ /^($pat)/
$pat
$cpan_file =~ /^($pat)/
Truth table33%1/3
A and B
A= $patB= $cpan_file =~ /^($pat)/
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | delete $cpan_files->{$cpan_file}; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | print_debug("Ignoring $cpan_file\n"); | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 44489 | my $d = CPAN::DistnameInfo->new($cpan_file); | |||||||||||||||||||||||||||||||||||||||||
| 50 | 44489 | ▶ | next unless ($d->maturity eq 'released'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 44487 | my $dist_name = $d->dist; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 44487 | my $dist_vers = $d->version; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 44487 | my $cpanid = $d->cpanid; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 44487 | my $dist_file = $d->filename; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 44487 | ▶ | unless ($dist_name and $dist_vers and $cpanid) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$dist_name and $dist_vers and $cpanid
$dist_name and $dist_vers
MC/DC66%2/3
$dist_name and $dist_vers and $cpanid
$dist_name
$dist_vers
$cpanid
Truth table75%3/4
A and B and C
A= $dist_nameB= $dist_versC= $cpanid
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 98 | print_debug("No dist_name/version/cpanid for $cpan_file: skipping\n"); | |||||||||||||||||||||||||||||||||||||||||
| 57 | 98 | delete $cpan_files->{$cpan_file}; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 98 | next; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | # ignore specified dists | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 44389 | ▶ | if ($pat and ($dist_name =~ /^($pat)$/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$pat and $dist_name =~ /^($pat)$/
MC/DC0%0/2
$pat and $dist_name =~ /^($pat)$/
$pat
$dist_name =~ /^($pat)$/
Truth table33%1/3
A and B
A= $patB= $dist_name =~ /^($pat)$/
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | delete $cpan_files->{$cpan_file}; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | print_debug("Ignoring $dist_name\n"); | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 44389 | ▶ | if (not $dists->{$dist_name} or vcmp($dist_vers, $dists->{$dist_name}->{dist_vers}) > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $dists->{$dist_name} or vcmp($dist_vers, $dists->{$dist_name}{"dist_vers"}) > 0
MC/DC100%2/2
not $dists->{$dist_name} or vcmp($dist_vers, $dists->{$dist_name}{"dist_vers"}) > 0
not $dists->{$dist_name}
vcmp($dist_vers, $dists->{$dist_name}{"dist_vers"}) > 0
Truth table100%3/3
not(A) or B
A= not $dists->{$dist_name}B= vcmp($dist_vers, $dists->{$dist_name}{"dist_vers"}) > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 43005 | $dists->{$dist_name}->{dist_vers} = $dist_vers; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 43005 | $dists->{$dist_name}->{dist_file} = $dist_file; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 43005 | $dists->{$dist_name}->{cpanid} = $cpanid; | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | my $wanted; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 4 | foreach my $dist_name (keys %$dists) { | |||||||||||||||||||||||||||||||||||||||||
| 76 | 41927 | $wanted->{ basename($dists->{$dist_name}->{dist_file}) } = $dist_name; | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | foreach my $mod_name (keys %$packages) { | |||||||||||||||||||||||||||||||||||||||||
| 79 | 269316 | my $file = basename($packages->{$mod_name}->{dist_file}); | |||||||||||||||||||||||||||||||||||||||||
| 80 | 269316 | my $dist_name = $wanted->{$file}; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 269316 | ▶ | unless ($dist_name and $dists->{$dist_name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$dist_name and $dists->{$dist_name}
MC/DC50%1/2
$dist_name and $dists->{$dist_name}
$dist_name
$dists->{$dist_name}
Truth table66%2/3
A and B
A= $dist_nameB= $dists->{$dist_name}
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 33520 | delete $packages->{$mod_name}; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 33520 | next; | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 235796 | $mods->{$mod_name}->{dist_name} = $dist_name; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 235796 | $dists->{$dist_name}->{modules}->{$mod_name}++; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 235796 | $mods->{$mod_name}->{mod_vers} = $packages->{$mod_name}->{mod_vers}; | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 4 | $self->{dists} = $dists; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 4 | return $self->{mods} = $mods; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | sub modlist { | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
modlist: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | warn 'Modlist does not contain any useful info anymore'; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | sub packages { | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
packages: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 4 | my $index = 'modules/02packages.details.txt.gz'; | |||||||||||||||||||||||||||||||||||||||||
| 102 | my $packages = | ||||||||||||||||||||||||||||||||||||||||||
| 103 | $self->{keep_source_where} | ||||||||||||||||||||||||||||||||||||||||||
| 104 | ? CPAN::FTP->localize($index, catfile($self->{keep_source_where}, $index)) | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 4 | ▶ | : catfile($self->{CPAN}, $index); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 4 | ▶ | return unless check_file('modules/02packages.details.txt.gz', $packages); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 4 | print_debug("Reading information from $packages\n"); | |||||||||||||||||||||||||||||||||||||||||
| 108 | 4 | my $lines = zcat($packages); | |||||||||||||||||||||||||||||||||||||||||
| 109 | 4 | ▶ | while (@$lines) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 36 | my $shift = shift(@$lines); | |||||||||||||||||||||||||||||||||||||||||
| 111 | 36 | ▶ | last if $shift =~ /^\s*$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 4 | my ($mods, $cpan_files); | |||||||||||||||||||||||||||||||||||||||||
| 114 | 4 | foreach (@$lines) { | |||||||||||||||||||||||||||||||||||||||||
| 115 | 269316 | my ($mod_name, $mod_vers, $dist_file) = split(" ", $_, 4); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 269316 | ▶ | $mod_vers = undef if $mod_vers eq 'undef'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 269316 | $mods->{$mod_name} = { mod_vers => $mod_vers, dist_file => $dist_file }; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 269316 | $cpan_files->{$dist_file}++; | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 4 | return ($mods, $cpan_files); | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | sub mailrc { | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mailrc: called CC=6 SCAR=18.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 4 | my $index = 'authors/01mailrc.txt.gz'; | |||||||||||||||||||||||||||||||||||||||||
| 126 | my $mailrc = | ||||||||||||||||||||||||||||||||||||||||||
| 127 | $self->{keep_source_where} | ||||||||||||||||||||||||||||||||||||||||||
| 128 | ? CPAN::FTP->localize($index, catfile($self->{keep_source_where}, $index)) | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 4 | ▶ | : catfile($self->{CPAN}, $index); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 4 | ▶ | return unless check_file('authors/01mailrc.txt.gz', $mailrc); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 4 | print_debug("Reading information from $mailrc\n"); | |||||||||||||||||||||||||||||||||||||||||
| 132 | 4 | my $lines = zcat($mailrc); | |||||||||||||||||||||||||||||||||||||||||
| 133 | 4 | my $auths; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 4 | foreach (@$lines) { | |||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | #my($cpanid,$fullname,$email) = | ||||||||||||||||||||||||||||||||||||||||||
| 137 | #m/alias\s+(\S+)\s+\"([^\"\<]+)\s+\<([^\>]+)\>\"/; | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 14735 | my ($cpanid, $authinfo) = m/alias\s+(\S+)\s+\"([^\"]+)\"/; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 14735 | ▶ | next unless $cpanid; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 14735 | my ($fullname, $email); | |||||||||||||||||||||||||||||||||||||||||
| 141 | 14735 | ▶ | if ($authinfo =~ m/([^<]+)\<(.*)\>/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 14735 | $fullname = $1; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 14735 | $email = $2; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $fullname = ''; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $email = lc($cpanid) . '@cpan.org'; | |||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 14735 | $auths->{$cpanid} = { | |||||||||||||||||||||||||||||||||||||||||
| 149 | fullname => trim($fullname), | ||||||||||||||||||||||||||||||||||||||||||
| 150 | email => trim($email) }; | ||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 4 | return $self->{auths} = $auths; | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | sub check_file { | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 8 | ▶ | my ($index, $file) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_file: called CC=3 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 8 | ▶ | unless ($file) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | warn qq{index file '$index' not defined}; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 8 | ▶ | unless (-f $file) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | warn qq{index file '$file' not found}; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 8 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | sub zcat { | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 8 | ▶ | my $file = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
zcat: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 8 | my ($buffer, $lines); | |||||||||||||||||||||||||||||||||||||||||
| 171 | 8 | ▶ | my $gz = gzopen($file, 'rb') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | or die "Cannot open $file: $gzerrno"; | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 8 | ▶ | while ($gz->gzreadline($buffer) > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 284087 | push @$lines, $buffer; | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 8 | ▶ | die "Error reading from $file: $gzerrno" . ($gzerrno + 0) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | if $gzerrno != Z_STREAM_END; | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 8 | $gz->gzclose(); | |||||||||||||||||||||||||||||||||||||||||
| 179 | 8 | return $lines; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | sub trim { | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 29470 | ▶ | my $string = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trim: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 29470 | ▶ | return '' unless $string; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 29470 | $string =~ s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 29470 | $string =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 29470 | $string =~ s/\s+/ /g; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 29470 | return $string; | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | CPAN::SQLite::Info - extract information from CPAN indices | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | version 0.218 | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | This module extracts information from the CPAN indices | ||||||||||||||||||||||||||||||||||||||||||
| 204 | F<$CPAN/modules/02packages.details.txt.gz> and | ||||||||||||||||||||||||||||||||||||||||||
| 205 | F<$CPAN/authors/01mailrc.txt.gz>. | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | A C<CPAN::SQLite::Info> object is created with | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | my $info = CPAN::SQLite::Info->new(CPAN => $cpan); | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | where C<$cpan> specifies the top-level CPAN directory | ||||||||||||||||||||||||||||||||||||||||||
| 212 | underneath which the index files are found. Calling | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | $info->fetch_info(); | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | will result in the object being populated with 3 hash references: | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | =over 3 | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | =item * C<$info-E<gt>{dists}> | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | This contains information on distributions. Keys of this hash | ||||||||||||||||||||||||||||||||||||||||||
| 223 | reference are the distribution names, with the associated value being a | ||||||||||||||||||||||||||||||||||||||||||
| 224 | hash reference with keys of | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | =over 3 | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | =item C<dist_vers> - the version of the CPAN file | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | =item C<dist_file> - the CPAN filename | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | =item C<cpanid> - the CPAN author id | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | =item C<dist_abs> - a description, if available | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | =item C<modules> - specifies the modules present in the distribution: | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | for my $module (keys %{$info->{$distname}->{modules}}) { | ||||||||||||||||||||||||||||||||||||||||||
| 239 | print "Module: $module\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | =item * C<$info-E<gt>{mods}> | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | This contains information on modules. Keys of this hash | ||||||||||||||||||||||||||||||||||||||||||
| 247 | reference are the module names, with the associated values being a | ||||||||||||||||||||||||||||||||||||||||||
| 248 | hash reference with keys of | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | =over 3 | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | =item C<dist_name> - the distribution name containing the module | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | =item C<mod_vers> - the version | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | =item C<mod_abs> - a description, if available | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | =item * C<$info-E<gt>{auths}> | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | This contains information on CPAN authors. Keys of this hash | ||||||||||||||||||||||||||||||||||||||||||
| 263 | reference are the CPAN ids, with the associated value being a | ||||||||||||||||||||||||||||||||||||||||||
| 264 | hash reference with keys of | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | =over 3 | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | =item C<fullname> - the author's full name | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | =item C<email> - the author's email address | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | L<CPAN::SQLite::Index> | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | =cut | ||||||||||||||||||||||||||||||||||||||||||