blib/lib/Acme/MilkyHolmes/Character.pm

filter: Statementstmt 96.8% 62 / 64 Branchbran 75.0% 12 / 16 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 16 / 16 Podpod 87.5% 7 / 8 totaltotal 91.7% 100 / 109 CC 11 SCAR 10.3
CC
11
Cov
92%
name
6.1
BUILD
4.0
_localized_field
2.1
CRAP 2.8
« blib/lib/Acme/MilkyHolmes/Group/MilkyHolmes.pm ↑ Summary _build/lib/MyBuilder.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 sub name {
28 44 ▶ my ($self) = @_;
Subroutine name: called CC=6 SCAR=18.1
Pod documented
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 sub firstname {
46 56 ▶ my ($self) = @_;
Subroutine firstname: called CC=1 SCAR=0.0
Pod documented
47 56 return $self->_localized_field('firstname');
48 }
49  
50 sub familyname {
51 56 ▶ my ($self) = @_;
Subroutine familyname: called CC=1 SCAR=0.0
Pod documented
52 56 return $self->_localized_field('familyname');
53 }
54  
55 sub nickname {
56 12 ▶ my ($self) = @_;
Subroutine nickname: called CC=2 SCAR=6.9
Pod documented
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 sub birthday {
64 12 ▶ my ($self) = @_;
Subroutine birthday: called CC=1 SCAR=0.0
Pod documented
65 12 return $self->_localized_field('birthday');
66 }
67  
68 sub voiced_by {
69 10 ▶ my ($self) = @_;
Subroutine voiced_by: called CC=1 SCAR=0.0
Pod documented
70 10 return $self->_localized_field('voiced_by');
71 }
72  
73 sub nickname_voiced_by {
74 12 ▶ my ($self) = @_;
Subroutine nickname_voiced_by: called CC=1 SCAR=0.0
Pod undocumented
75 12 return $self->_localized_field('nickname_voiced_by');
76 }
77  
78 sub _localized_field {
79 276 ▶ my ($self, $name) = @_;
Subroutine _localized_field: called CC=2 SCAR=7.4
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 sub BUILD {
88 48 ▶ my ($self, $args) = @_;
Subroutine BUILD: called CC=4 SCAR=14.0
Pod documented
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 || {} } ) {
Branch: 1 branch
BranchTrueFalseTotal
$sections or {} 0 48 48
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__
« blib/lib/Acme/MilkyHolmes/Group/MilkyHolmes.pm ↑ Summary _build/lib/MyBuilder.pm »