CC: | Mark Grimes <mgrimes [...] cpan.org> |
Subject: | [PATCH] Accept ~ in the directory name as a proxy for $HOME |
Date: | Fri, 9 Apr 2010 13:12:52 -0400 |
To: | bug-Dist-Zilla-PluginBundle-CJM [...] rt.cpan.org |
From: | Mark Grimes <mgrimes [...] cpan.org> |
Thanks for writing DZP::ArchiveRelease. I've found it very helpful.
This patch will check the supplied "directory" entry for a leading
tilde ("~"), and replace it with File::HomeDir->my_home. While you
can achieve the same outcome by specifying an absolute directory in
dist.ini, this is more portable.
I didn't write a test for this, as I didn't think it was appropriate
to have test write outside of the distributions directory. I guess a
test could be put into xt/author.
---
Makefile.PL | 3 ++-
lib/Dist/Zilla/Plugin/ArchiveRelease.pm | 10 +++++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/Makefile.PL b/Makefile.PL
index 2bb40db..1a3455a 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -33,7 +33,8 @@ my %WriteMakefileArgs = (
'autodie' => '0',
'Pod::Loom' => '0',
'Path::Class' => '0',
- 'Moose' => '0.65'
+ 'Moose' => '0.65',
+ 'File::HomeDir' => '0.89',
},
'LICENSE' => 'perl'
);
diff --git a/lib/Dist/Zilla/Plugin/ArchiveRelease.pm b/lib/Dist/Zilla/Plugin/ArchiveRelease.pm
index eecbef1..bef2d58 100644
--- a/lib/Dist/Zilla/Plugin/ArchiveRelease.pm
+++ b/lib/Dist/Zilla/Plugin/ArchiveRelease.pm
@@ -43,7 +43,15 @@ sub directory
{
my $self = shift;
- Path::Class::dir($self->_directory)->absolute($self->zilla->root);
+ # Convert ~/... to /home/user/....
+ my $dir = $self->_directory;
+ if( $dir =~ m{^~[/\\:]} ){
+ require File::HomeDir;
+ $dir =~ s{~}{ File::HomeDir->my_home }xe;
+ }
+print "dir = $dir\n";
+
+ Path::Class::dir($dir)->absolute($self->zilla->root);
} # end get_directory
#---------------------------------------------------------------------
--
1.7.0.2