blib/lib/Punk/Plugin/RequestId.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 12 / 12 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 96.4% 55 / 57 CC 8 SCAR 16.1
CC
8
Cov
98%
register
8.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.0
« blib/lib/Punk/Upload.pm ↑ Summary blib/lib/Punk/Test/WS/Conn.pm »
1 package Punk::Plugin::RequestId;
2  
3 5 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use parent 'Punk::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Punk ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 5 our $VERSION = '0.69';
11  
12 # The id path itself is C - include/punk/punk_reqid.h and xs/reqid.xs.
13  
14 18 ▶sub register {
Subroutine register: called CC=8 SCAR=20.8
Pod documented
15 18 my ($self, $app, $opts) = @_;
16 18 ▶ $opts ||= {};
Condition50%1/2
$opts ||= {}
l!l
180
MC/DC0%0/1
$opts ||= {}
$opts
Truth table50%1/2
A
A= $opts
Aresult
11
00
17  
18 18 ▶ my $header = exists $opts->{header} ? $opts->{header} : 'X-Request-Id';
Branch: 1 branch
BranchTrueFalseTotal
exists $opts->{'header'} ? : 7 11 18
19 18 ▶ $header = undef unless $header;
Branch: 1 branch
BranchTrueFalseTotal
unless $header 3 15 18
20 18 ▶ if (defined $header) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $header) 15 3 18
21 15 ▶ Carp::croak("Punk::Plugin::RequestId: header '$header' is not a "
Branch: 1 branch
BranchTrueFalseTotal
if $header =~ /[^A-Za-z0-9_-]/ 1 14 15
22 . 'usable header name')
23 if $header =~ /[^A-Za-z0-9_-]/;
24 }
25  
26 17 my $envkey;
27 17 ▶ if ($opts->{trust_header}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"trust_header"}) 5 12 17
28 my $from = defined $header ? $header
29 5 ▶ : do {
Branch: 1 branch
BranchTrueFalseTotal
defined $header ? : 3 2 5
30 2 Carp::croak('Punk::Plugin::RequestId: trust_header needs '
31 . 'a header to read; it cannot be used with '
32 . 'header => 0');
33 };
34 3 ($envkey = uc $from) =~ tr/-/_/;
35 3 $envkey = "HTTP_$envkey";
36 }
37  
38 15 __PACKAGE__->_enable($app, $header, $envkey);
39  
40 15 $app->helper(request_id => \&_id);
41  
42 15 return;
43 }
44  
45 5 1;
46  
47 __END__
« blib/lib/Punk/Upload.pm ↑ Summary blib/lib/Punk/Test/WS/Conn.pm »