blib/lib/CPAN/Mini/LatestDistVersion.pm

filter: Statementstmt 36.1% 17 / 47 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 50.0% 5 / 10 Podpod 100% 2 / 2 totaltotal 28.9% 24 / 83 CC 11 SCAR 27.7
CC
11
Cov
25%
_get_latest_dists
30.0
new
20.0
_filter_latest
20.0
CRAP 15.9
↑ Summary
1 package CPAN::Mini::LatestDistVersion;
2  
3 1 ▶use base 'CPAN::Mini';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Parse::CPAN::Packages::Fast;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use CPAN::DistnameInfo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our $VERSION = '0.01';
12  
13 0 ▶sub new {
Subroutine new: not called CC=4 SCAR=30.0
Pod documented
14 0 my $class = shift;
15 0 my $self = $class->SUPER::new( @_ );
16  
17 0 ▶ if( !$self->{ path_filters } ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $self->{'path_filters'}) { } 0 0 0
elsif ($self->{'path_filters'} and ref $self->{'path_filters'} ne 'ARRAY') { } 0 0 0
18 0 $self->{ path_filters } = [];
19 }
20 ▶ elsif( $self->{ path_filters } && ref( $self->{ path_filters } ) ne 'ARRAY') {
Condition0%0/3
$self->{"path_filters"} and ref $self->{"path_filters"} ne "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"path_filters"} and ref $self->{"path_filters"} ne "ARRAY"
$self->{"path_filters"} ref $self->{"path_filters"} ne "ARRAY"
Truth table0%0/3
A and B
A= $self->{"path_filters"}B= ref $self->{"path_filters"} ne "ARRAY"
ABresult
0X0
100
111
21 0 $self->{ path_filters } = [ $self->{ path_filters } ];
22 }
23  
24 0 ▶ push @{ $self->{ path_filters } }, sub { _filter_latest( $self, @_ ) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
25  
26 0 return $self;
27 }
28  
29 0 ▶sub mirror_indices {
Subroutine mirror_indices: not called CC=1 SCAR=6.9
Pod documented
30 0 my $self = shift;
31 0 $self->SUPER::mirror_indices( @_ );
32  
33 0 my $packages = Parse::CPAN::Packages::Fast->new( $self->_scratch_dir . '/modules/02packages.details.txt.gz' );
34 0 $self->{ _latest_dists } = _get_latest_dists( $packages );
35 }
36  
37 0 ▶sub _filter_latest {
Subroutine _filter_latest: not called CC=4 SCAR=30.0
38 0 my ( $self, $file ) = @_;
39 0 my $dist = CPAN::DistnameInfo->new( $file );
40  
41 0 ▶ return 1 if !$dist || !$dist->distvname; # Skip problem dists, if any
Branch: 1 branch
BranchTrueFalseTotal
unless $dist and $dist->distvname 0 0 0
Condition0%0/3
$dist and $dist->distvname
!ll&&!rl&&r
000
MC/DC0%0/2
$dist and $dist->distvname
$dist $dist->distvname
Truth table0%0/3
A and B
A= $distB= $dist->distvname
ABresult
0X0
100
111
42 0 ▶ return 0 if $dist->distvname eq $self->{ _latest_dists }->{ $dist->dist }->distvname;
Branch: 1 branch
BranchTrueFalseTotal
if $dist->distvname eq $self->{"_latest_dists"}{$dist->dist}->distvname 0 0 0
43 0 return 1;
44 }
45  
46 # Slightly modified from Parse::CPAN::Packages::Fast
47 0 ▶sub _get_latest_dists {
Subroutine _get_latest_dists: not called CC=5 SCAR=34.0
48 0 my $self = shift;
49  
50 0 my %latest_dist;
51  
52 0 for my $pathname ( keys %{ $self->{ dist_to_pkgs } } ) {
53 0 my $d = Parse::CPAN::Packages::Fast::Distribution->new( $pathname, $self );
54 0 my $dist = $d->dist;
55 0 ▶ next if !defined $dist;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dist 0 0 0
56 0 ▶ if ( !exists $latest_dist{ $dist } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $latest_dist{$dist}) { } 0 0 0
57 0 $latest_dist{ $dist } = $d;
58 }
59 else {
60 0 ▶ if ( CPAN::Version->vlt( $latest_dist{ $dist }->version, $d->version ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("CPAN::Version"->vlt($latest_dist{$dist}->version, $d->version)) 0 0 0
61 0 $latest_dist{ $dist } = $d;
62 }
63 }
64 }
65  
66 0 return \%latest_dist;
67 }
68  
69 1 1;
70  
71 __END__
↑ Summary