| 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
Condition50%1/2
$charset || ''
MC/DC0%0/1
$charset || ''
$charset
Truth table50%1/2
A
A= $charset
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 305 | require_module('Encode'); | |||||||||||||||||||
| 21 | 305 | my $encoding = Encode::find_encoding($charset); | |||||||||||||||||||
| 22 | 305 | ▶ | croak | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 38 | 4089 | return $value; | |||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 193 | 1; | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | __END__ | ||||||||||||||||||||