ActionPack/Util.pm

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