Subject: | basename method for dir objects |
Attached is the patch and tests to add "basename" method to dir objects. like basename(1), we
should have an easy way to get the information just like we can with file objects.
Subject: | path-class.patch |
Only in Path-Class-0.15.clkao: Makefile
Only in Path-Class-0.15.clkao: blib
diff -ru Path-Class-0.15/lib/Path/Class/Dir.pm Path-Class-0.15.clkao/lib/Path/Class/Dir.pm
--- Path-Class-0.15/lib/Path/Class/Dir.pm 2005-12-16 10:12:44.000000000 +0800
+++ Path-Class-0.15.clkao/lib/Path/Class/Dir.pm 2006-01-27 23:58:28.000000000 +0800
@@ -56,6 +56,8 @@
return Path::Class::File->new(@_);
}
+sub basename { shift()->{dirs}[-1] }
+
sub dir_list {
my $self = shift;
my $d = $self->{dirs};
Only in Path-Class-0.15.clkao: pm_to_blib
diff -ru Path-Class-0.15/t/01-basic.t Path-Class-0.15.clkao/t/01-basic.t
--- Path-Class-0.15/t/01-basic.t 2005-12-16 10:12:44.000000000 +0800
+++ Path-Class-0.15.clkao/t/01-basic.t 2006-01-27 23:58:58.000000000 +0800
@@ -7,7 +7,7 @@
use Path::Class;
use Cwd;
-plan tests => 65;
+plan tests => 67;
ok(1);
my $file1 = Path::Class::File->new('foo.txt');
@@ -25,6 +25,7 @@
my $dir = dir('tmp');
ok $dir, 'tmp';
ok $dir->is_absolute, '';
+ok $dir->basename, 'tmp';
my $dir2 = dir('/tmp');
ok $dir2, '/tmp';
@@ -47,6 +48,7 @@
$cat = $dir2->subdir('foo');
ok $cat, '/tmp/foo';
ok $cat->isa('Path::Class::Dir');
+ok $cat->basename, 'foo';
my $file = file('/foo//baz/./foo')->cleanup;
ok $file, '/foo/baz/foo';