File Coverage

blib/lib/HTTP/Headers/ActionPack/AcceptLanguage.pm
Criterion Covered Total %
statement 16 16 100.0
branch 4 6 66.6
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 26 28 92.8


line stmt bran cond sub pod time code
1             package HTTP::Headers::ActionPack::AcceptLanguage;
2             BEGIN {
3 1     1   602 $HTTP::Headers::ActionPack::AcceptLanguage::AUTHORITY = 'cpan:STEVAN';
4             }
5             {
6             $HTTP::Headers::ActionPack::AcceptLanguage::VERSION = '0.09';
7             }
8             # ABSTRACT: A Priority List customized for Media Types
9              
10 1     1   6 use strict;
  1         1  
  1         23  
11 1     1   4 use warnings;
  1         1  
  1         20  
12              
13 1     1   732 use parent 'HTTP::Headers::ActionPack::PriorityList';
  1         276  
  1         5  
14              
15             # We'll just assume that any script or variant names are being given in the
16             # right form. To do this all properly would basically require having all the
17             # ICU data available, which we're not going to attempt currently.
18             sub canonicalize_choice {
19 65 50   65 1 127 return unless defined $_[1];
20 65         193 my @parts = split /[-_]/, $_[1];
21              
22 65         309 my $lang = lc shift @parts;
23              
24 65 100       140 if (@parts) {
25 20 50       53 $parts[-1] = uc $parts[-1]
26             if length $parts[-1] == 2;
27             }
28              
29 65         243 return join '-', $lang, @parts;
30             }
31              
32             1;
33              
34             __END__