| 1 | package lib::xi; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use 5.008_001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = '1.03'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Config (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | our $VERBOSE; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # modules which dosn't exist in CPAN | ||||||||||||||||||||||||||||
| 14 | 2 | our %IGNORE = map { $_ => 1 } ( | |||||||||||||||||||||||||||
| 15 | 'Encode/ConfigLocal.pm', | ||||||||||||||||||||||||||||
| 16 | 'Devel/StackTraceFrame.pm', | ||||||||||||||||||||||||||||
| 17 | 'Log/Agent.pm', # used in Storable.pm | ||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | 2 | my($class, %args) = @_; | |||||||||||||||||||||||||||
| 22 | 2 | return bless \%args, $class; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub run_perl { | ||||||||||||||||||||||||||
|
Subroutine
run_perl: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 26 | 0 | my(@args) = @_; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | my %std_inc = map { $_ => 1 } | |||||||||||||||||||||||||||
| 29 | 0 | ▶ | grep { defined($_) && length } @Config::Config{qw( | ||||||||||||||||||||||||||
|
Condition0%0/3
defined $_ && length $_
MC/DC0%0/2
defined $_ && length $_
defined $_
length $_
Truth table0%0/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||
| 30 | sitelibexp sitearchexp | ||||||||||||||||||||||||||||
| 31 | venderlibexp venderarchexp | ||||||||||||||||||||||||||||
| 32 | privlibexp archlibexp | ||||||||||||||||||||||||||||
| 33 | )}; | ||||||||||||||||||||||||||||
| 34 | 0 | my @non_std_inc = map { File::Spec->rel2abs($_) } | |||||||||||||||||||||||||||
| 35 | 0 | ▶ | grep { defined($_) && not $std_inc{$_} } @INC; | ||||||||||||||||||||||||||
|
Condition0%0/3
defined $_ && !$std_inc{$_}
MC/DC0%0/2
defined $_ && !$std_inc{$_}
defined $_
!$std_inc{$_}
Truth table0%0/3
A && not(B)
A= defined $_B= !$std_inc{$_}
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | system($^X, (map { "-I$_" } @non_std_inc), @args); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub cpanm_command { | ||||||||||||||||||||||||||
|
Subroutine
cpanm_command: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 41 | 0 | my($self) = @_; | |||||||||||||||||||||||||||
| 42 | 0 | return('cpanm', @{ $self->{cpanm_opts} }); | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | # must be fully-qualified; othewise implied main::INC. | ||||||||||||||||||||||||||||
| 46 | 4 | ▶ | sub lib::xi::INC { | ||||||||||||||||||||||||||
|
Subroutine
INC: called CC=7 SCAR=37.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 47 | 4 | my($self, $file) = @_; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 4 | ▶ | return if $IGNORE{$file}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | my $module = $file; | |||||||||||||||||||||||||||
| 52 | 0 | $module =~ s/\.pm \z//xms; | |||||||||||||||||||||||||||
| 53 | 0 | $module =~ s{/}{::}xmsg; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | my @cmd = ($self->cpanm_command, $module); | |||||||||||||||||||||||||||
| 56 | 0 | ▶ | if($VERBOSE) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | print STDERR "# PERL_CPANM_OPT: ", ($ENV{PERL_CPANM_OPT} || '') ,"\n"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'PERL_CPANM_OPT'} || ''
MC/DC0%0/1
$ENV{'PERL_CPANM_OPT'} || ''
$ENV{'PERL_CPANM_OPT'}
Truth table0%0/2
A
A= $ENV{'PERL_CPANM_OPT'}
| |||||||||||||||||||||||||||||
| 58 | 0 | print STDERR "# COMMAND: @cmd\n"; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if(run_perl('-S', @cmd) == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | foreach my $lib (grep {defined} @{ $self->{myinc} }) { | |||||||||||||||||||||||||||
| 62 | 0 | ▶ | if(open my $inh, '<', "$lib/$file") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 0 | $INC{$file} = "$lib/$file"; | |||||||||||||||||||||||||||
| 64 | 0 | return $inh; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | # fall back to the default behavior (Can't locate Foo.pm ...) | ||||||||||||||||||||||||||||
| 70 | 0 | return; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 2 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=7 SCAR=19.6
| |||||||||||||||||||||||||||||
| 74 | 2 | my($class, @cpanm_opts) = @_; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 2 | my $install_dir; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 2 | ▶ | if(@cpanm_opts && $cpanm_opts[0] !~ /^-/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@cpanm_opts and not $cpanm_opts[0] =~ /^-/
MC/DC50%1/2
@cpanm_opts and not $cpanm_opts[0] =~ /^-/
@cpanm_opts
not $cpanm_opts[0] =~ /^-/
Truth table66%2/3
A and not(B)
A= @cpanm_optsB= not $cpanm_opts[0] =~ /^-/
| |||||||||||||||||||||||||||||
| 79 | 1 | require File::Spec; | |||||||||||||||||||||||||||
| 80 | 1 | my $base; | |||||||||||||||||||||||||||
| 81 | 1 | ▶ | if($0 ne '-e' && -e $0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$0 ne "-e" and -e $0
MC/DC0%0/2
$0 ne "-e" and -e $0
$0 ne "-e"
-e $0
Truth table33%1/3
A and B
A= $0 ne "-e"B= -e $0
| |||||||||||||||||||||||||||||
| 82 | 1 | my($volume, $dir, undef) = File::Spec->splitpath($0); | |||||||||||||||||||||||||||
| 83 | 1 | $base = File::Spec->catpath($volume, $dir, ''); | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | 1 | $install_dir = File::Spec->rel2abs(shift(@cpanm_opts), $base); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 2 | my @myinc; | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 2 | ▶ | if($install_dir) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 1 | @myinc = ( | |||||||||||||||||||||||||||
| 92 | "$install_dir/lib/perl5/$Config::Config{archname}", | ||||||||||||||||||||||||||||
| 93 | "$install_dir/lib/perl5", | ||||||||||||||||||||||||||||
| 94 | ); | ||||||||||||||||||||||||||||
| 95 | 1 | unshift @INC, @myinc; | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 1 | unshift @cpanm_opts, '-l', $install_dir; | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 2 | $VERBOSE = scalar grep { $_ eq '-v' } @cpanm_opts; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 2 | ▶ | push @INC, $class->new( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | install_dir => $install_dir, | ||||||||||||||||||||||||||||
| 104 | myinc => $install_dir ? \@myinc : \@INC, | ||||||||||||||||||||||||||||
| 105 | cpanm_opts => \@cpanm_opts, | ||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||
| 107 | 2 | return; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub install_dir { $_[0]->{install_dir} } # for testing | ||||||||||||||||||||||||||
|
Subroutine
install_dir: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 2 | 1; | |||||||||||||||||||||||||||
| 113 | __END__ | ||||||||||||||||||||||||||||