Shipwright
view release on metacpan or search on metacpan
lib/Shipwright/Util.pm view on Meta::CPAN
}
return;
}
=head2 PATHS
=head3 shipwright_root
Returns the root directory that Shipwright has been installed into.
Uses %INC to figure out where Shipwright.pm is.
=cut
sub shipwright_root {
unless ($SHIPWRIGHT_ROOT) {
my $dir = ( splitpath( $INC{"Shipwright.pm"} ) )[1];
$SHIPWRIGHT_ROOT = rel2abs($dir);
}
return ($SHIPWRIGHT_ROOT);
}
=head3 share_root
Returns the 'share' directory of the installed Shipwright module. This is
currently only used to store the initial files in project.
=cut
sub share_root {
unless ($SHARE_ROOT) {
my @root = splitdir( shipwright_root() );
if ( $root[-2] ne 'blib'
&& $root[-1] eq 'lib'
&& ( $^O !~ /MSWin/ || $root[-2] ne 'site' ) )
{
# so it's -Ilib in the Shipwright's source dir
$root[-1] = 'share';
}
else {
push @root, qw/auto share dist Shipwright/;
}
$SHARE_ROOT = catdir(@root);
}
return ($SHARE_ROOT);
}
=head3 user_home
return current user's home directory
=cut
sub user_home {
return $ENV{HOME} if $ENV{HOME};
my $home = eval { (getpwuid $<)[7] };
if ( $@ ) {
confess_or_die "can't find user's home, please set it by env HOME";
}
else {
return $home;
}
}
=head3 shipwright_user_root
the user's own shipwright root where we put internal files in.
it's ~/.shipwright by default.
it can be overwritten by $ENV{SHIPWRIGHT_USER_ROOT}
=cut
sub shipwright_user_root {
return $ENV{SHIPWRIGHT_USER_ROOT} || catdir( user_home, '.shipwright' );
}
1;
__END__
=head1 NAME
Shipwright::Util - Util
=head1 AUTHOR
sunnavy C<< <sunnavy@bestpractical.com> >>
=head1 LICENCE AND COPYRIGHT
Copyright 2007-2015 Best Practical Solutions.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
( run in 2.502 seconds using v1.01-cache-2.11-cpan-2398b32b56e )