Badger
view release on metacpan or search on metacpan
lib/Badger/Utils.pm view on Meta::CPAN
map {
my $name = $_; # e.g. Scalar::Util
my $file = module_file($name); # e.g. Scalar/Util.pm
map { $_ => [$name, $file, 0] } # third item is loaded flag
split(DELIMITER, $helpers->{ $name })
}
keys %$helpers
}
}
sub is_object($$) {
blessed $_[1] && $_[1]->isa($_[0]);
}
sub textlike($) {
! ref $_[0] # check if $[0] is a non-reference
|| blessed $_[0] # or an object with an overloaded
&& overload::Method($_[0], '""'); # '""' stringification operator
}
sub truelike($) {
falselike($_[0]) ? FALSE : TRUE;
}
sub falselike($) {
(! $_[0] || $_[0] =~ /^(0|off|no|none|false)$/i) ? TRUE : FALSE;
}
sub params {
# enable $DEBUG to track down calls to params() that pass an odd number
# of arguments, typically when the rhs argument returns an empty list,
# e.g. $obj->foo( x => this_returns_empty_list() )
my @args = @_;
local $SIG{__WARN__} = sub {
odd_params(@args);
t/filesystem/directory.t view on Meta::CPAN
our $DIR = 'Badger::Filesystem::Directory';
our $FS = 'Badger::Filesystem';
our $TDIR = -d 't' ? $FS->join_dir(qw(t filesystem)) : $FS->directory;
# ugly hack to grok file separator on local filesystem
my $PATHSEP = File::Spec->catdir(('badger') x 2);
$PATHSEP =~ s/badger//g;
# convert unix-like paths into local equivalent
sub lp($) {
my $path = shift;
$path =~ s|/|$PATHSEP|g;
$path;
}
my $dir = $DIR->new('example');
ok( $dir, 'created a new directory' );
is( $dir->name, 'example', 'got example name' );
ok( ! $dir->volume, 'got (no) file volume' );
t/filesystem/filesystem.t view on Meta::CPAN
debug => 'Badger::Filesystem',
args => \@ARGV;
our $TDIR = -d 't' ? FS->join_dir(qw(t filesystem)) : FS->directory;
# ugly hack to grok file separator on local filesystem
my $PATHSEP = File::Spec->catdir(('badger') x 2);
$PATHSEP =~ s/badger//g;
# convert unix-like paths into local equivalent
sub lp($) {
my $path = shift;
$path =~ s|/|$PATHSEP|g;
$path;
}
#-----------------------------------------------------------------------
# test $Bin from FindBin, and Bin() as directory wrapper around it
#-----------------------------------------------------------------------
t/filesystem/path.t view on Meta::CPAN
our $PATH = 'Badger::Filesystem::Path';
our $FS = $PATH->filesystem;
our $CWD = $FS->cwd;
my ($path, $sub);
# ugly hack to grok file separator on local filesystem
my $PATHSEP = File::Spec->catdir(('badger') x 2);
$PATHSEP =~ s/badger//g;
# convert unix-like paths into local equivalent
sub lp($) {
my $path = shift;
$path =~ s|/|$PATHSEP|g;
$path;
}
$path = $PATH->new('foo');
ok( $path, 'created a new file: foo' );
ok( $path->is_relative, 'foo is relative' );
ok( ! $path->is_absolute, 'foo is not absolute' );
is( $path->absolute, $FS->join_dir($CWD, 'foo'), 'foo absolute is ' . $path->absolute );
t/filesystem/virtual.t view on Meta::CPAN
debug => 'Badger::Filesystem::X Badger::Filesystem::Virtual',
args => \@ARGV;
use Badger::Filesystem 'FS';
use Badger::Filesystem::Virtual 'VFS';
# ugly hack to grok file separator on local filesystem
my $PATHSEP = File::Spec->catdir(('badger') x 2);
$PATHSEP =~ s/badger//g;
# convert unix-like paths into local equivalent
sub lp($) {
my $path = shift;
$path =~ s|/|$PATHSEP|g;
$path;
}
#-----------------------------------------------------------------------
# figure out where the t/filesystem/testfiles directory, depending on
# where this script is being run from.
#-----------------------------------------------------------------------
( run in 0.743 second using v1.01-cache-2.11-cpan-65fba6d93b7 )