| 1 | package FindApp::Utils::Paths; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 6 | ▶ | use v5.10; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 6 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 6 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 6 | ▶ | use FindApp::Utils::Carp; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | |||||||||||||||
| 9 | 6 | ▶ | use FindApp::Utils::Foreign qw( | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | abs2rel | ||||||||||||||
| 11 | abs_path | ||||||||||||||
| 12 | fileparse | ||||||||||||||
| 13 | dirname | ||||||||||||||
| 14 | basename | ||||||||||||||
| 15 | 6 | ); | |||||||||||||
| 16 | 6 | ▶ | use FindApp::Utils::Package qw( | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 17 | PACKAGE | ||||||||||||||
| 18 | 6 | ); | |||||||||||||
| 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 | 6 | ▶ | use Exporter qw(import); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 33 | 6 | our $VERSION = v1.0; | |||||||||||||
| 34 | 6 | 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 | 6 | push @EXPORT_OK, qw( | |||||||||||||
| 45 | abs2rel | ||||||||||||||
| 46 | abs_path | ||||||||||||||
| 47 | basename | ||||||||||||||
| 48 | dirname | ||||||||||||||
| 49 | fileparse | ||||||||||||||
| 50 | ); | ||||||||||||||
| 51 | 6 | our %EXPORT_TAGS = (all => \@EXPORT_OK); | |||||||||||||
| 52 | |||||||||||||||
| 53 | ################################################################# | ||||||||||||||
| 54 | |||||||||||||||
| 55 | 132 | ▶ | sub hate_empty { | ||||||||||||
|
Subroutine
hate_empty: called CC=4 SCAR=21.1
Pod
documented
| |||||||||||||||
| 56 | 0 | ▶ | for (@_) { | ||||||||||||
|
Subroutine
hate_empty: not called CC=4 SCAR=21.1
Pod
documented
| |||||||||||||||
| 57 | 0 | ▶ | croak "paths cannot be undef" unless defined; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 58 | 0 | ▶ | croak "paths cannot be empty" unless length; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 59 | } | ||||||||||||||
| 60 | } | ||||||||||||||
| 61 | |||||||||||||||
| 62 | 66 | ▶ | sub file_dir_ext(_) { &hate_empty; fileparse shift, qr/\..*/ } | ||||||||||||
|
Subroutine
file_dir_ext: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 63 | 6 | ▶ | sub dir_file_ext(_) { &hate_empty; (&file_dir_ext)[1,0,2] } | ||||||||||||
|
Subroutine
dir_file_ext: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 64 | 60 | ▶ | sub basename_noext(_) { &hate_empty; scalar file_dir_ext shift } | ||||||||||||
|
Subroutine
basename_noext: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 65 | 0 | ▶ | sub is_absolute(_) { &hate_empty; substr(shift, 0, 1) eq "/" } | ||||||||||||
|
Subroutine
is_absolute: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 66 | 0 | ▶ | sub is_relative(_) { &hate_empty; !&is_absolute } | ||||||||||||
|
Subroutine
is_relative: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 67 | 0 | ▶ | sub module2path(_) { &hate_empty; PACKAGE(shift)->pmpath } | ||||||||||||
|
Subroutine
module2path: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 68 | |||||||||||||||
| 69 | # only works on ones with at least one double-colon | ||||||||||||||
| 70 | 0 | ▶ | sub pathify_modules(@) { &hate_empty; map { /^\w+(::\w+)+$/ ? module2path : $_ } @_ } | ||||||||||||
|
Subroutine
pathify_modules: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||
| 71 | |||||||||||||||
| 72 | 6 | 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 | |||||||||||||||