Skip to content

Commit

Permalink
add new tempdir function to Path::Class which returns new Path::Cla…
Browse files Browse the repository at this point in the history
…ss::Dir instance pointed to temporary directory.
  • Loading branch information
cho45 committed Jul 20, 2012
1 parent a3bf55c commit 3fd9fa7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/Path/Class.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ package Path::Class;
no strict 'vars';
@ISA = qw(Exporter);
@EXPORT = qw(file dir);
@EXPORT_OK = qw(file dir foreign_file foreign_dir);
@EXPORT_OK = qw(file dir foreign_file foreign_dir tempdir);
}

use Exporter;
use Path::Class::File;
use Path::Class::Dir;
use File::Temp ();

sub file { Path::Class::File->new(@_) }
sub dir { Path::Class::Dir ->new(@_) }
sub foreign_file { Path::Class::File->new_foreign(@_) }
sub foreign_dir { Path::Class::Dir ->new_foreign(@_) }
sub tempdir { Path::Class::Dir->new(File::Temp::tempdir(@_)) }


1;
Expand Down
10 changes: 9 additions & 1 deletion t/03-filesystem.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use Test::More;
use File::Temp qw(tmpnam tempdir);
use File::Spec;

plan tests => 79;
plan tests => 81;

use_ok 'Path::Class';

Expand Down Expand Up @@ -292,3 +292,11 @@ SKIP: {
return \%files;
}
}

{
$dir = Path::Class::tempdir();
isa_ok $dir, 'Path::Class::Dir';

$dir = Path::Class::tempdir(CLEANUP => 1);
isa_ok $dir, 'Path::Class::Dir';
};

0 comments on commit 3fd9fa7

Please sign in to comment.