Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Path-Class CPAN distribution.

Maintainer(s)' notes

I prefer that bugs & patches are filed on GitHub rather than on RT: https://github.com/kenahoo/Path-Class/issues. Thanks.

Report information
The Basics
Id: 53035
Status: open
Priority: 0/
Queue: Path-Class

People
Owner: Nobody in particular
Requestors: schwern [...] pobox.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: basename() should return a Path::Class object
Date: Wed, 23 Dec 2009 17:39:42 -0800
To: bug-Path-Class [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
Download (untitled) / with headers
text/plain 430b
use Path::Class; my $file = file("/foo/bar/baz")->basename; $file->relative("/new/dir"); I was surprised to find that $file was not a Path::Class object. This breaks the magic of Path::Class, which is to have ubiquitous file and directory objects without having to convert strings. I haven't investigated, but other methods might have the same problem. -- package Outer::Space; use Test::More tests => 9;
Download (untitled) / with headers
text/plain 290b
If we did that, we'd need to create a new Path::Class class. It's not a File (because a File knows its directory). BTW, for your specific example, perhaps a rebase() method would be nice: use Path::Class; my $file = file("/foo/bar/baz"); $file->rebase("/new/dir");
Subject: Re: [rt.cpan.org #53035] basename() should return a Path::Class object
Date: Thu, 24 Dec 2009 13:26:53 -0800
To: bug-Path-Class [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
Download (untitled) / with headers
text/plain 1.2k
Ken Williams via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=53035 > > > If we did that, we'd need to create a new Path::Class class. It's not a File (because a File knows > its directory).
Its equivalent to ./file. In fact, it seems to work fine now. my $file = file("foo"); print $file; # foo print $file->dir; # . print $file; # foo (original representation maintained) This'll cover it. --- a/lib/Path/Class/File.pm +++ b/lib/Path/Class/File.pm @@ -54,7 +54,7 @@ sub volume { return $self->{dir}->volume; } -sub basename { shift->{file} } +sub basename { Path::Class::File->new(shift->{file}) } sub open { IO::File->new(@_) } sub openr { $_[0]->open('r') or die "Can't read $_[0]: $!" } I'm knocking up some tests to check that everything returns an object that could. Show quoted text
> BTW, for your specific example, perhaps a rebase() method would be nice: > > use Path::Class; > my $file = file("/foo/bar/baz"); > $file->rebase("/new/dir");
Consider me +0 on that. I don't know how generally useful it is. What if you want to move a subdir? -- You know what the chain of command is? It's the chain I go get and beat you with 'til you understand who's in ruttin' command here. -- Jayne Cobb, "Firefly"


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.