lib/Dancer2/ConfigUtils.pm

filter: Statementstmt 100% 30 / 30 Branchbran 75.0% 6 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 89.8% 44 / 49 CC 6 SCAR 10.7
CC
6
Cov
92%
__ANON__
5.2
normalize_config_entry
2.0
BEGIN
1.0
CRAP 2.9
« lib/Dancer2/Core/Role/Template.pm ↑ Summary lib/Dancer2/Core/Role/SessionFactory.pm »
1 package Dancer2::ConfigUtils;
2 # ABSTRACT: Config utility helpers
3 193 $Dancer2::ConfigUtils::VERSION = '2.3.0';
4 193 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 193 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 193 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 193 ▶use Module::Runtime qw{ require_module };
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 193 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 193 our @EXPORT_OK = qw(
12 normalize_config_entry
13 );
14  
15 my $NORMALIZERS = {
16 305 ▶ charset => sub {
Subroutine __ANON__: called CC=5 SCAR=16.4
17 305 my ($charset) = @_;
18 305 ▶ return $charset if !length( $charset || '' );
Branch: 1 branch
BranchTrueFalseTotal
unless length($charset || "") 0 305 305
Condition50%1/2
$charset || ''
l!l
3050
MC/DC0%0/1
$charset || ''
$charset
Truth table50%1/2
A
A= $charset
Aresult
11
00
19  
20 305 require_module('Encode');
21 305 my $encoding = Encode::find_encoding($charset);
22 305 ▶ croak
Branch: 1 branch
BranchTrueFalseTotal
unless defined $encoding 2 303 305
23 "Charset defined in configuration is wrong : couldn't identify '$charset'"
24 unless defined $encoding;
25 303 my $name = $encoding->name;
26  
27 # Perl makes a distinction between the usual perl utf8, and the strict
28 # utf8 charset. But we don't want to make this distinction
29 303 ▶ $name = 'utf-8' if $name eq 'utf-8-strict';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "utf-8-strict" 303 0 303
30 303 return $name;
31 },
32 193 };
33  
34 4091 ▶sub normalize_config_entry {
Subroutine normalize_config_entry: called CC=2 SCAR=6.9
Pod undocumented
35 4091 my ( $name, $value ) = @_;
36 $value = $NORMALIZERS->{$name}->($value)
37 4091 ▶ if exists $NORMALIZERS->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $NORMALIZERS->{$name} 305 3786 4091
38 4089 return $value;
39 }
40  
41 193 1;
42  
43 __END__
« lib/Dancer2/Core/Role/Template.pm ↑ Summary lib/Dancer2/Core/Role/SessionFactory.pm »