File Coverage

blib/lib/Dist/Zilla/Path.pm
Criterion Covered Total %
statement 23 34 67.6
branch 6 8 75.0
condition 5 6 83.3
subroutine 7 9 77.7
pod 1 3 33.3
total 42 60 70.0


line stmt bran cond sub pod time code
1             package Dist::Zilla::Path 6.029;
2             # ABSTRACT: a helper to get Path::Tiny objects
3              
4 52     52   126006 use Dist::Zilla::Pragmas;
  52         154  
  52         2382  
5              
6 52     52   409 use parent 'Path::Tiny';
  52         134  
  52         317  
7              
8 52     52   46650 use Path::Tiny 0.052 qw(); # issue 427
  52         1191  
  52         1457  
9 52     52   365 use Scalar::Util qw( blessed );
  52         190  
  52         4703  
10 52         2235 use Sub::Exporter -setup => {
11             exports => [ qw( path ) ],
12             groups => { default => [ qw( path ) ] },
13 52     52   1120 };
  52         11647  
14              
15 52     52   36258 use namespace::autoclean -except => 'import';
  52         18130  
  52         2587  
16              
17             sub path {
18 3926     3926 1 54579 my ($thing, @rest) = @_;
19              
20 3926 100 100     23608 if (@rest == 0 && blessed $thing) {
21 1681 100       15215 return $thing if $thing->isa(__PACKAGE__);
22              
23 885 100 66     10524 return bless(Path::Tiny::path("$thing"), __PACKAGE__)
24             if $thing->isa('Path::Class::Entity') || $thing->isa('Path::Tiny');
25             }
26              
27 2412         8705 return bless(Path::Tiny::path($thing, @rest), __PACKAGE__);
28             }
29              
30             my %warned;
31              
32             sub file {
33 0     0 0   my ($self, @file) = @_;
34              
35 0           my ($package, $pmfile, $line) = caller;
36              
37 0           my $key = join qq{\0}, $pmfile, $line;
38 0 0         unless ($warned{ $key }++) {
39 0           Carp::carp("->file called on a Dist::Zilla::Path object; this will cease to work in Dist::Zilla v7; downstream code should be updated to use Path::Tiny API, not Path::Class");
40             }
41              
42 0           require Path::Class;
43 0           Path::Class::dir($self)->file(@file);
44             }
45              
46             sub subdir {
47 0     0 0   my ($self, @subdir) = @_;
48 0           Carp::carp("->subdir called on a Dist::Zilla::Path object; this will cease to work in Dist::Zilla v7; downstream code should be updated to use Path::Tiny API, not Path::Class");
49 0           require Path::Class;
50 0           Path::Class::dir($self)->subdir(@subdir);
51             }
52              
53             1;
54              
55             __END__
56              
57             =pod
58              
59             =encoding UTF-8
60              
61             =head1 NAME
62              
63             Dist::Zilla::Path - a helper to get Path::Tiny objects
64              
65             =head1 VERSION
66              
67             version 6.029
68              
69             =head1 PERL VERSION
70              
71             This module should work on any version of perl still receiving updates from
72             the Perl 5 Porters. This means it should work on any version of perl released
73             in the last two to three years. (That is, if the most recently released
74             version is v5.40, then this module should work on both v5.40 and v5.38.)
75              
76             Although it may work on older versions of perl, no guarantee is made that the
77             minimum required version will not be increased. The version may be increased
78             for any reason, and there is no promise that patches will be accepted to lower
79             the minimum required perl.
80              
81             =head1 AUTHOR
82              
83             Ricardo SIGNES 😏 <cpan@semiotic.systems>
84              
85             =head1 COPYRIGHT AND LICENSE
86              
87             This software is copyright (c) 2022 by Ricardo SIGNES.
88              
89             This is free software; you can redistribute it and/or modify it under
90             the same terms as the Perl 5 programming language system itself.
91              
92             =cut