Pickles/Plugin/Encode.pm

filter: Statementstmt 100% 39 / 39 Branchbran 75.0% 3 / 4 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 89.4% 51 / 57 CC 7 SCAR 8.1
CC
7
Cov
94%
__ANON__
3.1
_decode_args
3.0
__ANON__
2.0
CRAP 2.2
« Pickles/WebApp.pm ↑ Summary Pickles/Plugin.pm »
1 package Pickles::Plugin::Encode;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 6 ▶sub _decode {
Subroutine _decode: called CC=2 SCAR=6.9
6 6 my ($hmv, $ie) = @_;
7 6 for my $key( $hmv->keys ) {
8 1 my @values = map { Encode::decode($ie, $_) } $hmv->get_all( $key );
9 1 $hmv->remove( $key );
10 1 $hmv->add( $key => @values );
11 }
12 }
13  
14 3 ▶sub _decode_args {
Subroutine _decode_args: called CC=3 SCAR=11.0
15 3 my($h, $ie) = @_;
16 3 for my $key( keys %{$h} ) {
17 2 ▶ if ( ref $h->{$key} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $h->{$key} eq 'ARRAY') { } 1 1 2
18 1 my @values = map { Encode::decode($ie, $_) } @{$h->{$key}};
19 1 $h->{$key} = \@values;
20 }
21 else {
22 1 $h->{$key} = Encode::decode($ie, $h->{$key});
23 }
24 }
25 }
26  
27 1 ▶sub install {
Subroutine install: called CC=1 SCAR=0.0
Pod undocumented
28 1 my( $class, $pkg ) = @_;
29 3 ▶ $pkg->add_trigger( init => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
30 3 my $c = shift;
31 3 my $config = $c->config->{'Plugin::Encode'};
32 3 ▶ my $ie = $config->{input_encoding} || 'utf-8';
Condition50%1/2
$config->{'input_encoding'} || 'utf-8'
l!l
03
MC/DC0%0/1
$config->{'input_encoding'} || 'utf-8'
$config->{'input_encoding'}
Truth table50%1/2
A
A= $config->{'input_encoding'}
Aresult
11
00
33 3 _decode( $c->req->query_parameters, $ie );
34 3 _decode( $c->req->body_parameters, $ie );
35 3 _decode_args($c->args, $ie);
36 3 delete $c->req->env->{'plack.request.merged'}; # make sure
37 1 });
38 3 ▶ $pkg->add_trigger( pre_finalize => sub {
Subroutine __ANON__: called CC=3 SCAR=11.2
39 3 my( $c ) = @_;
40 3 ▶ if ( $c->res->content_type =~ m{^text/} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->res->content_type =~ m[^text/]) 3 0 3
41 3 my $body = $c->res->body;
42 3 my $config = $c->config->{'Plugin::Encode'};
43 3 ▶ my $oe = $config->{output_encoding} || 'utf-8';
Condition50%1/2
$config->{'output_encoding'} || 'utf-8'
l!l
03
MC/DC0%0/1
$config->{'output_encoding'} || 'utf-8'
$config->{'output_encoding'}
Truth table50%1/2
A
A= $config->{'output_encoding'}
Aresult
11
00
44 3 $c->res->content_type( $c->res->content_type. '; charset='. $oe );
45 3 $c->res->body( Encode::encode( $oe, $body ) );
46 }
47 1 });
48 }
49  
50 1 1;
51  
52 __END__
« Pickles/WebApp.pm ↑ Summary Pickles/Plugin.pm »