| 1 | package App::CpanfileSlipstop::CLI; | ||||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Carton::Snapshot; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Getopt::Long qw/:config posix_default no_ignore_case gnu_compat bundling/; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Module::CPANfile; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Pod::Find qw(pod_where); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Pod::Usage qw(pod2usage); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use App::CpanfileSlipstop::Resolver; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use App::CpanfileSlipstop::Writer; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 15 | 0 | my ($class) = @_; | |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||
| 17 | # defaults | ||||||||||||||||||||||||||||||
| 18 | 0 | bless +{ | |||||||||||||||||||||||||||||
| 19 | cpanfile => './cpanfile', | ||||||||||||||||||||||||||||||
| 20 | snapshot => './cpanfile.snapshot', | ||||||||||||||||||||||||||||||
| 21 | stopper => 'exact', # or minimum, maximmu | ||||||||||||||||||||||||||||||
| 22 | dry_run => 0, | ||||||||||||||||||||||||||||||
| 23 | with_core => 0, | ||||||||||||||||||||||||||||||
| 24 | silent => 0, | ||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||
| 26 | remove => 0, | ||||||||||||||||||||||||||||||
| 27 | help => 0, | ||||||||||||||||||||||||||||||
| 28 | }, $class; | ||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 32 | 0 | my ($self, @argv) = @_; | |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||
| 34 | 0 | $self->parse_options(@argv); | |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | return $self->cmd_help if $self->{help}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | return $self->cmd_remove if $self->{remove}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||
| 39 | 0 | return $self->cmd_feedback; | |||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub parse_options { | ||||||||||||||||||||||||||||
|
Subroutine
parse_options: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 43 | 0 | my ($self, @argv) = @_; | |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||
| 45 | GetOptions( | ||||||||||||||||||||||||||||||
| 46 | 'cpanfile=s' => \($self->{cpanfile}), | ||||||||||||||||||||||||||||||
| 47 | 'snapshot=s' => \($self->{snapshot}), | ||||||||||||||||||||||||||||||
| 48 | 'stopper=s' => \($self->{stopper}), | ||||||||||||||||||||||||||||||
| 49 | 'dry-run' => \($self->{dry_run}), | ||||||||||||||||||||||||||||||
| 50 | 'with-core' => \($self->{with_core}), | ||||||||||||||||||||||||||||||
| 51 | 'silent' => \($self->{silent}), | ||||||||||||||||||||||||||||||
| 52 | 'remove' => \($self->{remove}), | ||||||||||||||||||||||||||||||
| 53 | 0 | 'help|h' => \($self->{help}), | |||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub cmd_feedback { | ||||||||||||||||||||||||||||
|
Subroutine
cmd_feedback: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 58 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||
| 60 | 0 | my $cpanfile = Module::CPANfile->load($self->{cpanfile}); | |||||||||||||||||||||||||||||
| 61 | 0 | my $snapshot = Carton::Snapshot->new(path => $self->{snapshot}); | |||||||||||||||||||||||||||||
| 62 | 0 | $snapshot->load; | |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||
| 64 | my $resolver = App::CpanfileSlipstop::Resolver->new( | ||||||||||||||||||||||||||||||
| 65 | cpanfile => $cpanfile, | ||||||||||||||||||||||||||||||
| 66 | snapshot => $snapshot, | ||||||||||||||||||||||||||||||
| 67 | with_core => $self->{with_core}, | ||||||||||||||||||||||||||||||
| 68 | 0 | ); | |||||||||||||||||||||||||||||
| 69 | 0 | $resolver->read_cpanfile_requirements; | |||||||||||||||||||||||||||||
| 70 | 0 | $resolver->merge_snapshot_versions($self->versioning_method, $self->{with_core}); | |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||
| 72 | my $writer = App::CpanfileSlipstop::Writer->new( | ||||||||||||||||||||||||||||||
| 73 | cpanfile_path => $self->{cpanfile}, | ||||||||||||||||||||||||||||||
| 74 | dry_run => $self->{dry_run}, | ||||||||||||||||||||||||||||||
| 75 | 0 | ); | |||||||||||||||||||||||||||||
| 76 | $writer->set_versions( | ||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub { $resolver->get_version_range($_[0]) }, | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub { !$self->{silent} && $self->log(@_) }, | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 79 | 0 | ); | |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||
| 81 | 0 | return 0; | |||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub cmd_remove { | ||||||||||||||||||||||||||||
|
Subroutine
cmd_remove: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 85 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||
| 87 | 0 | my $cpanfile = Module::CPANfile->load($self->{cpanfile}); | |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||
| 89 | my $writer = App::CpanfileSlipstop::Writer->new( | ||||||||||||||||||||||||||||||
| 90 | cpanfile_path => $self->{cpanfile}, | ||||||||||||||||||||||||||||||
| 91 | dry_run => $self->{dry_run}, | ||||||||||||||||||||||||||||||
| 92 | 0 | ); | |||||||||||||||||||||||||||||
| 93 | $writer->remove_versions( | ||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub { !$self->{silent} && $self->log(@_) }, | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 95 | 0 | ); | |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||
| 97 | 0 | return 0; | |||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | sub cmd_help { | ||||||||||||||||||||||||||||
|
Subroutine
cmd_help: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 101 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||
| 103 | 0 | pod2usage( | |||||||||||||||||||||||||||||
| 104 | -input => pod_where({ -inc => 1 }, 'App::CpanfileSlipstop'), | ||||||||||||||||||||||||||||||
| 105 | -exitval => 0, | ||||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub versioning_method { | ||||||||||||||||||||||||||||
|
Subroutine
versioning_method: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 110 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||
| 112 | return +{ | ||||||||||||||||||||||||||||||
| 113 | minimum => 'add_minimum', | ||||||||||||||||||||||||||||||
| 114 | maximum => 'add_maximum', | ||||||||||||||||||||||||||||||
| 115 | exact => 'exact_version', | ||||||||||||||||||||||||||||||
| 116 | 0 | }->{$self->{stopper}}; | |||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub log { | ||||||||||||||||||||||||||||
|
Subroutine
log: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 120 | 0 | my ($self, $log) = @_; | |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | return if ($log->{before} || '') eq ($log->{after} || ''); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/4
$log->{'before'} || ''
$log->{'after'} || ''
MC/DC0%0/1
$log->{'before'} || ''
$log->{'before'}
MC/DC0%0/1
$log->{'after'} || ''
$log->{'after'}
Truth table0%0/2
A
A= $log->{'before'}
Truth table0%0/2
A
A= $log->{'after'}
| |||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||
| 124 | 0 | my $quote = $log->{quote}; | |||||||||||||||||||||||||||||
| 125 | print sprintf "%s: %s -> %s\n", | ||||||||||||||||||||||||||||||
| 126 | $log->{module}, | ||||||||||||||||||||||||||||||
| 127 | $log->{before} ? $log->{before} : '(unspecified)', | ||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | $log->{after} ? $log->{after} : '(unspecified)'; | ||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||
| 131 | 1 | 1; | |||||||||||||||||||||||||||||