blib/lib/Punk/Plugin/RequestId.pm

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