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             # ABSTRACT: a helper to get Path::Tiny objects
2              
3             use Dist::Zilla::Pragmas;
4 52     52   122949  
  52         123  
  52         551  
5             use parent 'Path::Tiny';
6 52     52   363  
  52         138  
  52         346  
7             use Path::Tiny 0.052 qw(); # issue 427
8 52     52   41961 use Scalar::Util qw( blessed );
  52         1135  
  52         1478  
9 52     52   345 use Sub::Exporter -setup => {
  52         137  
  52         4149  
10 52         2119 exports => [ qw( path ) ],
11             groups => { default => [ qw( path ) ] },
12             };
13 52     52   1045  
  52         11140  
14             use namespace::autoclean -except => 'import';
15 52     52   34485  
  52         17286  
  52         2384  
16             my ($thing, @rest) = @_;
17              
18 3863     3863 1 51272 if (@rest == 0 && blessed $thing) {
19             return $thing if $thing->isa(__PACKAGE__);
20 3863 100 100     23010  
21 1652 100       14640 return bless(Path::Tiny::path("$thing"), __PACKAGE__)
22             if $thing->isa('Path::Class::Entity') || $thing->isa('Path::Tiny');
23 869 100 66     10377 }
24              
25             return bless(Path::Tiny::path($thing, @rest), __PACKAGE__);
26             }
27 2376         8483  
28             my %warned;
29              
30             my ($self, @file) = @_;
31              
32             my ($package, $pmfile, $line) = caller;
33 0     0 0    
34             my $key = join qq{\0}, $pmfile, $line;
35 0           unless ($warned{ $key }++) {
36             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");
37 0           }
38 0 0          
39 0           require Path::Class;
40             Path::Class::dir($self)->file(@file);
41             }
42 0            
43 0           my ($self, @subdir) = @_;
44             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");
45             require Path::Class;
46             Path::Class::dir($self)->subdir(@subdir);
47 0     0 0   }
48 0            
49 0           1;
50 0            
51              
52             =pod
53              
54             =encoding UTF-8
55              
56             =head1 NAME
57              
58             Dist::Zilla::Path - a helper to get Path::Tiny objects
59              
60             =head1 VERSION
61              
62             version 6.028
63              
64             =head1 PERL VERSION
65              
66             This module should work on any version of perl still receiving updates from
67             the Perl 5 Porters. This means it should work on any version of perl released
68             in the last two to three years. (That is, if the most recently released
69             version is v5.40, then this module should work on both v5.40 and v5.38.)
70              
71             Although it may work on older versions of perl, no guarantee is made that the
72             minimum required version will not be increased. The version may be increased
73             for any reason, and there is no promise that patches will be accepted to lower
74             the minimum required perl.
75              
76             =head1 AUTHOR
77              
78             Ricardo SIGNES 😏 <cpan@semiotic.systems>
79              
80             =head1 COPYRIGHT AND LICENSE
81              
82             This software is copyright (c) 2022 by Ricardo SIGNES.
83              
84             This is free software; you can redistribute it and/or modify it under
85             the same terms as the Perl 5 programming language system itself.
86              
87             =cut