| 1 | package HTML::CalendarMonth::Locale; | ||||||||||||||||||||||||||||
| 2 | { | ||||||||||||||||||||||||||||
| 3 | 10 | $HTML::CalendarMonth::Locale::VERSION = '2.00'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | # Front end class around DateTime::Locale. In addition to providing | ||||||||||||||||||||||||||||
| 7 | # access to the DT::Locale class and locale-specific instance, this | ||||||||||||||||||||||||||||
| 8 | # class prepares some other hashes and lookups utilized by | ||||||||||||||||||||||||||||
| 9 | # HTML::CalendarMonth. | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 10 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 10 | ▶ | use DateTime::Locale 0.45; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 19 | ▶ | sub _locale_version { $DateTime::Locale::VERSION } | ||||||||||||||||||||||||||
|
Subroutine
_locale_version: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 10 | my($CODE_METHOD, $CODES_METHOD); | |||||||||||||||||||||||||||
| 20 | 10 | ▶ | if (_locale_version() > 0.92) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 10 | $CODE_METHOD = "code"; | |||||||||||||||||||||||||||
| 22 | 10 | $CODES_METHOD = "codes"; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | else { | ||||||||||||||||||||||||||||
| 25 | 0 | $CODE_METHOD = "id"; | |||||||||||||||||||||||||||
| 26 | 0 | $CODES_METHOD = "ids"; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 10 | my %Register; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 309 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=20.4
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | 309 | my $class = shift; | |||||||||||||||||||||||||||
| 33 | 309 | my $self = {}; | |||||||||||||||||||||||||||
| 34 | 309 | bless $self, $class; | |||||||||||||||||||||||||||
| 35 | 309 | my %parms = @_; | |||||||||||||||||||||||||||
| 36 | # id is for backwards compatibility | ||||||||||||||||||||||||||||
| 37 | my $code = $parms{code} || $parms{id} | ||||||||||||||||||||||||||||
| 38 | 309 | ▶ | or croak "Locale code required (eg 'en-US')\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$parms{'code'} || $parms{'id'}
MC/DC0%0/2
$parms{'code'} || $parms{'id'}
$parms{'code'}
$parms{'id'}
Truth table33%1/3
A || B
A= $parms{'code'}B= $parms{'id'}
| |||||||||||||||||||||||||||||
| 39 | 309 | ▶ | $self->{full_days} = defined $parms{full_days} ? $parms{full_days} : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 309 | ▶ | $self->{full_months} = defined $parms{full_months} ? $parms{full_months} : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | # returned code might be different from given code | ||||||||||||||||||||||||||||
| 42 | 309 | ▶ | unless ($Register{$code}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 10 | ▶ | my $dtl = $self->locale->load($code) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | or croak "Problem loading locale '$code'"; | ||||||||||||||||||||||||||||
| 45 | 10 | $Register{$code} = $Register{$dtl->$CODE_METHOD} = { loc => $dtl }; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | 309 | $self->{code} = $Register{$code}{loc}->$CODE_METHOD; | |||||||||||||||||||||||||||
| 48 | 309 | $self; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 11 | ▶ | sub locale { 'DateTime::Locale' } | ||||||||||||||||||||||||||
|
Subroutine
locale: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 35 | ▶ | sub loc { $Register{shift->code}{loc} } | ||||||||||||||||||||||||||
|
Subroutine
loc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 1 | ▶ | sub locales { shift->locale->$CODES_METHOD } | ||||||||||||||||||||||||||
|
Subroutine
locales: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 2834 | ▶ | sub code { shift->{code} } | ||||||||||||||||||||||||||
|
Subroutine
code: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | 10 | *id = *code; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 10 | ▶ | sub full_days { shift->{full_days} } | ||||||||||||||||||||||||||
|
Subroutine
full_days: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 61 | 10 | ▶ | sub full_months { shift->{full_months} } | ||||||||||||||||||||||||||
|
Subroutine
full_months: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 7 | ▶ | sub first_day_of_week { shift->loc->first_day_of_week % 7 } | ||||||||||||||||||||||||||
|
Subroutine
first_day_of_week: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 624 | ▶ | sub days { | ||||||||||||||||||||||||||
|
Subroutine
days: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 624 | my $self = shift; | |||||||||||||||||||||||||||
| 67 | 624 | my $code = $self->code; | |||||||||||||||||||||||||||
| 68 | 624 | ▶ | unless ($Register{$code}{days}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 10 | ▶ | my $method = $self->full_days ? 'day_stand_alone_wide' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | : 'day_stand_alone_abbreviated'; | ||||||||||||||||||||||||||||
| 71 | # adjust to H::CM standard expectation, 1st day Sun | ||||||||||||||||||||||||||||
| 72 | # Sunday is first, regardless of what the calendar considers to be | ||||||||||||||||||||||||||||
| 73 | # the first day of the week | ||||||||||||||||||||||||||||
| 74 | 10 | my @days = @{$self->loc->$method}; | |||||||||||||||||||||||||||
| 75 | 10 | unshift(@days, pop @days); | |||||||||||||||||||||||||||
| 76 | 10 | $Register{$code}{days} = \@days; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | 624 | ▶ | wantarray ? @{$Register{$code}{days}} : $Register{$code}{days}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 6 | ▶ | sub narrow_days { | ||||||||||||||||||||||||||
|
Subroutine
narrow_days: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 82 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 83 | 6 | my $code = $self->code; | |||||||||||||||||||||||||||
| 84 | 6 | ▶ | unless ($Register{$code}{narrow_days}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | # Sunday is first, regardless of what the calendar considers to be | ||||||||||||||||||||||||||||
| 86 | # the first day of the week | ||||||||||||||||||||||||||||
| 87 | 1 | my @days = @{ $self->loc->day_stand_alone_narrow }; | |||||||||||||||||||||||||||
| 88 | 1 | unshift(@days, pop @days); | |||||||||||||||||||||||||||
| 89 | 1 | $Register{$code}{narrow_days} = \@days; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | 6 | wantarray ? @{$Register{$code}{narrow_days}} | |||||||||||||||||||||||||||
| 92 | 6 | ▶ | : $Register{$code}{narrow_days}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 327 | ▶ | sub months { | ||||||||||||||||||||||||||
|
Subroutine
months: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 96 | 327 | my $self = shift; | |||||||||||||||||||||||||||
| 97 | 327 | my $code = $self->code; | |||||||||||||||||||||||||||
| 98 | 327 | ▶ | unless ($Register{$code}{months}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 10 | ▶ | my $method = $self->full_months > 0 ? 'month_stand_alone_wide' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | : 'month_stand_alone_abbreviated'; | ||||||||||||||||||||||||||||
| 101 | 10 | $Register{$code}{months} = [@{$self->loc->$method}]; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | 327 | ▶ | wantarray ? @{$Register{$code}{months}} : $Register{$code}{months}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub narrow_months { | ||||||||||||||||||||||||||
|
Subroutine
narrow_months: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 107 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 108 | 0 | my $code = $self->code; | |||||||||||||||||||||||||||
| 109 | $Register{$code}{narrow_months} | ||||||||||||||||||||||||||||
| 110 | 0 | ▶ | ||= [@{$self->loc->month_stand_alone_narrow}]; | ||||||||||||||||||||||||||
|
Condition0%0/2
$Register{$code}{"narrow_months"} ||= [@{$self->loc->month_stand_alone_narrow;}]
MC/DC0%0/1
$Register{$code}{"narrow_months"} ||= [@{$self->loc->month_stand_alone_narrow;}]
$Register{$code}{"narrow_months"}
Truth table0%0/2
A
A= $Register{$code}{"narrow_months"}
| |||||||||||||||||||||||||||||
| 111 | 0 | wantarray ? @{$Register{$code}{narrow_months}} | |||||||||||||||||||||||||||
| 112 | 0 | ▶ | : $Register{$code}{narrow_months}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | ▶ | sub days_minmatch { | ||||||||||||||||||||||||||
|
Subroutine
days_minmatch: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 116 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 117 | $Register{$self->code}{days_mm} | ||||||||||||||||||||||||||||
| 118 | 0 | ▶ | ||= $self->lc_minmatch_hash($self->days); | ||||||||||||||||||||||||||
|
Condition0%0/3
$Register{$self->code}{"days_mm"} ||= $self->lc_minmatch_hash($self->days)
MC/DC0%0/2
$Register{$self->code}{"days_mm"} ||= $self->lc_minmatch_hash($self->days)
$Register{$self->code}{"days_mm"}
$self->lc_minmatch_hash($self->days)
Truth table0%0/3
A ||= B
A= $Register{$self->code}{"days_mm"}B= $self->lc_minmatch_hash($self->days)
| |||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | 10 | *minmatch = \&days_minmatch; | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub _days_minmatch_pattern { | ||||||||||||||||||||||||||
|
Subroutine
_days_minmatch_pattern: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 123 | 0 | my $dmm = shift->days_minmatch; | |||||||||||||||||||||||||||
| 124 | 0 | join('|', sort keys %$dmm); | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | 10 | *minmatch_pattern = \&_days_minmatch_pattern; | |||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 1228 | ▶ | sub months_minmatch { | ||||||||||||||||||||||||||
|
Subroutine
months_minmatch: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 129 | 1228 | my $self = shift; | |||||||||||||||||||||||||||
| 130 | $Register{$self->code}{months_mm} | ||||||||||||||||||||||||||||
| 131 | 1228 | ▶ | ||= $self->lc_minmatch_hash($self->months); | ||||||||||||||||||||||||||
|
Condition66%2/3
$Register{$self->code}{"months_mm"} ||= $self->lc_minmatch_hash($self->months)
MC/DC0%0/2
$Register{$self->code}{"months_mm"} ||= $self->lc_minmatch_hash($self->months)
$Register{$self->code}{"months_mm"}
$self->lc_minmatch_hash($self->months)
Truth table66%2/3
A ||= B
A= $Register{$self->code}{"months_mm"}B= $self->lc_minmatch_hash($self->months)
| |||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 614 | ▶ | sub _months_minmatch_pattern { | ||||||||||||||||||||||||||
|
Subroutine
_months_minmatch_pattern: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 135 | 614 | my $mmm = shift->months_minmatch; | |||||||||||||||||||||||||||
| 136 | 614 | join('|', sort keys %$mmm); | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 0 | ▶ | sub daynums { | ||||||||||||||||||||||||||
|
Subroutine
daynums: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 140 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 141 | 0 | my $code = $self->code; | |||||||||||||||||||||||||||
| 142 | 0 | ▶ | unless ($Register{$code}{daynum}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | 0 | my %daynum; | |||||||||||||||||||||||||||
| 144 | 0 | my $days = $self->days; | |||||||||||||||||||||||||||
| 145 | 0 | $daynum{$days->[$_]} = $_ foreach 0 .. $#$days; | |||||||||||||||||||||||||||
| 146 | 0 | $Register{$code}{daynum} = \%daynum; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | 0 | wantarray ? %{$Register{$code}{daynum}} | |||||||||||||||||||||||||||
| 149 | 0 | ▶ | : $Register{$code}{daynum}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 0 | ▶ | sub _daymatch { | ||||||||||||||||||||||||||
|
Subroutine
_daymatch: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 153 | 0 | my($self, $day) = @_; | |||||||||||||||||||||||||||
| 154 | 0 | ▶ | return unless defined $day; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | 0 | ▶ | if ($day =~ /^\d+$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | 0 | $day %= 7; | |||||||||||||||||||||||||||
| 157 | 0 | return($day, $self->days->[$day]); | |||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | 0 | my $p = $self->_days_minmatch_pattern; | |||||||||||||||||||||||||||
| 160 | 0 | ▶ | if ($day =~ /^($p)/i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | 0 | $day = $self->days_minmatch->{lc $1}; | |||||||||||||||||||||||||||
| 162 | 0 | return($self->daynums->{$day}, $day); | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | 0 | return (); | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub daynum { (shift->_daymatch(@_))[0] } | ||||||||||||||||||||||||||
|
Subroutine
daynum: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 168 | 0 | ▶ | sub dayname { (shift->_daymatch(@_))[1] } | ||||||||||||||||||||||||||
|
Subroutine
dayname: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 614 | ▶ | sub monthnums { | ||||||||||||||||||||||||||
|
Subroutine
monthnums: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 171 | 614 | my $self = shift; | |||||||||||||||||||||||||||
| 172 | 614 | my $code = $self->code; | |||||||||||||||||||||||||||
| 173 | 614 | ▶ | unless ($Register{$code}{monthnum}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 174 | 10 | my %monthnum; | |||||||||||||||||||||||||||
| 175 | 10 | my $months = $self->months; | |||||||||||||||||||||||||||
| 176 | 10 | $monthnum{$months->[$_]} = $_ foreach 0 .. $#$months; | |||||||||||||||||||||||||||
| 177 | 10 | $Register{$code}{monthnum} = \%monthnum; | |||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | 0 | wantarray ? %{$Register{$code}{monthnum}} | |||||||||||||||||||||||||||
| 180 | 614 | ▶ | : $Register{$code}{monthnum}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 921 | ▶ | sub _monthmatch { | ||||||||||||||||||||||||||
|
Subroutine
_monthmatch: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||
| 184 | 921 | my($self, $mon) = @_; | |||||||||||||||||||||||||||
| 185 | 921 | ▶ | return unless defined $mon; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | 921 | ▶ | if ($mon =~ /^\d+$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | 307 | $mon %= 12; | |||||||||||||||||||||||||||
| 188 | 307 | return($mon, $self->months->[$mon]); | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | 614 | my $p = $self->_months_minmatch_pattern; | |||||||||||||||||||||||||||
| 191 | 614 | ▶ | if ($mon =~ /^($p)/i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | 614 | $mon = $self->months_minmatch->{lc $1}; | |||||||||||||||||||||||||||
| 193 | 614 | return($self->monthnums->{$mon}, $mon); | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | 0 | return (); | |||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 614 | ▶ | sub monthnum { (shift->_monthmatch(@_))[0] } | ||||||||||||||||||||||||||
|
Subroutine
monthnum: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 199 | 307 | ▶ | sub monthname { (shift->_monthmatch(@_))[1] } | ||||||||||||||||||||||||||
|
Subroutine
monthname: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | ### | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 0 | ▶ | sub locale_map { | ||||||||||||||||||||||||||
|
Subroutine
locale_map: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 204 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 205 | 0 | my %map; | |||||||||||||||||||||||||||
| 206 | 0 | foreach my $code ($self->locales) { | |||||||||||||||||||||||||||
| 207 | 0 | $map{$code} = $self->locale->load($code)->name; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | 0 | ▶ | wantarray ? %map : \%map; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | ### | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 10 | ▶ | sub lc_minmatch_hash { | ||||||||||||||||||||||||||
|
Subroutine
lc_minmatch_hash: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 215 | # given a list, provide a reverse lookup of case-insensitive minimal | ||||||||||||||||||||||||||||
| 216 | # values for each label in the list | ||||||||||||||||||||||||||||
| 217 | 10 | my $whatever = shift; | |||||||||||||||||||||||||||
| 218 | 10 | my @orig_labels = @_; | |||||||||||||||||||||||||||
| 219 | 10 | my @labels = map { lc $_ } @orig_labels; | |||||||||||||||||||||||||||
| 220 | 10 | my $cc = 1; | |||||||||||||||||||||||||||
| 221 | 10 | my %minmatch; | |||||||||||||||||||||||||||
| 222 | 10 | ▶ | while (@labels) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | 31 | my %scratch; | |||||||||||||||||||||||||||
| 224 | 31 | foreach my $i (0 .. $#labels) { | |||||||||||||||||||||||||||
| 225 | 218 | my $str = $labels[$i]; | |||||||||||||||||||||||||||
| 226 | 218 | my $chrs = substr($str, 0, $cc); | |||||||||||||||||||||||||||
| 227 | 218 | ▶ | $scratch{$chrs} ||= []; | ||||||||||||||||||||||||||
|
Condition100%2/2
$scratch{$chrs} ||= []
MC/DC100%1/1
$scratch{$chrs} ||= []
$scratch{$chrs}
Truth table100%2/2
A
A= $scratch{$chrs}
| |||||||||||||||||||||||||||||
| 228 | 218 | push(@{$scratch{$chrs}}, $i); | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | 31 | my @keep_i; | |||||||||||||||||||||||||||
| 231 | 31 | foreach (keys %scratch) { | |||||||||||||||||||||||||||
| 232 | 165 | ▶ | if (@{$scratch{$_}} == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 233 | 120 | $minmatch{$_} = $orig_labels[$scratch{$_}[0]]; | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | else { | ||||||||||||||||||||||||||||
| 236 | 45 | push(@keep_i, @{$scratch{$_}}); | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | 31 | @labels = @labels[@keep_i]; | |||||||||||||||||||||||||||
| 240 | 31 | @orig_labels = @orig_labels[@keep_i]; | |||||||||||||||||||||||||||
| 241 | 31 | ++$cc; | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | 10 | \%minmatch; | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 0 | ▶ | sub minmatch_hash { | ||||||||||||||||||||||||||
|
Subroutine
minmatch_hash: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 247 | # given a list, provide a reverse lookup of minimal values for each | ||||||||||||||||||||||||||||
| 248 | # label in the list | ||||||||||||||||||||||||||||
| 249 | 0 | my $whatever = shift; | |||||||||||||||||||||||||||
| 250 | 0 | my @labels = @_; | |||||||||||||||||||||||||||
| 251 | 0 | my $cc = 1; | |||||||||||||||||||||||||||
| 252 | 0 | my %minmatch; | |||||||||||||||||||||||||||
| 253 | 0 | ▶ | while (@labels) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | 0 | my %scratch; | |||||||||||||||||||||||||||
| 255 | 0 | foreach my $i (0 .. $#labels) { | |||||||||||||||||||||||||||
| 256 | 0 | my $str = $labels[$i]; | |||||||||||||||||||||||||||
| 257 | 0 | my $chrs = substr($str, 0, $cc); | |||||||||||||||||||||||||||
| 258 | 0 | ▶ | $scratch{$chrs} ||= []; | ||||||||||||||||||||||||||
|
Condition0%0/2
$scratch{$chrs} ||= []
MC/DC0%0/1
$scratch{$chrs} ||= []
$scratch{$chrs}
Truth table0%0/2
A
A= $scratch{$chrs}
| |||||||||||||||||||||||||||||
| 259 | 0 | push(@{$scratch{$chrs}}, $i); | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | 0 | my @keep_i; | |||||||||||||||||||||||||||
| 262 | 0 | foreach (keys %scratch) { | |||||||||||||||||||||||||||
| 263 | 0 | ▶ | if (@{$scratch{$_}} == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 0 | $minmatch{$_} = $labels[$scratch{$_}[0]]; | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | else { | ||||||||||||||||||||||||||||
| 267 | 0 | push(@keep_i, @{$scratch{$_}}); | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | 0 | @labels = @labels[@keep_i]; | |||||||||||||||||||||||||||
| 271 | 0 | ++$cc; | |||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | 0 | \%minmatch; | |||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 10 | 1; | |||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | __END__ | ||||||||||||||||||||||||||||