Allow file globbing in preload.exclude
This commit is contained in:
parent
7c240127e8
commit
1db4a7f916
3 changed files with 34 additions and 4 deletions
|
|
@ -18,6 +18,7 @@
|
|||
- fixed #11228: Gallery image upload to other users folder permission denied
|
||||
- added USPS International driver.
|
||||
- added #10727: language choice during site adding
|
||||
- added file globbing to preload.exclude
|
||||
|
||||
7.8.4
|
||||
- Fixed a compatibility problem between WRE and new Spectre code.
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ These functions are available from this package:
|
|||
Return an array of all the modules in the given namespace. Will search all
|
||||
@INC directories. C<options> is a hashref of options with the following keys
|
||||
|
||||
exclude => An arrayref of modules to exclude
|
||||
exclude => An arrayref of modules to exclude. A module name can include an asterisk to glob.
|
||||
onelevel => If true, only find sub modules (children), no deeper
|
||||
find( "CGI", { onelevel => 1 } ) would match "CGI::Session" but
|
||||
not "CGI::Session::File"
|
||||
|
|
@ -110,6 +110,12 @@ sub find {
|
|||
@modulesHash{ @modules } = ( 1 ) x @modules;
|
||||
delete @modulesHash{ @{ $options->{exclude} } };
|
||||
@modules = keys %modulesHash;
|
||||
my @excludePatterns = map { s/(?<!\.)\*/.*/g; $_; } grep { /\*/ } @modules;
|
||||
if (@excludePatterns) {
|
||||
my $pattern = join q{|}, @excludePatterns;
|
||||
my $exclusions = qr/$pattern/;
|
||||
@modules = grep { ! m/$exclusions/ } @modules;
|
||||
}
|
||||
}
|
||||
|
||||
### Return valu
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ use WebGUI::Pluggable;
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 8; # Increment this number for each test you create
|
||||
plan tests => 11; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
|
@ -82,7 +82,7 @@ is($dumper->Dump, q|$VAR1 = {
|
|||
},
|
||||
File::Spec->catfile( $lib, 'WebGUI', 'i18n' ),
|
||||
);
|
||||
|
||||
|
||||
cmp_deeply(
|
||||
[ WebGUI::Pluggable::find( 'WebGUI::i18n' ) ],
|
||||
bag( @testFiles ),
|
||||
|
|
@ -100,7 +100,30 @@ is($dumper->Dump, q|$VAR1 = {
|
|||
bag( grep { $_ ne 'WebGUI::i18n::English::WebGUI' } @testFiles ),
|
||||
"find() with exclude",
|
||||
);
|
||||
|
||||
|
||||
cmp_deeply(
|
||||
[ WebGUI::Pluggable::find( 'WebGUI::i18n', { exclude => [ 'WebGUI::i18n::English::WebGUI*' ] } ) ],
|
||||
bag( grep { $_ ne 'WebGUI::i18n::English::WebGUI' || $_ ne 'WebGUI::i18n::English::WebGUIProfile' } @testFiles ),
|
||||
"find() with exclude with glob",
|
||||
);
|
||||
|
||||
cmp_deeply(
|
||||
[ WebGUI::Pluggable::find( 'WebGUI::i18n', { exclude => [ 'WebGUI::i18n::English::WebGUI.*' ] } ) ],
|
||||
bag( grep { $_ ne 'WebGUI::i18n::English::WebGUI' || $_ ne 'WebGUI::i18n::English::WebGUIProfile' } @testFiles ),
|
||||
"find() with exclude with regex",
|
||||
);
|
||||
|
||||
cmp_deeply(
|
||||
[ WebGUI::Pluggable::find( 'WebGUI::i18n', { exclude => [ qw/WebGUI::i18n::English::WebGUI.* WebGUI::i18n::English::ShipDriver_USPS*/ ] } ) ],
|
||||
bag( grep {
|
||||
$_ ne 'WebGUI::i18n::English::WebGUI'
|
||||
|| $_ ne 'WebGUI::i18n::English::WebGUIProfile'
|
||||
|| $_ ne 'WebGUI::i18n::English::ShipDriver_USPS'
|
||||
|| $_ ne 'WebGUI::i18n::English::ShipDriver_USPSInternational'
|
||||
} @testFiles ),
|
||||
"find() with multiple excludes",
|
||||
);
|
||||
|
||||
cmp_deeply(
|
||||
[ WebGUI::Pluggable::find( 'WebGUI::i18n', { onelevel => 1, return => "name" } ) ],
|
||||
bag( map { /::([^:]+)$/; $1 } grep { /^WebGUI::i18n::[^:]+$/ } @testFiles ),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue