Author: ericwilhelm
Date: Sat Feb 16 22:26:53 2008
New Revision: 10760
Modified:
Module-Build/trunk/t/lib/DistGen.pm
Log:
t/lib/DistGen.pm - added chdir_in() and chdir_original()
Modified: Module-Build/trunk/t/lib/DistGen.pm
==============================================================================
--- Module-Build/trunk/t/lib/DistGen.pm (original)
+++ Module-Build/trunk/t/lib/DistGen.pm Sat Feb 16 22:26:53 2008
@@ -411,6 +411,24 @@
$self->{pending}{change}{$file} = 1;
}
+sub chdir_in {
+ my $self = shift;
+
+ $self->{original_dir} ||= Cwd::cwd; # only once
+ my $dir = $self->dirname;
+ chdir($dir) or die "Can't chdir to '$dir': $!";
+} # end subroutine chdir_in definition
+########################################################################
+
+sub chdir_original {
+ my $self = shift;
+
+ croak("never called chdir_in()") unless($self->{original_dir});
+ my $dir = $self->{original_dir};
+ chdir($dir) or die "Can't chdir to '$dir': $!";
+} # end subroutine chdir_original definition
+########################################################################
+
1;
__END__
@@ -488,6 +506,19 @@
If the optional C<clean> argument is given, it also removes any
extraneous files that do not belong to the distribution.
+=head2 chdir_in
+
+Change directory into the dist root.
+
+ $dist->chdir_in;
+
+=head2 chdir_original
+
+Returns to whatever directory you were in before chdir_in() (regardless
+of the cwd.)
+
+ $dist->chdir_original;
+
=head3 clean()
Removes any files that are not part of the distribution.