blib/lib/CPAN/DistnameInfo.pm

filter: Statementstmt 100% 52 / 52 Branchbran 87.5% 28 / 32 Conditioncond 75.0% 18 / 24 MC/DCmcdc 53.8% 7 / 13 Subroutinesub 100% 12 / 12 Podpod 81.8% 9 / 11 totaltotal 87.5% 126 / 144 CC 25 SCAR 26.9
CC
25
Cov
91%
distname_info
22.8
new
4.0
BEGIN
1.0
CRAP 14.7
↑ Summary
1  
2 package CPAN::DistnameInfo;
3  
4 2 $VERSION = "0.12_01";
5 2 $VERSION =~ tr/_//d;
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 593 ▶sub distname_info {
Subroutine distname_info: called CC=22 SCAR=31.3
Pod undocumented
9 593 ▶ my $file = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $file = shift() or return 593 0 593
10  
11 593 ▶ return ($file, undef, undef) if $file =~ /\P{ASCII}/;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ /\P{ASCII}/ 1 592 593
12  
13 592 ▶ my ($dist, $version) = $file =~ /^
Branch: 1 branch
BranchTrueFalseTotal
() = $file =~ /^ ((?:[-+.]*(?:[A-Za-z0-9]+|(?<=\D)_|_(?=\D))* (?: [A-Za-z](?=[^A-Za-z]|$) | \d(?=-) )(?<![._-][vV]) )+)(.*) $/sx or return $file, undef, undef 592 0 592
14 ((?:[-+.]*(?:[A-Za-z0-9]+|(?<=\D)_|_(?=\D))*
15 (?:
16 [A-Za-z](?=[^A-Za-z]|$)
17 |
18 \d(?=-)
19 )(?<![._-][vV])
20 )+)(.*)
21 $/xs or return ($file,undef,undef);
22  
23 592 ▶ if ($dist =~ /-undef\z/ and ! length $version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dist =~ /-undef\z/ and not length $version) 1 591 592
Condition100%3/3
$dist =~ /-undef\z/ and not length $version
!ll&&!rl&&r
59011
MC/DC100%2/2
$dist =~ /-undef\z/ and not length $version
$dist =~ /-undef\z/ not length $version
Truth table100%3/3
A and not(B)
A= $dist =~ /-undef\z/B= not length $version
ABresult
0X0
100
111
24 1 $dist =~ s/-undef\z//;
25 }
26  
27 # Remove potential -withoutworldwriteables suffix
28 592 $version =~ s/-withoutworldwriteables$//;
29  
30 592 ▶ if ($version =~ /^(-[Vv].*)-(\d.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version =~ /^(-[Vv].*)-(\d.*)/) 1 591 592
31 # Catch names like Unicode-Collate-Standard-V3_1_1-0.1
32 # where the V3_1_1 is part of the distname
33 1 $dist .= $1;
34 1 $version = $2;
35 }
36  
37 592 ▶ if ($version =~ /(.+_.*)-(\d.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version =~ /(.+_.*)-(\d.*)/) 1 591 592
38 # Catch names like Task-Deprecations5_14-1.00.tar.gz where the 5_14 is
39 # part of the distname. However, names like libao-perl_0.03-1.tar.gz
40 # should still have 0.03-1 as their version.
41 1 $dist .= $1;
42 1 $version = $2;
43 }
44  
45 # Normalize the Dist.pm-1.23 convention which CGI.pm and
46 # a few others use.
47 592 $dist =~ s{\.pm$}{};
48  
49 592 ▶ $version = $1
Branch: 1 branch
BranchTrueFalseTotal
if not length $version and $dist =~ s/-(\d+\w)$// 0 592 592
Condition66%2/3
not length $version and $dist =~ s/-(\d+\w)$//
!ll&&!rl&&r
563290
MC/DC0%0/2
not length $version and $dist =~ s/-(\d+\w)$//
not length $version $dist =~ s/-(\d+\w)$//
Truth table66%2/3
not(A) and B
A= not length $versionB= $dist =~ s/-(\d+\w)$//
ABresult
0X0
100
111
50 if !length $version and $dist =~ s/-(\d+\w)$//;
51  
52 592 ▶ $version = $1 . $version
Branch: 1 branch
BranchTrueFalseTotal
if $version =~ /^\d+$/ and $dist =~ s/-(\w+)$// 11 581 592
Condition100%3/3
$version =~ /^\d+$/ and $dist =~ s/-(\w+)$//
!ll&&!rl&&r
577411
MC/DC100%2/2
$version =~ /^\d+$/ and $dist =~ s/-(\w+)$//
$version =~ /^\d+$/ $dist =~ s/-(\w+)$//
Truth table100%3/3
A and B
A= $version =~ /^\d+$/B= $dist =~ s/-(\w+)$//
ABresult
0X0
100
111
53 if $version =~ /^\d+$/ and $dist =~ s/-(\w+)$//;
54  
55 592 ▶ if ($version =~ /\d\.\d/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version =~ /\d\.\d/) { } 492 100 592
56 492 $version =~ s/^[-_.]+//;
57 }
58 else {
59 100 $version =~ s/^[-_]+//;
60 }
61  
62 592 my $dev;
63 592 ▶ if (length $version) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $version) { } 563 29 592
64 563 ▶ if ($file =~ /^perl-?\d+\.(\d+)(?:\D(\d+))?(-(?:TRIAL|RC)\d+)?$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($file =~ /^perl-?\d+\.(\d+)(?:\D(\d+))?(-(?:TRIAL|RC)\d+)?$/) { } 5 558 563
elsif ($version =~ /\d\D\d+_\d/ or $version =~ s/-TRIAL[0-9]*$//) { } 8 550 558
65 5 ▶ $dev = 1 if (($1 > 6 and $1 & 1) or ($2 and $2 >= 50)) or $3;
Branch: 1 branch
BranchTrueFalseTotal
if $1 > 6 and $1 & 1 or $2 and $2 >= 50 or $3 3 2 5
Condition58%7/12
$1 > 6 and $1 & 1 or $2 and $2 >= 50 or $3
l!l&&r!l&&!r
032
$1 > 6 and $1 & 1 or $2 and $2 >= 50
l!l&&r!l&&!r
005
$1 > 6 and $1 & 1
!ll&&!rl&&r
320
$2 and $2 >= 50
!ll&&!rl&&r
140
MC/DC20%1/5
$1 > 6 and $1 & 1 or $2 and $2 >= 50 or $3
$1 > 6 $1 & 1 $2 $2 >= 50 $3
Truth table36%4/11
A and B or C and D or E
A= $1 > 6B= $1 & 1C= $2D= $2 >= 50E= $3
ABCDEresult
11XXX1
0X11X1
1011X1
0X0X11
0X1011
100X11
101011
0X0X00
0X1000
100X00
101000
66 }
67 ▶ elsif ($version =~ /\d\D\d+_\d/ or $version =~ s/-TRIAL[0-9]*$//) {
Condition100%3/3
$version =~ /\d\D\d+_\d/ or $version =~ s/-TRIAL[0-9]*$//
l!l&&r!l&&!r
53550
MC/DC100%2/2
$version =~ /\d\D\d+_\d/ or $version =~ s/-TRIAL[0-9]*$//
$version =~ /\d\D\d+_\d/ $version =~ s/-TRIAL[0-9]*$//
Truth table100%3/3
A or B
A= $version =~ /\d\D\d+_\d/B= $version =~ s/-TRIAL[0-9]*$//
ABresult
1X1
011
000
68 8 $dev = 1;
69 }
70 }
71 else {
72 29 $version = undef;
73 }
74  
75 592 ($dist, $version, $dev);
76 }
77  
78 593 ▶sub new {
Subroutine new: called CC=4 SCAR=13.9
Pod undocumented
79 593 my $class = shift;
80 593 my $distfile = shift;
81  
82 593 $distfile =~ s,//+,/,g;
83  
84 593 my %info = ( pathname => $distfile );
85  
86 ($info{filename} = $distfile) =~ s,^(((.*?/)?authors/)?id/)?([A-Z])/(\4[A-Z])/(\5[-A-Z0-9]*)/,,
87 593 ▶ and $info{cpanid} = $6;
Branch: 1 branch
BranchTrueFalseTotal
($info{"filename"} = $distfile) =~ s[^(((.*?/)?authors/)?id/)?([A-Z])/(\4[A-Z])/(\5[-A-Z0-9]*)/][] and $info{"cpanid"} = $6 29 564 593
88  
89 593 ▶ if ($distfile =~ m,([^/]+)\.(tar\.(?:g?z|bz2|xz)|zip|tgz)$,i) { # support more ?
Branch: 1 branch
BranchTrueFalseTotal
if ($distfile =~ m[([^/]+)\.(tar\.(?:g?z|bz2|xz)|zip|tgz)$]i) 593 0 593
90 593 $info{distvname} = $1;
91 593 $info{extension} = $2;
92 }
93  
94 593 @info{qw(dist version beta)} = distname_info($info{distvname});
95 593 ▶ $info{maturity} = delete $info{beta} ? 'developer' : 'released';
Branch: 1 branch
BranchTrueFalseTotal
delete $info{'beta'} ? : 11 582 593
96  
97 593 return bless \%info, $class;
98 }
99  
100 593 ▶sub dist { shift->{dist} }
Subroutine dist: called CC=1 SCAR=0.0
Pod documented
101 593 ▶sub version { shift->{version} }
Subroutine version: called CC=1 SCAR=0.0
Pod documented
102 593 ▶sub maturity { shift->{maturity} }
Subroutine maturity: called CC=1 SCAR=0.0
Pod documented
103 30 ▶sub filename { shift->{filename} }
Subroutine filename: called CC=1 SCAR=0.0
Pod documented
104 29 ▶sub cpanid { shift->{cpanid} }
Subroutine cpanid: called CC=1 SCAR=0.0
Pod documented
105 30 ▶sub distvname { shift->{distvname} }
Subroutine distvname: called CC=1 SCAR=0.0
Pod documented
106 30 ▶sub extension { shift->{extension} }
Subroutine extension: called CC=1 SCAR=0.0
Pod documented
107 30 ▶sub pathname { shift->{pathname} }
Subroutine pathname: called CC=1 SCAR=0.0
Pod documented
108  
109 30 ▶sub properties { %{ $_[0] } }
Subroutine properties: called CC=1 SCAR=0.0
Pod documented
110  
111 2 1;
112  
113 __END__
↑ Summary