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   77 use strict;
  4         6  
  4         133  
4 4     4   16 use warnings;
  4         6  
  4         103  
5              
6 4     4   842 use parent 'Exporter';
  4         466  
  4         28  
7              
8             our @EXPORT_OK = qw(try_load_class);
9              
10 4     4   1077 use Plack::Util ();
  4         18375  
  4         368  
11              
12             sub try_load_class {
13 48     48 1 55 my ($class) = @_;
14              
15 48         195 my $path = (join '/', split /::/, $class) . '.pm';
16              
17 48 50 33     155 return $class if exists $INC{$path} && defined $INC{$path};
18              
19             {
20 4     4   27 no strict 'refs';
  4         6  
  4         539  
  48         50  
21 48         36 for (keys %{"$class\::"}) {
  48         220  
22 259 100       166 return $class if defined &{"$class\::$_"};
  259         689  
23             }
24             }
25              
26             eval {
27 9         28 Plack::Util::load_class($class);
28 9 100       16 } || do {
29 8         1651 my $e = $@;
30              
31 8 50       162 die $e unless $@ =~ m/Can't locate $path in \@INC/;
32              
33 8         39 return;
34             };
35             }
36              
37             1;
38             __END__