| 1 | package exact::lib; | ||||||||||||||
| 2 | # ABSTRACT: Compile-time @INC manipulation extension for exact | ||||||||||||||
| 3 | |||||||||||||||
| 4 | 2 | ▶ | use 5.014; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 2 | ▶ | use exact; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 2 | ▶ | use FindBin; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | 2 | our $VERSION = '1.06'; # VERSION | |||||||||||||
| 9 | |||||||||||||||
| 10 | 1 | ▶ | sub import { | ||||||||||||
|
Subroutine
import: called CC=6 SCAR=18.0
| |||||||||||||||
| 11 | 1 | my ( $self, $params ) = @_; | |||||||||||||
| 12 | |||||||||||||||
| 13 | 1 | ▶ | $params //= 'lib'; | ||||||||||||
|
Condition50%1/2
$params //= "lib"
MC/DC0%0/1
$params //= "lib"
$params
Truth table50%1/2
A
A= $params
| |||||||||||||||
| 14 | 1 | $params =~ s/(^\s+|\s+$)//g; | |||||||||||||
| 15 | |||||||||||||||
| 16 | 1 | for my $dir ( map { s/\\ / /g; $_ } split( /(?<!\\)\s/, $params ) ) { | |||||||||||||
| 17 | 3 | ▶ | if ( index( $dir, '/', 0 ) == 0 ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 18 | 1 | _add_to_inc($dir); | |||||||||||||
| 19 | } | ||||||||||||||
| 20 | elsif ( index( $dir, '.', 0 ) == 0 ) { | ||||||||||||||
| 21 | 1 | _add_to_inc( $FindBin::Bin . '/' . $dir ); | |||||||||||||
| 22 | } | ||||||||||||||
| 23 | else { | ||||||||||||||
| 24 | 1 | my $found_dir = _find_dir($dir); | |||||||||||||
| 25 | 1 | ▶ | _add_to_inc($found_dir) if ($found_dir); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 26 | } | ||||||||||||||
| 27 | } | ||||||||||||||
| 28 | } | ||||||||||||||
| 29 | |||||||||||||||
| 30 | 2 | ▶ | sub _add_to_inc { | ||||||||||||
|
Subroutine
_add_to_inc: called CC=3 SCAR=11.2
| |||||||||||||||
| 31 | 2 | for my $lib (@_) { | |||||||||||||
| 32 | 2 | ▶ | unshift( @INC, $lib ) unless ( grep { $_ eq $lib } @INC ); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 33 | } | ||||||||||||||
| 34 | } | ||||||||||||||
| 35 | |||||||||||||||
| 36 | 1 | ▶ | sub _find_dir { | ||||||||||||
|
Subroutine
_find_dir: called CC=3 SCAR=11.0
| |||||||||||||||
| 37 | 1 | my ($suffix) = @_; | |||||||||||||
| 38 | |||||||||||||||
| 39 | 1 | my @search_path = split( '/', $FindBin::Bin ); | |||||||||||||
| 40 | 1 | ▶ | while ( @search_path > 0 ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 41 | 7 | my $dir = join( '/', @search_path, $suffix ); | |||||||||||||
| 42 | 7 | ▶ | return $dir if ( -d $dir ); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 43 | 7 | pop @search_path; | |||||||||||||
| 44 | } | ||||||||||||||
| 45 | |||||||||||||||
| 46 | 1 | return; | |||||||||||||
| 47 | } | ||||||||||||||
| 48 | |||||||||||||||
| 49 | 2 | 1; | |||||||||||||
| 50 | |||||||||||||||
| 51 | __END__ | ||||||||||||||