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.037;
2             # ABSTRACT: a helper to get Path::Tiny objects
3              
4 52     52   111658 use Dist::Zilla::Pragmas;
  52         109  
  52         494  
5              
6 52     52   410 use parent 'Path::Tiny';
  52         131  
  52         437  
7              
8 52     52   46610 use Path::Tiny 0.052 qw(); # issue 427
  52         1159  
  52         1678  
9 52     52   312 use Scalar::Util qw( blessed );
  52         112  
  52         5056  
10 52         1054 use Sub::Exporter -setup => {
11             exports => [ qw( path ) ],
12             groups => { default => [ qw( path ) ] },
13 52     52   959 };
  52         9542  
14              
15 52     52   35054 use namespace::autoclean -except => 'import';
  52         15379  
  52         629  
16              
17             sub path {
18 4008     4008 1 55879 my ($thing, @rest) = @_;
19              
20 4008 100 100     20763 if (@rest == 0 && blessed $thing) {
21 1763 100       15439 return $thing if $thing->isa(__PACKAGE__);
22              
23 967 100 66     12054 return bless(Path::Tiny::path("$thing"), __PACKAGE__)
24             if $thing->isa('Path::Class::Entity') || $thing->isa('Path::Tiny');
25             }
26              
27 2412         8803 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.037
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
73             released in the last two to three years. (That is, if the most recently
74             released version is v5.40, then this module should work on both v5.40 and
75             v5.38.)
76              
77             Although it may work on older versions of perl, no guarantee is made that the
78             minimum required version will not be increased. The version may be increased
79             for any reason, and there is no promise that patches will be accepted to
80             lower the minimum required perl.
81              
82             =head1 AUTHOR
83              
84             Ricardo SIGNES 😏 <cpan@semiotic.systems>
85              
86             =head1 COPYRIGHT AND LICENSE
87              
88             This software is copyright (c) 2026 by Ricardo SIGNES.
89              
90             This is free software; you can redistribute it and/or modify it under
91             the same terms as the Perl 5 programming language system itself.
92              
93             =cut