lib/Analizo/Batch/Job/Directories.pm
raw| 1 | package Analizo::Batch::Job::Directories; |
| 2 | |
| 3 | use parent qw( Analizo::Batch::Job Class::Accessor::Fast ); |
| 4 | use Cwd; |
| 5 | |
| 6 | sub new { |
| 7 | my ($class, $directory) = @_; |
| 8 | $class->SUPER::new(id => $directory, directory => $directory); |
| 9 | } |
| 10 | |
| 11 | __PACKAGE__->mk_accessors(qw(oldcwd)); |
| 12 | |
| 13 | sub prepare { |
| 14 | my ($self) = @_; |
| 15 | $self->oldcwd(getcwd); |
| 16 | chdir($self->directory); |
| 17 | } |
| 18 | |
| 19 | sub cleanup { |
| 20 | my ($self) = @_; |
| 21 | chdir($self->oldcwd); |
| 22 | } |
| 23 | |
| 24 | 1; |