ActionPack/Util.pm

filter: Statementstmt 100% 41 / 41 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 40.0% 2 / 5 totaltotal 95.3% 61 / 64 CC 4 SCAR 4.3
CC
4
Cov
100%
join_header_params
3.0
join_header_words
2.0
BEGIN
1.0
CRAP 1.5
« ActionPack/Core/BaseHeaderList.pm ↑ Summary ActionPack/Authorization.pm »
1 package HTTP::Headers::ActionPack::Util;
2 22 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 22 $HTTP::Headers::ActionPack::Util::AUTHORITY = 'cpan:STEVAN';
4 }
5 {
6 22 $HTTP::Headers::ActionPack::Util::VERSION = '0.09';
7 }
8 # ABSTRACT: General Utility module
9  
10 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 22 ▶use Time::Piece;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 22 ▶use HTTP::Date qw[ str2time time2str ];
Subroutine BEGIN: called CC=1 SCAR=0.0
15 22 ▶use HTTP::Headers::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 22 ▶use Sub::Exporter -setup => {
Subroutine BEGIN: called CC=1 SCAR=0.0
18 exports => [qw[
19 header_to_date
20 date_to_header
21 split_header_words
22 join_header_words
23 join_header_params
24 ]]
25 22 };
26  
27 8 ▶sub header_to_date { scalar Time::Piece->gmtime( str2time( shift ) ) }
Subroutine header_to_date: called CC=1 SCAR=0.0
Pod undocumented
28 15 ▶sub date_to_header { time2str( shift->epoch ) }
Subroutine date_to_header: called CC=1 SCAR=0.0
Pod undocumented
29  
30 141 ▶sub split_header_words {
Subroutine split_header_words: called CC=1 SCAR=0.0
Pod documented
31 141 my $header = shift;
32 map {
33 141 splice @$_, 1, 1;
34 229 $_;
35 } HTTP::Headers::Util::_split_header_words( $header );
36 }
37  
38 294 ▶sub join_header_words {
Subroutine join_header_words: called CC=2 SCAR=6.9
Pod documented
39 294 my ($subject, @params) = @_;
40 294 ▶ return $subject . '; ' . join_header_params( '; ' => @params ) if @params;
Branch: 1 branch
BranchTrueFalseTotal
if @params 164 130 294
41 130 return $subject;
42 }
43  
44 178 ▶sub join_header_params {
Subroutine join_header_params: called CC=3 SCAR=11.0
Pod undocumented
45 178 my ($separator, @params) = @_;
46 178 my @attrs;
47 178 ▶ while ( @params ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@params) 276 178 454
48 276 my $k = shift @params;
49 276 my $v = shift @params;
50  
51 276 ▶ if (defined $v) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $v) { } 275 1 276
52 275 $v =~ s/([\"\\])/\\$1/g; # escape " and \
53 }
54 else {
55 1 $v = q{};
56 }
57 276 push @attrs => ($k . qq(="$v"));
58 }
59 178 return join $separator => @attrs;
60 }
61  
62 22 1;
63  
64 __END__
« ActionPack/Core/BaseHeaderList.pm ↑ Summary ActionPack/Authorization.pm »