File Coverage

blib/lib/WebNano/FindController.pm
Criterion Covered Total %
statement 27 27 100.0
branch 7 8 87.5
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 40 41 97.5


line stmt bran cond sub pod time code
1 4     4   22 use strict;
  4         7  
  4         91  
2 4     4   19 use warnings;
  4         5  
  4         133  
3              
4             package WebNano::FindController;
5              
6 4     4   20 use Exporter 'import';
  4         5  
  4         164  
7             our @EXPORT_OK = qw(find_nested);
8              
9 4     4   3118 use Try::Tiny;
  4         9782  
  4         966  
10              
11             sub find_nested {
12 66     66 1 209 my( $sub_path, $search_path ) = @_;
13 66 50       190 return if $sub_path =~ /\./;
14 66         140 $sub_path =~ s{/}{::}g;
15 66         140 my @path = @$search_path;
16 66         112 for my $base ( @path ){
17 95         196 my $controller_class = $base . '::Controller' . $sub_path;
18 95         5000 eval "require $controller_class";
19 95 100       6883 if( $@ ){
20 33         47 my $file = $controller_class;
21 33         128 $file =~ s{::}{/}g;
22 33         48 $file .= '.pm';
23 33 100       564 if( $@ !~ /Can't locate \Q$file\E in \@INC/ ){
24 1         10 die $@;
25             }
26             };
27 94 100       778 return $controller_class if $controller_class->isa( 'WebNano::Controller' );
28             }
29 4         15 return;
30             }
31              
32             1;
33              
34              
35              
36             =pod
37              
38             =head1 NAME
39              
40             WebNano::FindController - Tool for finding controller classes
41              
42             =head1 VERSION
43              
44             version 0.001
45              
46             =head2 find_nested
47              
48             =head1 AUTHOR
49              
50             Zbigniew Lukasiak <zby@cpan.org>
51              
52             =head1 COPYRIGHT AND LICENSE
53              
54             This software is copyright (c) 2010 by Zbigniew Lukasiak <zby@cpan.org>.
55              
56             This is free software; you can redistribute it and/or modify it under
57             the same terms as the Perl 5 programming language system itself.
58              
59             =cut
60              
61              
62             __END__
63              
64             # ABSTRACT: Tool for finding controller classes
65