ActionPack/LinkHeader.pm

filter: Statementstmt 100% 47 / 47 Branchbran 80.0% 8 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 66.6% 4 / 6 totaltotal 94.6% 71 / 75 CC 8 SCAR 9.2
CC
8
Cov
96%
relation_matches
5.1
as_string
3.0
BUILD
2.0
CRAP 2.5
« ActionPack/AcceptCharset.pm ↑ Summary ActionPack/Core/Base.pm »
1 package HTTP::Headers::ActionPack::LinkHeader;
2 8 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 8 $HTTP::Headers::ActionPack::LinkHeader::AUTHORITY = 'cpan:STEVAN';
4 }
5 {
6 8 $HTTP::Headers::ActionPack::LinkHeader::VERSION = '0.09';
7 }
8 # ABSTRACT: A Link
9  
10 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 8 ▶use URI::Escape qw[ uri_escape uri_unescape ];
Subroutine BEGIN: called CC=1 SCAR=0.0
14 8 ▶use HTTP::Headers::ActionPack::Util qw[ join_header_words ];
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 8 ▶use parent 'HTTP::Headers::ActionPack::Core::BaseHeaderType';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 28 ▶sub BUILDARGS {
Subroutine BUILDARGS: called CC=1 SCAR=0.0
Pod documented
19 28 my $class = shift;
20 28 my ($href, @params) = @_;
21  
22 28 $href =~ s/^<//;
23 28 $href =~ s/>$//;
24  
25 28 $class->SUPER::BUILDARGS( $href, @params );
26 }
27  
28 28 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=6.9
Pod documented
29 28 my $self = shift;
30 28 foreach my $param ( grep { /\*$/ } @{ $self->_param_order } ) {
31 2 my ($encoding, $language, $content) = ( $self->params->{ $param } =~ /^(.*)\'(.*)\'(.*)$/);
32 2 $self->params->{ $param } = {
33 encoding => $encoding,
34 language => $language,
35 content => uri_unescape( $content )
36 };
37 }
38 }
39  
40 40 ▶sub href { (shift)->subject }
Subroutine href: called CC=1 SCAR=0.0
Pod documented
41 6 ▶sub rel { (shift)->params->{'rel'} }
Subroutine rel: called CC=1 SCAR=0.0
Pod undocumented
42  
43 11 ▶sub relation_matches {
Subroutine relation_matches: called CC=5 SCAR=16.3
Pod undocumented
44 11 my ($self, $relation) = @_;
45  
46 11 ▶ if ( my $rel = $self->params->{'rel'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $rel = $self->params->{"rel"}) 11 0 11
47 # if it is an extension rel type
48 # then it is a URI and it should
49 # not be compared in a case-insensitive
50 # manner ...
51 11 ▶ if ( $rel =~ m!^\w+\://! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rel =~ m[^\w+\://]) { } 2 9 11
52 2 ▶ $self->params->{'rel'} eq $relation ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->params->{'rel'} eq $relation ? : 1 1 2
53 }
54 # if it is not a URI, then compare
55 # it case-insensitively
56 else {
57 9 ▶ (lc $self->params->{'rel'} ) eq (lc $relation) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
lc $self->params->{'rel'} eq lc $relation ? : 9 0 9
58 }
59 }
60 }
61  
62 34 ▶sub as_string {
Subroutine as_string: called CC=3 SCAR=11.0
Pod documented
63 34 my $self = shift;
64  
65 34 my @params;
66 34 foreach my $param ( @{ $self->_param_order } ) {
67 52 ▶ if ( $param =~ /\*$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($param =~ /\*$/) { } 2 50 52
68 2 my $complex = $self->params->{ $param };
69 push @params => ( $param,
70 join "'" => (
71 $complex->{'encoding'},
72 $complex->{'language'},
73 2 uri_escape( $complex->{'content'} ),
74 )
75 );
76 }
77 else {
78 50 push @params => ( $param, $self->params->{ $param } );
79 }
80 52 my ($encoding, $language, $content) = ( $self->params->{ $param } =~ /^(.*)\'(.*)\'(.*)$/);
81 }
82  
83 34 join_header_words( '<' . $self->href . '>', @params );
84 }
85  
86 8 1;
87  
88 __END__
« ActionPack/AcceptCharset.pm ↑ Summary ActionPack/Core/Base.pm »