Perl6-Pugs
view release on metacpan or search on metacpan
misc/sixpan/JIB/lib/JIB/Constants.pm view on Meta::CPAN
package JIB::Constants;
use strict;
use Package::Constants;
use File::Spec;
use Log::Message::Simple qw[:STD];
use vars qw[@EXPORT];
use base 'Exporter';
@EXPORT = Package::Constants->list( __PACKAGE__ );
sub constants { @EXPORT };
use constant IS_CODEREF => sub { ref $_[-1] eq 'CODE' };
use constant IS_FILE => sub { return 1 if -e $_[-1] };
use constant FILE_EXISTS => sub {
my $file = $_[-1];
return 1 if IS_FILE->($file);
local $Carp::CarpLevel =
$Carp::CarpLevel+2;
error(qq[File '$file' does not exist]);
return;
};
use constant FILE_READABLE => sub {
my $file = $_[-1];
return 1 if -e $file && -r _;
local $Carp::CarpLevel =
$Carp::CarpLevel+2;
error(qq[File '$file' is not readable ].
q[or does not exist]);
return;
};
use constant IS_DIR => sub { return 1 if -d $_[-1] };
use constant DIR_EXISTS => sub {
my $dir = $_[-1];
return 1 if IS_DIR->($dir);
local $Carp::CarpLevel =
$Carp::CarpLevel+2;
error(q[Dir '$dir' does not exist]);
return;
};
use constant OPEN_FILE => sub {
my($file, $mode) = (@_, '');
my $fh;
open $fh, "$mode" . $file
or error(
"Could not open file '$file': $!");
return $fh if $fh;
return;
};
use constant ISA_JIB_META => sub { UNIVERSAL::isa(shift(), 'JIB::Meta') };
use constant ISA_JIB_CONFIG => sub { UNIVERSAL::isa(shift(), 'JIB::Config') };
use constant ISA_JIB_REPOSITORY
=> sub { UNIVERSAL::isa(shift(),
'JIB::Repository') };
use constant ISA_JIB_INSTALLATION
=> sub { UNIVERSAL::isa(shift(),
'JIB::Installation') };
( run in 0.853 second using v1.01-cache-2.11-cpan-9581c071862 )