cpan/distfile.pm

filter: Statementstmt 100% 31 / 31 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 5 totaltotal 88.0% 44 / 50 CC 3 SCAR 2.9
CC
3
Cov
97%
validate
2.0
dist_name
2.0
BEGIN
1.0
CRAP 1.3
« cpan.pm ↑ Summary cpan/dist.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package URI::cpan::distfile 1.008;
5 # ABSTRACT: cpan:///distfile/AUTHOR/Dist-1.234.tar.gz
6  
7 1 ▶use parent qw(URI::cpan);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use CPAN::DistnameInfo;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 #pod =head1 SYNOPSIS
13 #pod
14 #pod This URL refers to a file in an author directory on the CPAN, and expects the
15 #pod format AUTHOR/DISTFILE
16 #pod
17 #pod =head1 METHODS
18 #pod
19 #pod =cut
20  
21 sub validate {
22 3 ▶ my ($self) = @_;
Subroutine validate: called CC=2 SCAR=7.1
Pod undocumented
23  
24 3 my (undef, undef, $author, $filename) = split m{/}, $self->path, 4;
25  
26 3 ▶ Carp::croak "invalid cpan URI: invalid author part in $self"
Branch: 1 branch
BranchTrueFalseTotal
unless $author =~ /\A[A-Z][-0-9A-Z]*\z/ 0 3 3
27 unless $author =~ m{\A[A-Z][-0-9A-Z]*\z};
28 }
29  
30 #pod =head1 dist_name
31 #pod
32 #pod This returns the name of the dist, like F<CGI.pm> or F<Acme-Drunk>.
33 #pod
34 #pod =cut
35  
36 sub dist_name {
37 3 ▶ my ($self) = @_;
Subroutine dist_name: called CC=2 SCAR=6.9
Pod undocumented
38 3 my $dist = CPAN::DistnameInfo->new($self->_p_rel);
39 3 my $name = $dist->dist;
40  
41 3 ▶ $name =~ s/-undef$// if ! defined $dist->version;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dist->version 1 2 3
42  
43 3 return $name;
44 }
45  
46 #pod =head1 dist_version
47 #pod
48 #pod This returns the version of the dist, or undef if the version can't be found or
49 #pod is the string "undef"
50 #pod
51 #pod =cut
52  
53 sub dist_version {
54 3 ▶ my ($self) = @_;
Subroutine dist_version: called CC=1 SCAR=0.0
Pod undocumented
55 3 CPAN::DistnameInfo->new($self->_p_rel)->version;
56 }
57  
58 #pod =head1 dist_filepath
59 #pod
60 #pod This returns the path to the dist file. This is the whole URL after the
61 #pod C<distfile> part.
62 #pod
63 #pod =cut
64  
65 sub dist_filepath {
66 1 ▶ my ($self) = @_;
Subroutine dist_filepath: called CC=1 SCAR=0.0
Pod undocumented
67 1 $self->_p_rel;
68 }
69  
70 #pod =head1 author
71 #pod
72 #pod This returns the name of the author whose file is referred to.
73 #pod
74 #pod =cut
75  
76 sub author {
77 3 ▶ my ($self) = @_;
Subroutine author: called CC=1 SCAR=0.0
Pod undocumented
78 3 my ($author) = $self->_p_rel =~ m{^([A-Z]+)/};
79 3 return $author;
80 }
81  
82 1 1;
83  
84 __END__
« cpan.pm ↑ Summary cpan/dist.pm »