| 1 | package Config::Find::Where; | ||||||||||||||||||||||
| 2 | |||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 5 | |||||||||||||||||||||||
| 6 | 2 | ▶ | use Carp; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 7 | 2 | ▶ | use Config::Find; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 8 | 2 | our @ISA=@Config::Find::ISA; | |||||||||||||||||||||
| 9 | |||||||||||||||||||||||
| 10 | 0 | ▶ | sub temp_dir { | ||||||||||||||||||||
|
Subroutine
temp_dir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||
| 11 | 0 | my $class = shift; | |||||||||||||||||||||
| 12 | 0 | my ($name, $more_name, $create, $dn, $scope)= | |||||||||||||||||||||
| 13 | $class->parse_opts(scope=> 'user', @_); | ||||||||||||||||||||||
| 14 | |||||||||||||||||||||||
| 15 | 0 | ▶ | $class->create_dir_if( (defined $dn | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 16 | ? $dn | ||||||||||||||||||||||
| 17 | : $class->_temp_dir($name, $more_name, $scope)), | ||||||||||||||||||||||
| 18 | $create) | ||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||
| 20 | |||||||||||||||||||||||
| 21 | 0 | ▶ | sub var_dir { | ||||||||||||||||||||
|
Subroutine
var_dir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||
| 22 | 0 | my $class = shift; | |||||||||||||||||||||
| 23 | 0 | my ($name, $more_name, $create, $dn, $scope)= | |||||||||||||||||||||
| 24 | $class->parse_opts(scope => 'app', @_); | ||||||||||||||||||||||
| 25 | |||||||||||||||||||||||
| 26 | 0 | ▶ | $class->create_dir_if( (defined $dn | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 27 | ? $dn | ||||||||||||||||||||||
| 28 | : $class->_var_dir($name, $more_name, $scope) ), | ||||||||||||||||||||||
| 29 | $create) | ||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||
| 31 | |||||||||||||||||||||||
| 32 | 0 | ▶ | sub bin_dir { | ||||||||||||||||||||
|
Subroutine
bin_dir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||
| 33 | 0 | my $class = shift; | |||||||||||||||||||||
| 34 | 0 | my ($name, $more_name, $create, $dn, $scope)= | |||||||||||||||||||||
| 35 | $class->parse_opts(scope=> 'app', @_); | ||||||||||||||||||||||
| 36 | |||||||||||||||||||||||
| 37 | 0 | ▶ | $class->create_dir_if( (defined $dn | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 38 | ? $dn | ||||||||||||||||||||||
| 39 | : $class->_bin_dir($name, $more_name, $scope) ), | ||||||||||||||||||||||
| 40 | $create); | ||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||
| 42 | |||||||||||||||||||||||
| 43 | 0 | ▶ | sub lib_dir { | ||||||||||||||||||||
|
Subroutine
lib_dir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||
| 44 | 0 | my $class = shift; | |||||||||||||||||||||
| 45 | 0 | my ($name, $more_name, $create, $dn, $scope) = | |||||||||||||||||||||
| 46 | $class->parse_opts(scope => 'app', @_); | ||||||||||||||||||||||
| 47 | |||||||||||||||||||||||
| 48 | 0 | ▶ | $class->create_dir_if( (defined $dn | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 49 | ? $dn | ||||||||||||||||||||||
| 50 | : $class->_lib_dir($name, $more_name, $scope) ), | ||||||||||||||||||||||
| 51 | $create); | ||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||
| 53 | |||||||||||||||||||||||
| 54 | 0 | ▶ | sub application_dir { | ||||||||||||||||||||
|
Subroutine
application_dir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||
| 55 | 0 | my $class=shift; | |||||||||||||||||||||
| 56 | 0 | my ($name, $more_name, $create, $dn, $scope)= | |||||||||||||||||||||
| 57 | $class->parse_opts(@_); | ||||||||||||||||||||||
| 58 | |||||||||||||||||||||||
| 59 | 0 | ▶ | $class->create_dir_if( (defined $dn | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 60 | ? $dn | ||||||||||||||||||||||
| 61 | : $class->app_dir($name) ), | ||||||||||||||||||||||
| 62 | $create) | ||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||
| 64 | |||||||||||||||||||||||
| 65 | 0 | ▶ | sub create_dir_if { | ||||||||||||||||||||
|
Subroutine
create_dir_if: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||
| 66 | 0 | my ($class, $dir, $create)=@_; | |||||||||||||||||||||
| 67 | # warn ("$class->create_dir($dir, $create)"); | ||||||||||||||||||||||
| 68 | 0 | ▶ | if ($create) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 69 | 0 | $class->create_dir($dir); | |||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||
| 71 | 0 | $dir; | |||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||
| 73 | |||||||||||||||||||||||
| 74 | 0 | ▶ | sub create_dir { | ||||||||||||||||||||
|
Subroutine
create_dir: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 75 | 0 | my ($class, $dir)=@_; | |||||||||||||||||||||
| 76 | 0 | $class->SUPER::create_dir(File::Spec->rel2abs($dir)); | |||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||
| 78 | |||||||||||||||||||||||
| 79 | 0 | ▶ | sub create_parent_dir { | ||||||||||||||||||||
|
Subroutine
create_parent_dir: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 80 | 0 | my ($class, $dir)=@_; | |||||||||||||||||||||
| 81 | 0 | $class->SUPER::create_parent_dir(File::Spec->rel2abs($dir)); | |||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||
| 83 | |||||||||||||||||||||||
| 84 | 0 | ▶ | sub script_full_path { shift->guess_full_script_name } | ||||||||||||||||||||
|
Subroutine
script_full_path: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 85 | |||||||||||||||||||||||
| 86 | 0 | ▶ | sub script_name { shift->guess_script_name } | ||||||||||||||||||||
|
Subroutine
script_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 87 | |||||||||||||||||||||||
| 88 | 0 | ▶ | sub script_dir { shift->guess_script_dir } | ||||||||||||||||||||
|
Subroutine
script_dir: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 89 | |||||||||||||||||||||||
| 90 | 0 | ▶ | sub helper_path { | ||||||||||||||||||||
|
Subroutine
helper_path: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 91 | 0 | my $class=shift; | |||||||||||||||||||||
| 92 | 0 | my $helper=shift; | |||||||||||||||||||||
| 93 | 0 | my $path=$class->bin_dir(@_); | |||||||||||||||||||||
| 94 | 0 | $class->look_for_helper($path, $helper); | |||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||
| 96 | |||||||||||||||||||||||
| 97 | 0 | ▶ | sub parse_opts { | ||||||||||||||||||||
|
Subroutine
parse_opts: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||
| 98 | 0 | my ($class, %opts)=@_; | |||||||||||||||||||||
| 99 | 0 | my ($name, $more_name, $create, $dn, $scope); | |||||||||||||||||||||
| 100 | 0 | $dn=$opts{dir}; | |||||||||||||||||||||
| 101 | 0 | $create=$opts{create}; | |||||||||||||||||||||
| 102 | |||||||||||||||||||||||
| 103 | 0 | ▶ | if (defined $opts{name}) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 104 | 0 | ▶ | $opts{name}=~m{^([^/]*)(?:/(.*))?$} | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 105 | or croak "invalid name '$opts{name}' specification"; | ||||||||||||||||||||||
| 106 | 0 | $name=$1; | |||||||||||||||||||||
| 107 | 0 | $more_name=$2; | |||||||||||||||||||||
| 108 | } else { | ||||||||||||||||||||||
| 109 | 0 | $name=$class->guess_script_name; | |||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||
| 111 | |||||||||||||||||||||||
| 112 | 0 | ▶ | if (defined $opts{scope}) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 113 | 0 | ▶ | if ($opts{scope}=~/^u(ser)?$/i) { | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 114 | 0 | $scope='user' | |||||||||||||||||||||
| 115 | } elsif ($opts{scope}=~/^g(lobal)?$/i) { | ||||||||||||||||||||||
| 116 | 0 | $scope='global' | |||||||||||||||||||||
| 117 | } elsif ($opts{scope}=~/^a(pp(lication)?)?$/i) { | ||||||||||||||||||||||
| 118 | 0 | $scope='app' | |||||||||||||||||||||
| 119 | } elsif ($opts{scope}=~/^p(rocess)?$/i) { | ||||||||||||||||||||||
| 120 | 0 | $scope='process' | |||||||||||||||||||||
| 121 | } else { | ||||||||||||||||||||||
| 122 | 0 | croak "invalid option scope => '$opts{scope}'"; | |||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||
| 124 | } else { | ||||||||||||||||||||||
| 125 | 0 | $scope='global'; | |||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||
| 127 | |||||||||||||||||||||||
| 128 | 0 | return ($name, $more_name, $create, $dn, $scope); | |||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||
| 130 | |||||||||||||||||||||||
| 131 | 2 | 1; | |||||||||||||||||||||
| 132 | |||||||||||||||||||||||
| 133 | __END__ | ||||||||||||||||||||||