Hi Ken,
I noticed some traffic in the commits and realized I had this stale
patch laying around.
I see there are still quite a few chdir()s in the test suite and thought
this might be a good way to keep things a little more organized.
I think I just hadn't checked it in because the method names are so
corny (but maybe I just hadn't had a chance to really test it yet.)
--Eric
--
"Beware of bugs in the above code; I have only proved it correct, not
tried it."
--Donald Knuth
---------------------------------------------------
http://scratchcomputing.com
---------------------------------------------------
Index: t/lib/DistGen.pm
===================================================================
--- t/lib/DistGen.pm (revision 10263)
+++ t/lib/DistGen.pm (working copy)
@@ -416,6 +416,26 @@
$self->{pending}{change}{$file} = 1;
}
+sub engage {
+ my $self = shift;
+
+ $self->{original_dir} ||= Cwd::cwd; # only once
+ my $dir = $self->dirname;
+ chdir($dir) or die "Can't chdir to '$dir': $!";
+ $self->{engaged} = 1;
+} # end subroutine engage definition
+########################################################################
+
+sub exodus {
+ my $self = shift;
+
+ croak("not engaged") unless($self->{engaged});
+ my $dir = $self->{original_dir};
+ chdir($dir) or die "Can't chdir to '$dir': $!";
+ $self->{engaged} = 0;
+} # end subroutine exodus definition
+########################################################################
+
1;
__END__
@@ -493,6 +513,20 @@
If the optional C<clean> argument is given, it also removes any
extraneous files that do not belong to the distribution.
+=head2 engage
+
+Change directory into the dist root. This also activates automatic
+chdir for regen().
+
+ $dist->engage;
+
+=head2 exodus
+
+Flee the dist root (returns to your original chdir regardless of the
+cwd.)
+
+ $dist->exodus;
+
=head3 clean()
Removes any files that are not part of the distribution.