Skip to content

Commit

Permalink
mention File::Temp too
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 8, 2017
1 parent 07799e5 commit 367e353
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/Mojo/File.pm
Expand Up @@ -134,6 +134,7 @@ Mojo::File - File system paths
use Mojo::File;
# Portably deal with file system paths
my $path = Mojo::File->new('/home/sri/.vimrc');
say $path->slurp;
say $path->basename;
Expand Down Expand Up @@ -163,6 +164,7 @@ individually.
my $path = path;
my $path = path('/home/sri/.vimrc');
my $path = path('/home', 'sri', '.vimrc');
my $path = path(File::Temp->newdir);

This comment has been minimized.

Copy link
@s1037989

s1037989 Jan 8, 2017

Contributor

Can File::Temp be a part of Mojo::File?

This comment has been minimized.

Copy link
@kraih

kraih Jan 8, 2017

Author Member

See next function below.

This comment has been minimized.

Copy link
@s1037989

s1037989 Jan 8, 2017

Contributor

Ah, darn it! That's twice you've had to do that now. I blame this collapsed view of Github! 😄 I knew there was a good reason for this...

Construct a new scalar-based L<Mojo::File> object, defaults to using the current
working directory.
Expand Down Expand Up @@ -295,6 +297,7 @@ Move the file.
my $path = Mojo::File->new;
my $path = Mojo::File->new('/home/sri/.vimrc');
my $path = Mojo::File->new('/home', 'sri', '.vimrc');
my $path = Mojo::File->new(File::Temp->newdir);
Construct a new L<Mojo::File> object, defaults to using the current working
directory.
Expand Down
8 changes: 8 additions & 0 deletions t/mojo/file.t
Expand Up @@ -4,6 +4,7 @@ use Test::More;
use Cwd qw(abs_path getcwd);
use File::Basename qw(basename dirname);
use File::Spec::Functions qw(abs2rel catfile splitdir);
use File::Temp;
use Mojo::File qw(path tempdir);

# Constructor
Expand Down Expand Up @@ -56,6 +57,13 @@ $dir = tempdir 'mytestXXXXX';
ok -d $dir, 'directory exists';
like $dir->basename, qr/mytest.{5}$/, 'right format';

# Temporary diectory (separate object)
$dir = Mojo::File->new(File::Temp->newdir);
$path = "$dir";
ok -d $path, 'directory exists';
undef $dir;
ok !-d $path, 'directory does not exist anymore';

# Make path
$dir = tempdir;
my $subdir = $dir->child('foo', 'bar');
Expand Down

0 comments on commit 367e353

Please sign in to comment.