Skip to content

Commit

Permalink
Allow "use lib CGI::Info::script_dir() . '../lib';"
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Jan 18, 2024
1 parent 6ca8c82 commit f45a147
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Revision history for CGI-Info
0.80
Added documentroot() as a synonym to rootdir()
For compatability with Apache
Allow "use lib CGI::Info::script_dir() . '../lib';"

0.79 Wed Jan 3 14:25:42 EST 2024
Better arg count checking
Expand Down
7 changes: 7 additions & 0 deletions lib/CGI/Info.pm
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,18 @@ Returns the file system directory containing the script.
print 'HTML files are normally stored in ', $info->script_dir(), '/', File::Spec->updir(), "\n";
# or
use lib CGI::Info::script_dir() . '../lib';
=cut

sub script_dir {
my $self = shift;

if(!ref($self)) {
$self = __PACKAGE__->new();
}

unless($self->{script_path}) {
$self->_find_paths();
}
Expand Down
3 changes: 2 additions & 1 deletion t/script.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use strict;
use warnings;
use Test::Most tests => 63;
use Test::Most tests => 64;
use File::Spec;
use Cwd;
use Test::NoWarnings;
Expand All @@ -22,6 +22,7 @@ PATHS: {
ok($i->script_path() =~ /.+script\.t$/);
ok($i->script_name() eq 'script.t');
ok($i->script_path() eq File::Spec->catfile($i->script_dir(), $i->script_name()));
ok($i->script_path() eq File::Spec->catfile(CGI::Info::script_dir(), $i->script_name()));
# Check calling twice return path
ok($i->script_name() eq 'script.t');

Expand Down

0 comments on commit f45a147

Please sign in to comment.