cpan.pm

filter: Statementstmt 100% 46 / 46 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod n/a totaltotal 95.3% 61 / 64 CC 4 SCAR 6.0
CC
4
Cov
94%
_init
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.8
« cpan/author.pm ↑ Summary cpan/distfile.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 1.008;
5 # ABSTRACT: URLs that refer to things on the CPAN
6  
7 1 ▶use parent qw(URI::_generic);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 #pod =head1 SYNOPSIS
10 #pod
11 #pod use URI::cpan;
12 #pod
13 #pod my $uri = URI->new('cpan:///distfile/RJBS/URI-cpan-1.000.tar.gz');
14 #pod
15 #pod $uri->author; # => RJBS
16 #pod $uri->dist_name; # => URI-cpan
17 #pod $uri->dist_version; # => 1.000
18 #pod
19 #pod Other forms of cpan: URI include:
20 #pod
21 #pod cpan:///author/RJBS
22 #pod
23 #pod Reserved for likely future use are:
24 #pod
25 #pod cpan:///dist
26 #pod cpan:///module
27 #pod cpan:///package
28 #pod
29 #pod =cut
30  
31 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
32 1 ▶use URI::cpan::author;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 1 ▶use URI::cpan::dist;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶use URI::cpan::distfile;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 1 ▶use URI::cpan::module;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 1 ▶use URI::cpan::package;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 1 ▶use URI::cpan::dist;
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 1 my %type_class = (
40 author => 'URI::cpan::author',
41 distfile => 'URI::cpan::distfile',
42  
43 # These will be uncommented when we figure out what the heck to do with them.
44 # -- rjbs, 2009-03-30
45 #
46 # dist => 'URI::cpan::dist',
47 # package => 'URI::cpan::package',
48 # module => 'URI::cpan::module',
49 );
50  
51 sub _init {
52 4 ▶ my $self = shift->SUPER::_init(@_);
Subroutine _init: called CC=4 SCAR=14.1
53 4 my $class = ref($self);
54  
55 4 ▶ Carp::croak "invalid cpan URI: non-empty query string not supported"
Branch: 1 branch
BranchTrueFalseTotal
if $self->query 0 4 4
56 if $self->query;
57  
58 4 ▶ Carp::croak "invalid cpan URI: non-empty fragment string not supported"
Branch: 1 branch
BranchTrueFalseTotal
if $self->fragment 0 4 4
59 if $self->fragment;
60  
61 4 my (undef, @path_parts) = split m{/}, $self->path;
62 4 my $type = $path_parts[0];
63  
64 Carp::croak "invalid cpan URI: do not understand path " . $self->path
65 4 ▶ unless my $new_class = $type_class{ $type };
Branch: 1 branch
BranchTrueFalseTotal
unless my $new_class = $type_class{$type} 0 4 4
66  
67 4 bless $self => $new_class;
68  
69 4 $self->validate;
70  
71 4 return $self;
72 }
73  
74 sub _p_rel {
75 12 ▶ my ($self) = @_;
Subroutine _p_rel: called CC=1 SCAR=0.0
76 12 my $path = $self->path;
77 12 $path =~ s{^/\w+/}{};
78 12 return $path;
79 }
80  
81 #pod =head1 WARNINGS
82 #pod
83 #pod URI objects are difficult to subclass, so I have not (yet?) taken the time to
84 #pod remove mutability from the objects. This means that you can probably alter a
85 #pod URI::cpan object into a state where it is no longer valid.
86 #pod
87 #pod Please don't change the contents of these objects after construction.
88 #pod
89 #pod =head1 SEE ALSO
90 #pod
91 #pod L<URI::cpan::author> and L<URI::cpan::distfile>
92 #pod
93 #pod =head1 THANKS
94 #pod
95 #pod This code is derived from code written at Pobox.com by Hans Dieter Pearcey.
96 #pod Dieter helped thrash out this new implementation, too.
97 #pod
98 #pod =cut
99  
100 1 1;
101  
102 __END__
« cpan/author.pm ↑ Summary cpan/distfile.pm »