Class-Usul
view release on metacpan or search on metacpan
lib/Class/Usul/Config.pm view on Meta::CPAN
return -d $dir ? $dir : untaint_path $Config{installsitescript};
}
sub _build_ctlfile {
my $name = $_[ 0 ]->inflate_symbol( $_[ 1 ], 'name' );
my $extension = $_[ 0 ]->inflate_symbol( $_[ 1 ], 'extension' );
return $_[ 0 ]->inflate_path( $_[ 1 ], 'ctrldir', $name.$extension );
}
sub _build_ctrldir {
my $dir = $_[ 0 ]->inflate_path( $_[ 1 ], 'vardir', 'etc' );
-d $dir and return $dir;
$dir = $_[ 0 ]->inflate_path( $_[ 1 ], 'appldir', 'etc' );
return -d $dir ? $dir : [ NUL, qw( usr local etc ) ];
}
sub _build_datadir {
my $dir = $_[ 0 ]->inflate_path( $_[ 1 ], 'vardir', 'data' );
return -d $dir ? $dir : $_[ 0 ]->inflate_path( $_[ 1 ], 'tempdir' );
}
sub _build_localedir {
my $dir = $_[ 0 ]->inflate_path( $_[ 1 ], 'vardir', 'locale' );
-d $dir and return $dir;
for (map { catdir( @{ $_ } ) } @{ LOCALE_DIRS() } ) { -d $_ and return $_ }
return $_[ 0 ]->inflate_path( $_[ 1 ], 'tempdir' );
}
sub _build_logfile {
my $name = $_[ 0 ]->inflate_symbol( $_[ 1 ], 'name' );
return $_[ 0 ]->inflate_path( $_[ 1 ], 'logsdir', "${name}.log" );
}
sub _build_logsdir {
my $dir = $_[ 0 ]->inflate_path( $_[ 1 ], 'vardir', 'logs' );
return -d $dir ? $dir : $_[ 0 ]->inflate_path( $_[ 1 ], 'tempdir' );
}
sub _build_name {
my $name = basename
( $_[ 0 ]->inflate_path( $_[ 1 ], 'pathname' ), PERL_EXTNS );
return (split_on__ $name, 1) || (split_on_dash $name, 1) || $name;
}
sub _build_pathname {
my $name = ('-' eq substr $PROGRAM_NAME, 0, 1) ? $EXECUTABLE_NAME
: $PROGRAM_NAME;
return rel2abs( (split m{ [ ][\-][ ] }mx, $name)[ 0 ] );
}
sub _build_phase {
my $verdir = basename( $_[ 0 ]->inflate_path( $_[ 1 ], 'appldir' ) );
my ($phase) = $verdir =~ m{ \A v \d+ \. \d+ p (\d+) \z }msx;
return defined $phase ? $phase : PHASE;
}
sub _build_prefix {
my $appclass = $_[ 0 ]->inflate_symbol( $_[ 1 ], 'appclass' );
return (split m{ :: }mx, lc $appclass)[ -1 ];
}
sub _build_root {
my $dir = $_[ 0 ]->inflate_path( $_[ 1 ], 'vardir', 'root' );
return -d $dir ? $dir : $_[ 0 ]->inflate_path( $_[ 1 ], 'tempdir' );
}
sub _build_rundir {
my $dir = $_[ 0 ]->inflate_path( $_[ 1 ], 'vardir', 'run' );
return -d $dir ? $dir : $_[ 0 ]->inflate_path( $_[ 1 ], 'tempdir' );
}
sub _build_sessdir {
my $dir = $_[ 0 ]->inflate_path( $_[ 1 ], 'vardir', 'session' );
return -d $dir ? $dir : $_[ 0 ]->inflate_path( $_[ 1 ], 'tempdir' );
}
sub _build_sharedir {
my $dir = $_[ 0 ]->inflate_path( $_[ 1 ], 'vardir', 'share' );
return -d $dir ? $dir : $_[ 0 ]->inflate_path( $_[ 1 ], 'tempdir' );
}
sub _build_shell {
my $file = $ENV{SHELL}; $file and -e $file and return $file;
$file = catfile( NUL, 'bin', 'ksh' ); -e $file and return $file;
$file = catfile( NUL, 'bin', 'bash' ); -e $file and return $file;
$file = which ( 'sh' ); $file and -e $file and return $file;
return catfile( NUL, 'bin', 'sh' );
}
sub _build_salt {
return untaint_cmdline $_[ 0 ]->inflate_symbol( $_[ 1 ], 'prefix' );
}
sub _build_suid {
my $prefix = $_[ 0 ]->inflate_symbol( $_[ 1 ], 'prefix' );
return $_[ 0 ]->inflate_path( $_[ 1 ], 'binsdir', "${prefix}-admin" );
}
sub _build_tempdir {
my $dir = $_[ 0 ]->inflate_path( $_[ 1 ], 'vardir', 'tmp' );
return -d $dir ? $dir : untaint_path tmpdir;
}
sub _build_vardir {
my $dir = $_[ 0 ]->inflate_path( $_[ 1 ], 'appldir', 'var' );
return -e $dir ? $dir : $_[ 0 ]->inflate_path( $_[ 1 ], 'appldir' );
}
# Public methods
sub inflate_path {
return canonicalise $_[ 0 ]->inflate_symbol( $_[ 1 ], $_[ 2 ] ), $_[ 3 ];
}
( run in 1.306 second using v1.01-cache-2.11-cpan-483215c6ad5 )