| 1 | package App::pmuninstall; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use File::Basename qw(dirname); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use ExtUtils::Packlist; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Getopt::Long qw(GetOptions :config bundling); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use YAML (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use CPAN::DistnameInfo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use version; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use HTTP::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Term::ANSIColor qw(colored); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Cwd (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use JSON::PP qw(decode_json); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | our $VERSION = "0.33"; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | my $perl_version = version->new($])->numify; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | my $depended_on_by = 'http://deps.cpantesters.org/depended-on-by.pl?dist='; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | my $cpanmetadb = 'http://cpanmetadb.plackperl.org/v1.0/package'; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | my @core_modules_dir = do { my %h; grep !$h{$_}++, @Config{qw/archlib archlibexp privlib privlibexp/} }; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | $ENV{ANSI_COLORS_DISABLED} = 1 if $^O eq 'MSWin32'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | our $OUTPUT_INDENT_LEVEL = 0; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my ($class, $inc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | $inc = [@INC] unless ref $inc eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | bless { | |||||||||||||||||||||||||||||||||||||||||
| 32 | check_deps => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 33 | verbose => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 34 | inc => $class->prepare_include_paths($inc), | ||||||||||||||||||||||||||||||||||||||||||
| 35 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | local @ARGV = @args; | |||||||||||||||||||||||||||||||||||||||||
| 41 | GetOptions( | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 'f|force' => \$self->{force}, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | 'v|verbose!' => sub { ++$self->{verbose} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 'c|checkdeps!' => \$self->{check_deps}, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | 'n|no-checkdeps!' => sub { $self->{check_deps} = 0 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 'q|quiet!' => \$self->{quiet}, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | 'h|help!' => sub { $self->usage }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 'V|version!' => \$self->{version}, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 'l|local-lib=s' => \$self->{local_lib}, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | 'L|local-lib-contained=s' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $self->{local_lib} = $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $self->{self_contained} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 53 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | ) or $self->usage; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if ($self->{version}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $self->puts("pm-uninstall (App::pmuninstall) version $App::pmuninstall::VERSION"); | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $self->short_usage unless @ARGV; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $self->uninstall(@ARGV); | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub uninstall { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uninstall: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my ($self, @modules) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $self->setup_local_lib; | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $uninstalled = 0; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | for my $module (@modules) { | |||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | $self->puts("--> Working on $module") unless $self->{quiet}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my ($packlist, $dist, $vname) = $self->find_packlist($module); | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $packlist = File::Spec->canonpath($packlist); | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if ($self->is_core_module($module, $packlist)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $self->puts(colored ['red'], "! $module is a core module!! Can't be uninstalled."); | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $self->puts unless $self->{quiet}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | unless ($dist) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $self->puts(colored ['red'], "! $module not found."); | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | $self->puts unless $self->{quiet}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | unless ($packlist) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $self->puts(colored ['red'], "! $module is not installed."); | |||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | $self->puts unless $self->{quiet}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if ($self->ask_permission($module, $dist, $vname, $packlist)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if ($self->uninstall_from_packlist($packlist)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $self->puts(colored ['green'], "Successfully uninstalled $module"); | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ++$uninstalled; | |||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $self->puts(colored ['red'], "! Failed to uninstall $module"); | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | $self->puts unless $self->{quiet}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ($uninstalled) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | $self->puts if $self->{quiet}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $self->puts("You may want to rebuild man(1) entries. Try `mandb -c` if needed"); | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | return $uninstalled; | |||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | sub uninstall_from_packlist { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uninstall_from_packlist: not called CC=15 SCAR=54.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my ($self, $packlist) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | my $inc = { | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | map { File::Spec->canonpath($_) => 1 } @{$self->{inc}} | |||||||||||||||||||||||||||||||||||||||||
| 120 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $failed; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | for my $file ($self->fixup_packlist($packlist)) { | |||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | chomp $file; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | $self->puts(-f $file ? 'unlink ' : 'not found', " : $file") if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | unlink $file or $self->puts("$file: $!") and $failed++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
unlink($file) || $self->puts("${file}: $!") && ++$failed
$self->puts("${file}: $!") and ++$failed
MC/DC0%0/3
unlink($file) || $self->puts("${file}: $!") && ++$failed
unlink($file)
$self->puts("${file}: $!")
++$failed
Truth table0%0/4
A || B and C
A= unlink($file)B= $self->puts("${file}: $!")C= ++$failed
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $self->rm_empty_dir_from_file($file, $inc); | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | $self->puts("unlink : $packlist") if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | unlink $packlist or $self->puts("$packlist: $!") and $failed++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
unlink($packlist) || $self->puts("${packlist}: $!") && ++$failed
$self->puts("${packlist}: $!") and ++$failed
MC/DC0%0/3
unlink($packlist) || $self->puts("${packlist}: $!") && ++$failed
unlink($packlist)
$self->puts("${packlist}: $!")
++$failed
Truth table0%0/4
A || B and C
A= unlink($packlist)B= $self->puts("${packlist}: $!")C= ++$failed
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $self->rm_empty_dir_from_file($packlist, $inc); | |||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if (my $install_json = $self->{install_json}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | $self->puts("unlink : $install_json") if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | unlink $install_json or $self->puts("$install_json: $!") and $failed++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
unlink($install_json) || $self->puts("${install_json}: $!") && ++$failed
$self->puts("${install_json}: $!") and ++$failed
MC/DC0%0/3
unlink($install_json) || $self->puts("${install_json}: $!") && ++$failed
unlink($install_json)
$self->puts("${install_json}: $!")
++$failed
Truth table0%0/4
A || B and C
A= unlink($install_json)B= $self->puts("${install_json}: $!")C= ++$failed
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $self->rm_empty_dir_from_file($install_json); | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | $self->puts unless $self->{quiet} || $self->{force}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"quiet"} or $self->{"force"}
MC/DC0%0/2
$self->{"quiet"} or $self->{"force"}
$self->{"quiet"}
$self->{"force"}
Truth table0%0/3
A or B
A= $self->{"quiet"}B= $self->{"force"}
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | return !$failed; | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | sub rm_empty_dir_from_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rm_empty_dir_from_file: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my ($self, $file, $inc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $dir = dirname $file; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | return unless -d $dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | return if $inc->{+File::Spec->canonpath($dir)}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my $failed; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if ($self->is_empty_dir($dir)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | $self->puts("rmdir : $dir") if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | rmdir $dir or $self->puts("$dir: $!") and $failed++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
rmdir $dir || $self->puts("${dir}: $!") && ++$failed
$self->puts("${dir}: $!") and ++$failed
MC/DC0%0/3
rmdir $dir || $self->puts("${dir}: $!") && ++$failed
rmdir $dir
$self->puts("${dir}: $!")
++$failed
Truth table0%0/4
A || B and C
A= rmdir $dirB= $self->puts("${dir}: $!")C= ++$failed
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $self->rm_empty_dir_from_file($dir, $inc); | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | return !$failed; | |||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | sub is_empty_dir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_empty_dir: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my ($self, $dir) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | opendir my $dh, $dir or die "$dir: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my @dir = grep !/^\.{1,2}$/, readdir $dh; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | closedir $dh; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | return @dir ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub find_packlist { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_packlist: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my ($self, $module) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | $self->puts("Finding $module in your \@INC") if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | # find with the given name first | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | (my $try_dist = $module) =~ s!::!-!g; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | if (my $pl = $self->locate_pack($try_dist)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | $self->puts("-> Found $pl") if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | return ($pl, $try_dist); | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | $self->puts("Looking up $module on cpanmetadb") if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | # map module -> dist and retry | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | my $yaml = $self->fetch("$cpanmetadb/$module") or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my $meta = YAML::Load($yaml); | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my $info = CPAN::DistnameInfo->new($meta->{distfile}); | |||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | my $name = $self->find_meta($info->distvname) || $info->dist; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->find_meta($info->distvname) || $info->dist
MC/DC0%0/2
$self->find_meta($info->distvname) || $info->dist
$self->find_meta($info->distvname)
$info->dist
Truth table0%0/3
A || B
A= $self->find_meta($info->distvname)B= $info->dist
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | if (my $pl = $self->locate_pack($name)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | $self->puts("-> Found $pl") if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | return ($pl, $info->dist, $info->distvname); | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | sub find_meta { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_meta: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my ($self, $distvname) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my $name; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | for my $lib (@{$self->{inc}}) { | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | next unless $lib =~ /$Config{archname}/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my $install_json = "$lib/.meta/$distvname/install.json"; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | next unless -f $install_json && -r _; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-f $install_json and -r _
MC/DC0%0/2
-f $install_json and -r _
-f $install_json
-r _
Truth table0%0/3
A and B
A= -f $install_jsonB= -r _
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my $data = decode_json +$self->slurp($install_json); | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | $name = $data->{name} || next; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$data->{'name'} || (next)
MC/DC0%0/1
$data->{'name'} || (next)
$data->{'name'}
Truth table0%0/2
A
A= $data->{'name'}
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | $self->puts("-> Found $install_json") if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $self->{meta} = $install_json; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | return $name; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | sub locate_pack { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locate_pack: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my ($self, $dist) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $dist =~ s!-!/!g; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | for my $lib (@{$self->{inc}}) { | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $packlist = "$lib/auto/$dist/.packlist"; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | $self->puts("-> Finding .packlist $packlist") if $self->{verbose} > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | return $packlist if -f $packlist && -r _; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-f $packlist and -r _
MC/DC0%0/2
-f $packlist and -r _
-f $packlist
-r _
Truth table0%0/3
A and B
A= -f $packlistB= -r _
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | sub is_core_module { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_core_module: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my ($self, $dist, $packlist) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | require Module::CoreList; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | return unless exists $Module::CoreList::version{$perl_version}{$dist}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | return 1 unless $packlist; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | my $is_core = 0; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | for my $dir (@core_modules_dir) { | |||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $safe_dir = quotemeta $dir; # workaround for MSWin32 | |||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | if ($packlist =~ /^$safe_dir/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $is_core = 1; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | return $is_core; | |||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | sub ask_permission { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ask_permission: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | my($self, $module, $dist, $vname, $packlist) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | my @deps = $self->find_deps($vname, $module); | |||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | $self->puts if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | $self->puts("$module is included in the distribution $dist and contains:\n") | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | unless $self->{quiet}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | for my $file ($self->fixup_packlist($packlist)) { | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | chomp $file; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | $self->puts(" $file") unless $self->{quiet}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | $self->puts unless $self->{quiet}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | return 'force uninstall' if $self->{force}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my $default = 'y'; | |||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if (@deps) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $self->puts("Also, they're depended on by the following installed dists:\n"); | |||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | for my $dep (@deps) { | |||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $self->puts(" $dep"); | |||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | $self->puts; | |||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $default = 'n'; | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | return lc($self->prompt("Are you sure you want to uninstall $dist?", $default)) eq 'y'; | |||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | sub find_deps { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_deps: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my ($self, $vname, $module) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | return unless $self->{check_deps} && !$self->{force}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"check_deps"} and not $self->{"force"}
MC/DC0%0/2
$self->{"check_deps"} and not $self->{"force"}
$self->{"check_deps"}
not $self->{"force"}
Truth table0%0/3
A and not(B)
A= $self->{"check_deps"}B= not $self->{"force"}
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | $vname ||= $self->vname_for($module) or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$vname ||= $self->vname_for($module)
MC/DC0%0/2
$vname ||= $self->vname_for($module)
$vname
$self->vname_for($module)
Truth table0%0/3
A ||= B
A= $vnameB= $self->vname_for($module)
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | $self->puts("Checking modules depending on $vname") if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | my $content = $self->fetch("$depended_on_by$vname") or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my (@deps, %seen); | |||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | for my $dep ($content =~ m|<li><a href=[^>]+>([a-zA-Z0-9_:-]+)|smg) { | |||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $dep =~ s/^\s+|\s+$//smg; # trim | |||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | next if $seen{$dep}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | local $OUTPUT_INDENT_LEVEL = $OUTPUT_INDENT_LEVEL + 1; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | $self->puts("Finding $dep in your \@INC (dependencies)") if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | push @deps, $dep if $self->locate_pack($dep); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | return @deps; | |||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | sub prompt { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prompt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my ($self, $msg, $default) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | require ExtUtils::MakeMaker; | |||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ExtUtils::MakeMaker::prompt($msg, $default); | |||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | sub fixup_packlist { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fixup_packlist: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my ($self, $packlist) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | my @target_list; | |||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $is_local_lib = $self->is_local_lib($packlist); | |||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my $plist = ExtUtils::Packlist->new($packlist); | |||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | while (my $file = each %$plist) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | if ($is_local_lib) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | next unless $self->is_local_lib($file); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | push @target_list, $file; | |||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | return @target_list; | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | # NOTE only use this for comparing paths | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | sub _canon_path_compare { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_canon_path_compare: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | my ($self, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $path = Cwd::realpath($path); | |||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | if( $^O eq 'MSWin32' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | require Win32; | |||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $path = Win32::GetLongPathName($path); | |||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | return $path; | |||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | sub is_local_lib { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_local_lib: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | return unless $self->{local_lib}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | my $local_lib_base = quotemeta $self->_canon_path_compare($self->{local_lib}); | |||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | $file = $self->_canon_path_compare($file); | |||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | return $file =~ /^$local_lib_base(?:\/|\z)/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | sub vname_for { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vname_for: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | my ($self, $module) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | $self->puts("Fetching $module vname on cpanmetadb") if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | my $yaml = $self->fetch("$cpanmetadb/$module") or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my $meta = YAML::Load($yaml); | |||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | my $info = CPAN::DistnameInfo->new($meta->{distfile}) or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | return $info->distvname; | |||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | # taken from cpan-outdated | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | sub setup_local_lib { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_local_lib: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | return unless $self->{local_lib}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | unless (-d $self->{local_lib}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $self->puts(colored ['red'], "! $self->{local_lib} : no such directory"); | |||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | local $SIG{__WARN__} = sub { }; # catch 'Attempting to write ...' | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | $self->{inc} = [ | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | grep { defined } | |||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | map { Cwd::realpath($_) } | |||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | @{$self->build_active_perl5lib($self->{local_lib}, $self->{self_contained})} | |||||||||||||||||||||||||||||||||||||||||
| 355 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | push @{$self->{inc}}, @INC unless $self->{self_contained}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | sub build_active_perl5lib { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_active_perl5lib: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my ($self, $path, $interpolate) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 361 | my $perl5libs = [ | ||||||||||||||||||||||||||||||||||||||||||
| 362 | $self->install_base_arch_path($path), | ||||||||||||||||||||||||||||||||||||||||||
| 363 | $self->install_base_perl_path($path), | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | $interpolate && $ENV{PERL5LIB} ? split(/\Q$Config{path_sep}\E/, $ENV{PERL5LIB}) : (), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$interpolate and $ENV{"PERL5LIB"}
MC/DC0%0/2
$interpolate and $ENV{"PERL5LIB"}
$interpolate
$ENV{"PERL5LIB"}
Truth table0%0/3
A and B
A= $interpolateB= $ENV{"PERL5LIB"}
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | return $perl5libs; | |||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | sub install_base_perl_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
install_base_perl_path: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my ($self, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | File::Spec->catdir($path, 'lib', 'perl5'); | |||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | sub install_base_arch_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
install_base_arch_path: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my ($self, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | File::Spec->catdir($self->install_base_perl_path($path), $Config{archname}); | |||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | sub fetch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my ($self, $url) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | $self->puts("-> Fetching from $url") if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | my $res = HTTP::Tiny->new->get($url); | |||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | return if $res->{status} == 404; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | die "[$res->{status}] fetch $url failed!!\n" if !$res->{success}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | return $res->{content}; | |||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | sub slurp { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
slurp: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | open my $fh, '<', $file or die "$file $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | do { local $/; <$fh> }; | |||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | sub puts { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
puts: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | my ($self, @msg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | push @msg, '' unless @msg; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | print ' ' x $OUTPUT_INDENT_LEVEL if $OUTPUT_INDENT_LEVEL; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | print @msg, "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | sub usage { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
usage: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | $self->puts(<< 'USAGE'); | |||||||||||||||||||||||||||||||||||||||||
| 404 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 405 | pm-uninstall [options] Module [...] | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | options: | ||||||||||||||||||||||||||||||||||||||||||
| 408 | -v,--verbose Turns on chatty output | ||||||||||||||||||||||||||||||||||||||||||
| 409 | -f,--force Uninstalls without prompts | ||||||||||||||||||||||||||||||||||||||||||
| 410 | -c,--checkdeps Check dependencies (defaults to on) | ||||||||||||||||||||||||||||||||||||||||||
| 411 | -n,--no-checkdeps Don't check dependencies | ||||||||||||||||||||||||||||||||||||||||||
| 412 | -q,--quiet Suppress some messages | ||||||||||||||||||||||||||||||||||||||||||
| 413 | -h,--help This help message | ||||||||||||||||||||||||||||||||||||||||||
| 414 | -V,--version Show version | ||||||||||||||||||||||||||||||||||||||||||
| 415 | -l,--local-lib Additional module path | ||||||||||||||||||||||||||||||||||||||||||
| 416 | -L,--local-lib-contained Additional module path (don't include non-core modules) | ||||||||||||||||||||||||||||||||||||||||||
| 417 | USAGE | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | sub short_usage { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
short_usage: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | $self->puts(<< 'USAGE'); | |||||||||||||||||||||||||||||||||||||||||
| 425 | Usage: pm-uninstall [options] Module [...] | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | Try `pm-uninstall --help` or `man pm-uninstall` for more options. | ||||||||||||||||||||||||||||||||||||||||||
| 428 | USAGE | ||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | sub prepare_include_paths { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_include_paths: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my ($class, $inc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my $new_inc = []; | |||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | my $archname = quotemeta $Config{archname}; | |||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | for my $path (@$inc) { | |||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | push @$new_inc, $path; | |||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | next if $path eq '.' or $path =~ /$archname/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$path eq "." or $path =~ /$archname/
MC/DC0%0/2
$path eq "." or $path =~ /$archname/
$path eq "."
$path =~ /$archname/
Truth table0%0/3
A or B
A= $path eq "."B= $path =~ /$archname/
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | push @$new_inc, File::Spec->catdir($path, $Config{archname}); | |||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | return [do { my %h; grep !$h{$_}++, @$new_inc }]; | |||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 446 | __END__ | ||||||||||||||||||||||||||||||||||||||||||