blib/lib/FindApp/Utils/Paths.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 22 Podpod 0.0% 0 / 15 totaltotal 0.0% 0 / 87 CC 4 SCAR 14.1
CC
4
Cov
0%
hate_empty
12.0
pathify_modules
6.0
file_dir_ext
2.0
CRAP 4.1
1 package FindApp::Utils::Paths;
2  
3 use v5.10;
4 use strict;
5 use warnings;
6  
7 use FindApp::Utils::Carp;
8  
9 use FindApp::Utils::Foreign qw(
10 abs2rel
11 abs_path
12 fileparse
13 dirname
14 basename
15 );
16 use FindApp::Utils::Package qw(
17 PACKAGE
18 );
19  
20 #################################################################
21  
22 sub basename_noext ( _ ) ;
23 sub dir_file_ext ( _ ) ;
24 sub file_dir_ext ( _ ) ;
25 sub is_absolute ( _ ) ;
26 sub is_relative ( _ ) ;
27 sub module2path ( _ ) ;
28 sub pathify_modules ( @ ) ;
29  
30 #################################################################
31  
32 use Exporter qw(import);
33 our $VERSION = v1.0;
34 our @EXPORT_OK = qw(
35 basename_noext
36 dir_file_ext
37 file_dir_ext
38 is_absolute
39 is_relative
40 module2path
41 pathify_modules
42 );
43 # Re-exports
44 push @EXPORT_OK, qw(
45 abs2rel
46 abs_path
47 basename
48 dirname
49 fileparse
50 );
51 our %EXPORT_TAGS = (all => \@EXPORT_OK);
52  
53 #################################################################
54  
55 sub hate_empty {
56 for (@_) {
57 croak "paths cannot be undef" unless defined;
58 croak "paths cannot be empty" unless length;
59 }
60 }
61  
62 sub file_dir_ext(_) { &hate_empty; fileparse shift, qr/\..*/ }
63 sub dir_file_ext(_) { &hate_empty; (&file_dir_ext)[1,0,2] }
64 sub basename_noext(_) { &hate_empty; scalar file_dir_ext shift }
65 sub is_absolute(_) { &hate_empty; substr(shift, 0, 1) eq "/" }
66 sub is_relative(_) { &hate_empty; !&is_absolute }
67 sub module2path(_) { &hate_empty; PACKAGE(shift)->pmpath }
68  
69 # only works on ones with at least one double-colon
70 sub pathify_modules(@) { &hate_empty; map { /^\w+(::\w+)+$/ ? module2path : $_ } @_ }
71  
72 1;
73  
74 =encoding utf8
75  
76 =head1 NAME
77  
78 FindApp::Utils::Paths - FIXME
79  
80 =head1 SYNOPSIS
81  
82 use FindApp::Utils::Paths;
83  
84 =head1 DESCRIPTION
85  
86 =head2 Public Methods
87  
88 =over
89  
90 =item FIXME
91  
92 =back
93  
94 =head2 Exports
95  
96 =over
97  
98 =item basename_noext
99  
100 =item dir_file_ext
101  
102 =item file_dir_ext
103  
104 =item is_absolute
105  
106 =item is_relative
107  
108 =item module2path
109  
110 =item pathify_modules
111  
112 =back
113  
114 =head2 Private Functions
115  
116 =over
117  
118 =item hate_empty
119  
120 =back
121  
122 =head1 EXAMPLES
123  
124 =head1 ENVIRONMENT
125  
126 =head1 SEE ALSO
127  
128 =over
129  
130 =item L<FindApp>
131  
132 =back
133  
134 =head1 CAVEATS AND PROVISOS
135  
136 =head1 BUGS AND LIMITATIONS
137  
138 =head1 HISTORY
139  
140 =head1 AUTHOR
141  
142 Tom Christiansen << <tchrist@perl.com> >>
143  
144 =head1 LICENCE AND COPYRIGHT
145  
146 Copyright (c) 2016, Tom Christiansen C<< <tchrist@perl.com> >>.
147 All Rights Reserved.
148  
149 This module is free software; you can redistribute it and/or
150 modify it under the same terms as Perl itself. See L<perlartistic>.
151  
152 =cut
153