| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 1 |  |  | 1 |  | 7 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 34 |  | 
| 2 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 55 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | package URI::cpan::distfile 1.008; | 
| 5 |  |  |  |  |  |  | # ABSTRACT: cpan:///distfile/AUTHOR/Dist-1.234.tar.gz | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 1 |  |  | 1 |  | 7 | use parent qw(URI::cpan); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 5 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 1 |  |  | 1 |  | 65 | use Carp (); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 17 |  | 
| 10 | 1 |  |  | 1 |  | 472 | use CPAN::DistnameInfo; | 
|  | 1 |  |  |  |  | 1030 |  | 
|  | 1 |  |  |  |  | 315 |  | 
| 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 |  |  | 3 | 0 | 7 | my ($self) = @_; | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 3 |  |  |  |  | 9 | my (undef, undef, $author, $filename) = split m{/}, $self->path, 4; | 
| 25 |  |  |  |  |  |  |  | 
| 26 | 3 | 50 |  |  |  | 92 | Carp::croak "invalid cpan URI: invalid author part in $self" | 
| 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 or F. | 
| 33 |  |  |  |  |  |  | #pod | 
| 34 |  |  |  |  |  |  | #pod =cut | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | sub dist_name { | 
| 37 | 3 |  |  | 3 | 0 | 6 | my ($self) = @_; | 
| 38 | 3 |  |  |  |  | 10 | my $dist = CPAN::DistnameInfo->new($self->_p_rel); | 
| 39 | 3 |  |  |  |  | 233 | my $name = $dist->dist; | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 3 | 100 |  |  |  | 16 | $name =~ s/-undef$// if ! defined $dist->version; | 
| 42 |  |  |  |  |  |  |  | 
| 43 | 3 |  |  |  |  | 35 | 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 |  |  | 3 | 0 | 7 | my ($self) = @_; | 
| 55 | 3 |  |  |  |  | 10 | 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 part. | 
| 62 |  |  |  |  |  |  | #pod | 
| 63 |  |  |  |  |  |  | #pod =cut | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | sub dist_filepath { | 
| 66 | 1 |  |  | 1 | 0 | 599 | my ($self) = @_; | 
| 67 | 1 |  |  |  |  | 4 | $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 |  |  | 3 | 0 | 1233 | my ($self) = @_; | 
| 78 | 3 |  |  |  |  | 11 | my ($author) = $self->_p_rel =~ m{^([A-Z]+)/}; | 
| 79 | 3 |  |  |  |  | 13 | return $author; | 
| 80 |  |  |  |  |  |  | } | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | 1; | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | __END__ |