blib/lib/Mojolicious/Plugin/Message/Locale.pm

filter: Statementstmt 95.6% 22 / 23 Branchbran 75.0% 6 / 8 Conditioncond 87.5% 7 / 8 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 89.5% 43 / 48 CC 9 SCAR 13.6
CC
9
Cov
90%
__ANON__
5.1
register
4.0
__ANON__
2.1
CRAP 3.9
↑ Summary
1 package Mojolicious::Plugin::Message::Locale;
2 5 ▶use Mojo::Base 'Mojolicious::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 5 our $VERSION = '0.03';
5  
6 4 ▶sub register {
Subroutine register: called CC=4 SCAR=13.9
Pod documented
7 4 my ($self, $app, $conf) = @_;
8  
9 4 ▶ $conf->{default_message} ||= '';
Condition100%2/2
$conf->{"default_message"} ||= ""
l!l
13
MC/DC100%1/1
$conf->{"default_message"} ||= ""
$conf->{"default_message"}
Truth table100%2/2
A
A= $conf->{"default_message"}
Aresult
11
00
10 4 ▶ $conf->{locale} ||= 'en';
Condition100%2/2
$conf->{"locale"} ||= "en"
l!l
13
MC/DC100%1/1
$conf->{"locale"} ||= "en"
$conf->{"locale"}
Truth table100%2/2
A
A= $conf->{"locale"}
Aresult
11
00
11 4 ▶ $conf->{file} ||= 'locale.conf';
Condition100%2/2
$conf->{"file"} ||= "locale.conf"
l!l
13
MC/DC100%1/1
$conf->{"file"} ||= "locale.conf"
$conf->{"file"}
Truth table100%2/2
A
A= $conf->{"file"}
Aresult
11
00
12  
13 4 my $messages = $app->plugin('Config', { file => $conf->{file} } );
14  
15 1 ▶ $app->helper ( set_locale => sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
16 1 my ($c, $loc,) = @_;
17 1 ▶ $conf->{locale} = $loc ? $loc : 'en';
Branch: 1 branch
BranchTrueFalseTotal
$loc ? : 1 0 1
18 4 });
19  
20 9 ▶ $app->helper ( locale => sub {
Subroutine __ANON__: called CC=5 SCAR=16.4
21 9 my ($c, $key, $group,) = @_;
22 9 ▶ unless ( $key ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($key) 1 8 9
23 1 warn 'key is undefined or incorrenct.';
24 1 return $conf->{default_message};
25 }
26 8 ▶ $group ||= 'common';
Condition50%1/2
$group ||= "common"
l!l
80
MC/DC0%0/1
$group ||= "common"
$group
Truth table50%1/2
A
A= $group
Aresult
11
00
27  
28 8 ▶ if ( exists $messages->{$group}->{$key}->{$conf->{locale}} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $messages->{$group}{$key}{$conf->{'locale'}}) { } 7 1 8
elsif (exists $messages->{'common'}{$key}{$conf->{'locale'}}) { } 0 1 1
29 7 $messages->{$group}->{$key}->{$conf->{locale}};
30 } elsif ( exists $messages->{'common'}->{$key}->{$conf->{locale}} ) {
31 $messages->{'common'}->{$key}->{$conf->{locale}}
32 0 } else {
33 1 $conf->{default_message};
34 }
35 4 });
36 }
37  
38 5 1;
39 __END__
↑ Summary