URI/irc.pm

filter: Statementstmt 68.4% 52 / 76 Branchbran 38.4% 10 / 26 Conditioncond 33.3% 2 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 75.0% 12 / 16 Podpod 62.5% 5 / 8 totaltotal 60.2% 82 / 136 CC 16 SCAR 20.3
CC
16
Cov
59%
path_query
20.0
entity
20.0
canonical
6.1
CRAP 7.6
« URI/geo.pm ↑ Summary URI/urn.pm »
1 package URI::irc; # draft-butcher-irc-url-04
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '5.40';
7  
8 2 ▶use parent 'URI::_login';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use overload (
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶ '""' => sub { $_[0]->as_string },
Subroutine __ANON__: called CC=1 SCAR=0.0
12 1 ▶ '==' => sub { URI::_obj_eq(@_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
13 0 ▶ '!=' => sub { !URI::_obj_eq(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
14 2 fallback => 1,
15 2 );
16  
17 2 ▶sub default_port {6667}
Subroutine default_port: called CC=1 SCAR=0.0
Pod documented
18  
19 # ircURL = ircURI "://" location "/" [ entity ] [ flags ] [ options ]
20 # ircURI = "irc" / "ircs"
21 # location = [ authinfo "@" ] hostport
22 # authinfo = [ username ] [ ":" password ]
23 # username = *( escaped / unreserved )
24 # password = *( escaped / unreserved ) [ ";" passtype ]
25 # passtype = *( escaped / unreserved )
26 # entity = [ "#" ] *( escaped / unreserved )
27 # flags = ( [ "," enttype ] [ "," hosttype ] )
28 # /= ( [ "," hosttype ] [ "," enttype ] )
29 # enttype = "," ( "isuser" / "ischannel" )
30 # hosttype = "," ( "isserver" / "isnetwork" )
31 # options = "?" option *( "&" option )
32 # option = optname [ "=" optvalue ]
33 # optname = *( ALPHA / "-" )
34 # optvalue = optparam *( "," optparam )
35 # optparam = *( escaped / unreserved )
36  
37 # XXX: Technically, passtype is part of the protocol, but is rarely used and
38 # not defined in the RFC beyond the URL ABNF.
39  
40 # Starting the entity with /# is okay per spec, but it needs to be encoded to
41 # %23 for the URL::_generic::path operations to parse correctly.
42 2 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
43 2 my $class = shift;
44 2 my $self = $class->SUPER::_init(@_);
45 2 $$self =~ s|^((?:[^:/?\#]+:)?(?://[^/?\#]*)?)/\#|$1/%23|s;
46 2 $self;
47 }
48  
49 # Return the /# form, since this is most common for channel names.
50 5 ▶sub path {
Subroutine path: called CC=4 SCAR=13.9
Pod documented
51 5 my $self = shift;
52 5 my ($new) = @_;
53 5 ▶ $new =~ s|^/\#|/%23| if (@_ && defined $new);
Branch: 1 branch
BranchTrueFalseTotal
if @_ and defined $new 2 3 5
Condition66%2/3
@_ and defined $new
!ll&&!rl&&r
302
MC/DC50%1/2
@_ and defined $new
@_ defined $new
Truth table66%2/3
A and B
A= @_B= defined $new
ABresult
0X0
100
111
54 5 ▶ my $val = $self->SUPER::path(@_ ? $new : ());
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 2 3 5
55 5 $val =~ s|^/%23|/\#|;
56 5 $val;
57 }
58  
59 0 ▶sub path_query {
Subroutine path_query: not called CC=4 SCAR=30.0
Pod documented
60 0 my $self = shift;
61 0 my ($new) = @_;
62 0 ▶ $new =~ s|^/\#|/%23| if (@_ && defined $new);
Branch: 1 branch
BranchTrueFalseTotal
if @_ and defined $new 0 0 0
Condition0%0/3
@_ and defined $new
!ll&&!rl&&r
000
MC/DC0%0/2
@_ and defined $new
@_ defined $new
Truth table0%0/3
A and B
A= @_B= defined $new
ABresult
0X0
100
111
63 0 ▶ my $val = $self->SUPER::path_query(@_ ? $new : ());
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
64 0 $val =~ s|^/%23|/\#|;
65 0 $val;
66 }
67  
68 2 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
69 2 my $self = shift;
70 2 my $val = $self->SUPER::as_string;
71 2 $val =~ s|^((?:[^:/?\#]+:)?(?://[^/?\#]*)?)/%23|$1/\#|s;
72 2 $val;
73 }
74  
75 0 ▶sub entity {
Subroutine entity: not called CC=4 SCAR=30.0
Pod undocumented
76 0 my $self = shift;
77  
78 0 my $path = $self->path;
79 0 $path =~ s|^/||;
80 0 my ($entity, @flags) = split /,/, $path;
81  
82 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
83 0 my $new = shift;
84 0 ▶ $new = '' unless defined $new;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $new 0 0 0
85 0 $self->path('/' . join(',', $new, @flags));
86 }
87  
88 0 ▶ return unless length $entity;
Branch: 1 branch
BranchTrueFalseTotal
unless length $entity 0 0 0
89 0 $entity;
90 }
91  
92 0 ▶sub flags {
Subroutine flags: not called CC=2 SCAR=17.9
Pod undocumented
93 0 my $self = shift;
94  
95 0 my $path = $self->path;
96 0 $path =~ s|^/||;
97 0 my ($entity, @flags) = split /,/, $path;
98  
99 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
100 0 $self->path('/' . join(',', $entity, @_));
101 }
102  
103 0 @flags;
104 }
105  
106 2 ▶sub options { shift->query_form(@_) }
Subroutine options: called CC=1 SCAR=0.0
Pod undocumented
107  
108 1 ▶sub canonical {
Subroutine canonical: called CC=6 SCAR=18.1
Pod documented
109 1 my $self = shift;
110 1 my $other = $self->SUPER::canonical;
111  
112 # Clean up the flags
113 1 my $path = $other->path;
114 1 $path =~ s|^/||;
115 1 my ($entity, @flags) = split /,/, $path;
116  
117 5 ▶ my @clean = map { $_ eq 'isnick' ? 'isuser' : $_ } # convert isnick->isuser
Branch: 1 branch
BranchTrueFalseTotal
$_ eq 'isnick' ? : 1 4 5
118 5 map {lc}
119  
120 # NOTE: Allow flags from draft-mirashi-url-irc-01 as well
121 1 grep {/^(?:is(?:user|channel|server|network|nick)|need(?:pass|key))$/i}
122 @flags;
123  
124 # Only allow the first type of each category, per the Butcher draft
125 1 my ($enttype) = grep {/^is(?:user|channel)$/} @clean;
126 1 my ($hosttype) = grep {/^is(?:server|network)$/} @clean;
127 1 my @others = grep {/^need(?:pass|key)$/} @clean;
128  
129 1 ▶ my @new = ($enttype ? $enttype : (), $hosttype ? $hosttype : (), @others,);
Branch: 2 branches
BranchTrueFalseTotal
$enttype ? : 1 0 1
$hosttype ? : 1 0 1
130  
131 1 ▶ unless (join(',', @new) eq join(',', @flags)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (join(",", @new) eq join(",", @flags)) 1 0 1
132 1 ▶ $other = $other->clone if $other == $self;
Branch: 1 branch
BranchTrueFalseTotal
if $other == $self 1 0 1
133 1 $other->path('/' . join(',', $entity, @new));
134 }
135  
136 1 $other;
137 }
138  
139 2 1;
« URI/geo.pm ↑ Summary URI/urn.pm »