Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix Windows bugs in Mojo::File (closes #1030)
  • Loading branch information
kraih committed Jan 10, 2017
1 parent 5a5639a commit d69f603
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,5 +1,6 @@

7.16 2017-01-10
- Fixed Windows bugs in Mojo::File. (kmx)

7.15 2017-01-09
- Deprecated Mojo::ByteStream::slurp and Mojo::Util::slurp in favor of
Expand Down
7 changes: 4 additions & 3 deletions lib/Mojo/File.pm
Expand Up @@ -7,13 +7,14 @@ use overload
fallback => 1;

use Carp 'croak';
use Cwd qw(abs_path getcwd);
use Cwd 'getcwd';
use Exporter 'import';
use File::Basename ();
use File::Copy ();
use File::Find ();
use File::Path ();
use File::Spec::Functions qw(abs2rel catfile file_name_is_absolute splitdir);
use File::Spec::Functions
qw(abs2rel catfile file_name_is_absolute rel2abs splitdir);
use File::Temp ();
use Mojo::Collection;

Expand Down Expand Up @@ -100,7 +101,7 @@ sub tap { shift->Mojo::Base::tap(@_) }

sub tempdir { __PACKAGE__->new(File::Temp->newdir(@_)) }

sub to_abs { $_[0]->new(abs_path ${$_[0]}) }
sub to_abs { $_[0]->new(rel2abs ${$_[0]}) }

sub to_array { [splitdir ${shift()}] }

Expand Down
14 changes: 7 additions & 7 deletions t/mojo/file.t
@@ -1,9 +1,9 @@
use Mojo::Base -strict;

use Test::More;
use Cwd qw(abs_path getcwd);
use Cwd 'getcwd';
use File::Basename qw(basename dirname);
use File::Spec::Functions qw(abs2rel catfile splitdir);
use File::Spec::Functions qw(abs2rel catfile rel2abs splitdir);
use File::Temp;
use Mojo::File qw(path tempdir);

Expand All @@ -29,19 +29,19 @@ is_deeply [@{path('foo', 'bar')}], [splitdir catfile('foo', 'bar')],
'same structure';

# Absolute
is path('file.t')->to_abs, abs_path('file.t'), 'same path';
is path('file.t')->to_abs, rel2abs('file.t'), 'same path';

# Relative
is path('test.txt')->to_abs->to_rel(getcwd),
abs2rel(abs_path('test.txt'), getcwd), 'same path';
abs2rel(rel2abs('test.txt'), getcwd), 'same path';

# Basename
is path('file.t')->to_abs->basename, basename(abs_path 'file.t'), 'same path';
is path('file.t')->to_abs->basename('.t'), basename(abs_path('file.t'), '.t'),
is path('file.t')->to_abs->basename, basename(rel2abs 'file.t'), 'same path';
is path('file.t')->to_abs->basename('.t'), basename(rel2abs('file.t'), '.t'),
'same path';

# Dirname
is path('file.t')->to_abs->dirname, dirname(abs_path 'file.t'), 'same path';
is path('file.t')->to_abs->dirname, dirname(rel2abs 'file.t'), 'same path';

# Checks
ok path(__FILE__)->to_abs->is_abs, 'path is absolute';
Expand Down

0 comments on commit d69f603

Please sign in to comment.