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   17 use strict;
  4         5  
  4         115  
4 4     4   14 use warnings;
  4         5  
  4         82  
5              
6 4     4   784 use parent 'Exporter';
  4         456  
  4         23  
7              
8             our @EXPORT_OK = qw(try_load_class);
9              
10 4     4   1074 use Plack::Util ();
  4         18333  
  4         278  
11              
12             sub try_load_class {
13 48     48 1 42 my ($class) = @_;
14              
15 48         168 my $path = (join '/', split /::/, $class) . '.pm';
16              
17 48 50 33     121 return $class if exists $INC{$path} && defined $INC{$path};
18              
19             {
20 4     4   24 no strict 'refs';
  4         5  
  4         483  
  48         41  
21 48         38 for (keys %{"$class\::"}) {
  48         203  
22 222 100       148 return $class if defined &{"$class\::$_"};
  222         536  
23             }
24             }
25              
26             eval {
27 9         32 Plack::Util::load_class($class);
28 9 100       13 } || do {
29 8         1332 my $e = $@;
30              
31 8 50       131 die $e unless $@ =~ m/Can't locate $path in \@INC/;
32              
33 8         37 return;
34             };
35             }
36              
37             1;
38             __END__