added "return => name" to WebGUI::Pluggable::find
This commit is contained in:
parent
314035912d
commit
4b120ad17c
2 changed files with 14 additions and 2 deletions
|
|
@ -70,6 +70,7 @@ Return an array of all the modules in the given namespace. Will search all
|
|||
onelevel => If true, only find sub modules (children), no deeper
|
||||
find( "CGI", { onelevel => 1 } ) would match "CGI::Session" but
|
||||
not "CGI::Session::File"
|
||||
return => "name" - Return just the last part of the package, so CGI::Session would return "Session"
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -111,6 +112,12 @@ sub find {
|
|||
@modules = keys %modulesHash;
|
||||
}
|
||||
|
||||
### Return valu
|
||||
# If "name", just grab the last part
|
||||
if ( $options->{ return } eq "name" ) {
|
||||
@modules = map { /::([^:]+)$/; $1 } @modules;
|
||||
}
|
||||
|
||||
return @modules;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ use WebGUI::Pluggable;
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 7; # Increment this number for each test you create
|
||||
plan tests => 8; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
|
@ -100,7 +100,12 @@ is($dumper->Dump, q|$VAR1 = {
|
|||
bag( grep { $_ ne 'WebGUI::i18n::English::WebGUI' } @testFiles ),
|
||||
"find() with exclude",
|
||||
);
|
||||
|
||||
|
||||
cmp_deeply(
|
||||
[ WebGUI::Pluggable::find( 'WebGUI::i18n', { onelevel => 1, return => "name" } ) ],
|
||||
bag( map { /::([^:]+)$/; $1 } grep { /^WebGUI::i18n::[^:]+$/ } @testFiles ),
|
||||
"find() with return => name",
|
||||
);
|
||||
};
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue