MilkyHolmes/Character.pm

filter: Statementstmt 96.8% 62 / 64 Branchbran 78.5% 11 / 14 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 16 / 16 Podpod 87.5% 7 / 8 totaltotal 90.9% 100 / 110 CC 11 SCAR 10.3
CC
11
Cov
92%
name
6.1
BUILD
4.0
_localized_field
2.1
CRAP 2.8
« MilkyHolmes/Group/MilkyHolmes.pm ↑ Summary MilkyHolmes.pm »
1 package Acme::MilkyHolmes::Character;
2 3 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 3 ▶use Data::Section::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use Localizer::Resource;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Localizer::Style::Gettext;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use YAML::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 has localizer => (
11 is => 'ro',
12 );
13  
14 3 has locale => (
15 is => 'rw',
16 isa => 'Str',
17 required => 1,
18 default => 'ja',
19 );
20  
21 3 has common => (
22 is => 'ro',
23 );
24  
25 3 ▶no Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 44 ▶sub name {
Subroutine name: called CC=6 SCAR=18.1
Pod documented
28 44 my ($self) = @_;
29  
30 44 my $sep = $self->_localized_field('name_separator');
31 44 ▶ $sep = ' ' if ( !defined $sep );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sep 32 12 44
32  
33 44 ▶ if ( defined $self->_localized_field('name') ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->_localized_field('name')) { } 0 44 44
elsif ($self->locale eq 'ja') { } 22 22 44
34 0 return $self->_localized_field('name');
35 }
36 elsif ( $self->locale eq 'ja' ) {
37 22 ▶ if( defined $sep && $sep eq '・' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sep and $sep eq "\x{30fb}") 12 10 22
Condition66%2/3
defined $sep and $sep eq "\x{30fb}"
!ll&&!rl&&r
01012
MC/DC50%1/2
defined $sep and $sep eq "\x{30fb}"
defined $sep $sep eq "\x{30fb}"
Truth table66%2/3
A and B
A= defined $sepB= $sep eq "\x{30fb}"
ABresult
0X0
100
111
38 12 return $self->firstname . $sep . $self->familyname;
39 }
40 10 return $self->familyname . $sep . $self->firstname;
41 }
42 22 return $self->firstname . $sep . $self->familyname;
43 }
44  
45 56 ▶sub firstname {
Subroutine firstname: called CC=1 SCAR=0.0
Pod documented
46 56 my ($self) = @_;
47 56 return $self->_localized_field('firstname');
48 }
49  
50 56 ▶sub familyname {
Subroutine familyname: called CC=1 SCAR=0.0
Pod documented
51 56 my ($self) = @_;
52 56 return $self->_localized_field('familyname');
53 }
54  
55 12 ▶sub nickname {
Subroutine nickname: called CC=2 SCAR=6.9
Pod documented
56 12 my ($self) = @_;
57 12 ▶ if ( defined $self->_localized_field('nickname') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->_localized_field("nickname")) 4 8 12
58 4 return $self->_localized_field('nickname');
59 }
60 8 return $self->_localized_field('firstname');
61 }
62  
63 12 ▶sub birthday {
Subroutine birthday: called CC=1 SCAR=0.0
Pod documented
64 12 my ($self) = @_;
65 12 return $self->_localized_field('birthday');
66 }
67  
68 10 ▶sub voiced_by {
Subroutine voiced_by: called CC=1 SCAR=0.0
Pod documented
69 10 my ($self) = @_;
70 10 return $self->_localized_field('voiced_by');
71 }
72  
73 12 ▶sub nickname_voiced_by {
Subroutine nickname_voiced_by: called CC=1 SCAR=0.0
Pod undocumented
74 12 my ($self) = @_;
75 12 return $self->_localized_field('nickname_voiced_by');
76 }
77  
78 276 ▶sub _localized_field {
Subroutine _localized_field: called CC=2 SCAR=7.4
79 276 my ($self, $name) = @_;
80 276 ▶ if ( exists $self->localizer->{ $self->locale } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->localizer->{$self->locale}) 276 0 276
81 276 my $localizer = $self->localizer->{ $self->locale };
82 276 return $localizer->maketext($name);
83 }
84 0 return $self->{$name};
85 }
86  
87 48 ▶sub BUILD {
Subroutine BUILD: called CC=4 SCAR=14.0
Pod documented
88 48 my ($self, $args) = @_;
89  
90 48 my $ds = Data::Section::Simple->new( ref $self );
91 48 my $sections = $ds->get_data_section();
92 48 ▶ if ( exists $sections->{common} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $sections->{"common"}) 48 0 48
93 48 my $common = YAML::Tiny->read_string( delete $sections->{common} );
94 48 $self->{common} = $common;
95 }
96  
97 48 ▶ for my $section_name ( keys %{ $sections || {} } ) {
Condition50%1/2
$sections || {}
l!l
480
MC/DC0%0/1
$sections || {}
$sections
Truth table50%1/2
A
A= $sections
Aresult
11
00
98 96 my $yaml = YAML::Tiny->read_string($sections->{$section_name});
99  
100 96 my $localizer = Localizer::Resource->new(
101 dictionary => $yaml->[0],
102 format => Localizer::Style::Gettext->new(),
103 );
104 96 $self->{localizer}->{$section_name} = $localizer;
105 }
106 }
107  
108 3 1;
109 __END__
« MilkyHolmes/Group/MilkyHolmes.pm ↑ Summary MilkyHolmes.pm »