code cleanup to WebGUI::Paths

This commit is contained in:
Graham Knop 2010-03-18 15:23:05 -05:00
parent 6cbdc3272c
commit a484fb126d
2 changed files with 19 additions and 8 deletions

View file

@ -103,13 +103,15 @@ sub preloadPaths {
my $class = shift; my $class = shift;
my @paths; my @paths;
try { try {
@paths = grep { for my $path ( _readTextLines($class->preloadCustom) ) {
(-d) ? 1 : do { if (-d $path) {
warn "WARNING: Not adding lib directory '$_' from " push @paths, $path;
. $class->preloadCustom . ": Directory does not exist.\n";
0;
} }
} _readTextLines($class->preloadCustom); else {
warn "WARNING: Not adding lib directory '$path' from "
. $class->preloadCustom . ": Directory does not exist.\n";
}
}
}; };
return @paths; return @paths;
} }

View file

@ -2,10 +2,10 @@ use 5.010;
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 3; use Test::More;
use WebGUI::Paths; use WebGUI::Paths;
can_ok 'WebGUI::Paths', qw( my @pathMethods = qw(
configBase configBase
logConfig logConfig
spectreConfig spectreConfig
@ -17,6 +17,8 @@ can_ok 'WebGUI::Paths', qw(
defaultCreateSQL defaultCreateSQL
var var
); );
can_ok 'WebGUI::Paths', @pathMethods;
ok !(grep { WebGUI::Paths->can($_) } qw( ok !(grep { WebGUI::Paths->can($_) } qw(
croak croak
realpath realpath
@ -35,3 +37,10 @@ ok !(grep { WebGUI::Paths->can($_) } qw(
my @configs = WebGUI::Paths->siteConfigs; my @configs = WebGUI::Paths->siteConfigs;
ok !(\@configs ~~ WebGUI::Paths->spectreConfig), 'Spectre config not listed in configs'; ok !(\@configs ~~ WebGUI::Paths->spectreConfig), 'Spectre config not listed in configs';
for my $method (@pathMethods) {
my $return = WebGUI::Paths->$method;
ok $return, "$method returns a path";
}
done_testing;