File Coverage

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


line stmt bran cond sub pod time code
1 5     5   27 use strict;
  5         8  
  5         149  
2 5     5   21 use warnings;
  5         11  
  5         193  
3              
4             package WebNano::FindController;
5             BEGIN {
6 5     5   79 $WebNano::FindController::VERSION = '0.007';
7             }
8              
9 5     5   23 use Exporter 'import';
  5         9  
  5         245  
10             our @EXPORT_OK = qw(find_nested);
11              
12 5     5   3997 use Class::Load 'try_load_class';
  5         175785  
  5         1334  
13              
14             sub find_nested {
15 77     77 1 304 my( $sub_path, $search_path ) = @_;
16 77 50       206 return if $sub_path =~ /\./;
17 77         209 $sub_path =~ s{/}{::}g;
18 77         149 my @path = @$search_path;
19 77         115 for my $base ( @path ){
20 109         219 my $controller_class = $base . '::Controller' . $sub_path;
21 109 100       258 if( ! try_load_class( $controller_class ) ){
22 36         17276 my $file = $controller_class;
23 36         109 $file =~ s{::}{/}g;
24 36         51 $file .= '.pm';
25 36 100       548 if( $Class::Load::ERROR !~ /Can't locate \Q$file\E in \@INC/ ){
26 1         13 die $Class::Load::ERROR;
27             }
28             };
29 108 100       20166 return $controller_class if $controller_class->isa( 'WebNano::Controller' );
30             }
31 5         17 return;
32             }
33              
34             1;
35              
36              
37              
38             =pod
39              
40             =head1 NAME
41              
42             WebNano::FindController - Tool for finding controller classes
43              
44             =head1 VERSION
45              
46             version 0.007
47              
48             =head2 find_nested
49              
50             =head1 AUTHOR
51              
52             Zbigniew Lukasiak
53              
54             =head1 COPYRIGHT AND LICENSE
55              
56             This software is Copyright (c) 2010 by Zbigniew Lukasiak .
57              
58             This is free software, licensed under:
59              
60             The Artistic License 2.0 (GPL Compatible)
61              
62             =cut
63              
64              
65             __END__