| 1 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | package WebNano::FindController; | ||||||||||
| 5 | 5 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 5 | $WebNano::FindController::VERSION = '0.007'; | |||||||||
| 7 | } | ||||||||||
| 8 | |||||||||||
| 9 | 5 | ▶ | use Exporter 'import'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 5 | our @EXPORT_OK = qw(find_nested); | |||||||||
| 11 | |||||||||||
| 12 | 5 | ▶ | use Class::Load 'try_load_class'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 77 | ▶ | sub find_nested { | ||||||||
|
Subroutine
find_nested: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||
| 15 | 77 | my( $sub_path, $search_path ) = @_; | |||||||||
| 16 | 77 | ▶ | return if $sub_path =~ /\./; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 77 | $sub_path =~ s{/}{::}g; | |||||||||
| 18 | 77 | my @path = @$search_path; | |||||||||
| 19 | 77 | for my $base ( @path ){ | |||||||||
| 20 | 109 | my $controller_class = $base . '::Controller' . $sub_path; | |||||||||
| 21 | 109 | ▶ | if( ! try_load_class( $controller_class ) ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 36 | my $file = $controller_class; | |||||||||
| 23 | 36 | $file =~ s{::}{/}g; | |||||||||
| 24 | 36 | $file .= '.pm'; | |||||||||
| 25 | 36 | ▶ | if( $Class::Load::ERROR !~ /Can't locate \Q$file\E in \@INC/ ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 1 | die $Class::Load::ERROR; | |||||||||
| 27 | } | ||||||||||
| 28 | }; | ||||||||||
| 29 | 108 | ▶ | return $controller_class if $controller_class->isa( 'WebNano::Controller' ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | } | ||||||||||
| 31 | 5 | return; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 5 | 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 <zby@cpan.org> | ||||||||||
| 53 | |||||||||||
| 54 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 55 | |||||||||||
| 56 | This software is Copyright (c) 2010 by Zbigniew Lukasiak <zby@cpan.org>. | ||||||||||
| 57 | |||||||||||
| 58 | This is free software, licensed under: | ||||||||||
| 59 | |||||||||||
| 60 | The Artistic License 2.0 (GPL Compatible) | ||||||||||
| 61 | |||||||||||
| 62 | =cut | ||||||||||
| 63 | |||||||||||
| 64 | |||||||||||
| 65 | __END__ | ||||||||||