File Coverage

blib/lib/Plack/I18N/Util.pm
Criterion Covered Total %
statement 28 28 100.0
branch 6 8 75.0
condition 1 3 33.3
subroutine 6 6 100.0
pod 1 1 100.0
total 42 46 91.3


line stmt bran cond sub pod time code
1             package Plack::I18N::Util;
2              
3 4     4   19 use strict;
  4         6  
  4         148  
4 4     4   19 use warnings;
  4         6  
  4         120  
5              
6 4     4   1050 use parent 'Exporter';
  4         613  
  4         27  
7              
8             our @EXPORT_OK = qw(try_load_class);
9              
10 4     4   1132 use Plack::Util ();
  4         19988  
  4         365  
11              
12             sub try_load_class {
13 48     48 1 45 my ($class) = @_;
14              
15 48         170 my $path = (join '/', split /::/, $class) . '.pm';
16              
17 48 50 33     136 return $class if exists $INC{$path} && defined $INC{$path};
18              
19             {
20 4     4   24 no strict 'refs';
  4         15  
  4         560  
  48         35  
21 48         40 for (keys %{"$class\::"}) {
  48         181  
22 211 100       153 return $class if defined &{"$class\::$_"};
  211         525  
23             }
24             }
25              
26             eval {
27 9         30 Plack::Util::load_class($class);
28 9 100       10 } || do {
29 8         1354 my $e = $@;
30              
31 8 50       146 die $e unless $@ =~ m/Can't locate $path in \@INC/;
32              
33 8         43 return;
34             };
35             }
36              
37             1;
38             __END__