rjbs/Dist-Zilla — pull request #277 by kentfredric (2014-02-02 16:23:22+00:00)
Title: No path class

I spent a bit of effort seeing if I could get this working.

Looks like I'm about 95% of the way there, just need a little buy-in from plugins. Though plugins _should_ work as-is due to the way I've done it, albeit with abundant superfluous warnings.

Test Suite passes tests with `PERL5OPT=-MDevel::Hide=Path::Class,Path::Class::File,Path::Class::Dir`.

Dzil also successfully builds with itself with the applied changes, and the only downside is copious lines of:

`file called on Dist::Zilla::Path. This is deprecated and will go away in a future release at /home/kent/perl5/perlbrew/perls/perl-5.19.8/lib/site_perl/5.19.8/Dist/Zilla/Plugin/PodWeaver.pm line 22`

Approach: I've made a somewhat self-propagating automatic dispatch thing.

- Everything that asks for a Path::Tiny method calls a Path::Tiny method, but the result is always a Dist::Zilla::Path if Path::Tiny returns a Path::Tiny
- Everything that asks for a Path::Class::* method calls a Path::Class::* method, but the result is always a Dist::Zilla::Path if Path::Class returns a Path::Class

The only real place it will go wrong is where people have MooseX::Types that ask for Path::Class objects and don't have coercions set up. ( I couldn't remember if I was possible or how to set up coercions for things you don't control, and `coerce => 1` is impossible to set on code you don't own as well ).

So for that reason, I wouldn't roll this out *just yet*, but its already of a grade of usefulness that people like myself can use it to track down where they've got Path::Class dependent logic in the DZil plugins.

I'm amazed how productive I can be when I'm **supposed** to be packing and moving house ... which is why I'm not on IRC =)

#### Note

There's a few things I'm not 100% sure I got right, relative path handling is always tricky.
And in testing, I found I needed `remove_tree({ safe => 0 })` for some reason. I don't quite understand why. The documentation for that parameter in File::Path says `safe => 0` will simply not try removing files you don't have permissions to remove, so we really shouldn't need it .... however, without it, it doesn't want to delete directories due to not being empty:

```
t/plugins/testrelease.t ......
ok 1 - No failures occured building the release with TestRelease
Generating a Unix-style Makefile
Writing Makefile for DZT::Sample
Writing MYMETA.yml and MYMETA.json
cp lib/DZT/Sample.pm blib/lib/DZT/Sample.pm
PERL_DL_NONLAZY=1 /home/kent/perl5/perlbrew/perls/perl-5.19.8/bin/perl5.19.8 "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/basic.t .. ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.02 cusr 0.00 csys = 0.04 CPU)
Result: PASS
cannot remove directory for /home/kent/perl/dist-zilla/tmp/vXQI9gmobg/source/.build/4a1ydD2ABX/DZT-Sample-0.001/blib/lib/DZT: Directory not empty at /home/kent/perl5/perlbrew/perls/perl-5.19.8/lib/site_perl/5.19.8/Path/Tiny.pm line 658.
cannot remove directory for /home/kent/perl/dist-zilla/tmp/vXQI9gmobg/source/.build/4a1ydD2ABX/DZT-Sample-0.001/blib/lib: Directory not empty at /home/kent/perl5/perlbrew/perls/perl-5.19.8/lib/site_perl/5.19.8/Path/Tiny.pm line 658.
cannot remove directory for /home/kent/perl/dist-zilla/tmp/vXQI9gmobg/source/.build/4a1ydD2ABX/DZT-Sample-0.001/blib: Directory not empty at /home/kent/perl5/perlbrew/perls/perl-5.19.8/lib/site_perl/5.19.8/Path/Tiny.pm line 658.
cannot remove directory for /home/kent/perl/dist-zilla/tmp/vXQI9gmobg/source/.build/4a1ydD2ABX/DZT-Sample-0.001: Directory not empty at /home/kent/perl5/perlbrew/perls/perl-5.19.8/lib/site_perl/5.19.8/Path/Tiny.pm line 658.
cannot remove directory for /home/kent/perl/dist-zilla/tmp/vXQI9gmobg/source/.build/4a1ydD2ABX: Directory not empty at /home/kent/perl5/perlbrew/perls/perl-5.19.8/lib/site_perl/5.19.8/Path/Tiny.pm line 658.
ok 2 - No failures occured in testing the release with TestRelease
# {
# 'root' => '/home/kent/perl/dist-zilla/tmp/vXQI9gmobg/source'
# }
ok 3 - Release happened
1..3
```

The docs:
```
safe => $bool
When set to a true value, will cause "remove_tree" to skip the
files for which the process lacks the required privileges needed
to delete files, such as delete privileges on VMS. In other words,
the code will make no attempt to alter file permissions. Thus, if
the process is interrupted, no filesystem object will be left in a
more permissive mode.
```

/cc @karenetheridge