lib/CPANPLUS/Dist/Autobundle.pm

filter: Statementstmt 92.3% 48 / 52 Branchbran 50.0% 5 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 90.9% 10 / 11 Podpod 100% 4 / 4 totaltotal 82.9% 68 / 82 SCAR 19.8
CC
7
Cov
83%
create
7.6
install
2.0
BEGIN
1.0
CRAP 7.2
« lib/CPANPLUS.pm ↑ Summary blib/lib/CPANPLUS/Config/HomeEnv.pm »
1 package CPANPLUS::Dist::Autobundle;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use CPANPLUS::Error qw[error msg];
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Params::Check qw[check];
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use vars qw[$VERSION];
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 $VERSION = "0.9912";
10  
11 4 ▶use base qw[CPANPLUS::Dist::Base];
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 =head1 NAME
14  
15 CPANPLUS::Dist::Autobundle - distribution class for installation snapshots
16  
17 =head1 SYNOPSIS
18  
19 $modobj = $cb->parse_module( module => 'file://path/to/Snapshot_XXYY.pm' );
20 $modobj->install;
21  
22 =head1 DESCRIPTION
23  
24 C<CPANPLUS::Dist::Autobundle> is a distribution class for installing installation
25 snapshots as created by C<CPANPLUS>' C<autobundle> command.
26  
27 All modules as mentioned in the snapshot will be installed on your system.
28  
29 =cut
30  
31 sub init {
32 1 ▶ my $dist = shift;
Subroutine init: called CC=1 SCAR=0.0
Pod documented
33 1 my $status = $dist->status;
34  
35 1 $status->mk_accessors(
36 qw[prepared created installed _prepare_args _create_args _install_args _metadata]
37 );
38  
39 1 return 1;
40 }
41  
42 sub prepare {
43 1 ▶ my $dist = shift;
Subroutine prepare: called CC=1 SCAR=0.0
Pod documented
44 1 my %args = @_;
45  
46 ### store the arguments, so ->install can use them in recursive loops ###
47 1 $dist->status->_prepare_args( \%args );
48  
49 1 return $dist->status->prepared( 1 );
50 }
51  
52 sub create {
53 1 ▶ my $dist = shift;
Subroutine create: called CC=7 SCAR=20.3
Pod documented
54 1 my $self = $dist->parent;
55  
56 ### we're also the cpan_dist, since we don't need to have anything
57 ### prepared
58 1 ▶ $dist = $self->status->dist_cpan if $self->status->dist_cpan;
Branch: 1 branch
BranchTrueFalseTotal
if $self->status->dist_cpan 1 0 1
59 1 ▶ $self->status->dist_cpan( $dist ) unless $self->status->dist_cpan;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->status->dist_cpan 0 1 1
60  
61 1 my $cb = $self->parent;
62 1 my $conf = $cb->configure_object;
63 1 my %hash = @_;
64  
65 1 my( $force, $verbose, $prereq_target, $prereq_format, $prereq_build);
66  
67 1 my $args = do {
68 1 local $Params::Check::ALLOW_UNKNOWN = 1;
69 1 my $tmpl = {
70 force => { default => $conf->get_conf('force'),
71 store => \$force },
72 verbose => { default => $conf->get_conf('verbose'),
73 store => \$verbose },
74 prereq_target => { default => '', store => \$prereq_target },
75  
76 ### don't set the default prereq format to 'makemaker' -- wrong!
77 prereq_format => { #default => $self->status->installer_type,
78 default => '',
79 store => \$prereq_format },
80 prereq_build => { default => 0, store => \$prereq_build },
81 };
82  
83 1 ▶ check( $tmpl, \%hash ) or return;
Branch: 1 branch
BranchTrueFalseTotal
check($tmpl, \%hash) or return 0 1 1
84 };
85  
86 ### maybe we already ran a create on this object? ###
87 1 ▶ return 1 if $dist->status->created && !$force;
Branch: 1 branch
BranchTrueFalseTotal
if $dist->status->created and not $force 0 1 1
Condition33%1/3
$dist->status->created and not $force
!ll&&!rl&&r
100
MC/DC0%0/2
$dist->status->created and not $force
$dist->status->created not $force
Truth table33%1/3
A and not(B)
A= $dist->status->createdB= not $force
ABresult
0X0
100
111
88  
89 ### store the arguments, so ->install can use them in recursive loops ###
90 1 $dist->status->_create_args( \%hash );
91  
92 1 msg(loc("Resolving prerequisites mentioned in the bundle"), $verbose);
93  
94 ### this will set the directory back to the start
95 ### dir, so we must chdir /again/
96 1 my $ok = $dist->_resolve_prereqs(
97 format => $prereq_format,
98 verbose => $verbose,
99 prereqs => $self->status->prereqs,
100 target => $prereq_target,
101 force => $force,
102 prereq_build => $prereq_build,
103 );
104  
105 ### if all went well, mark it & return
106 1 ▶ return $dist->status->created( $ok ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
$ok ? : 1 0 1
107 }
108  
109 sub install {
110 0 ▶ my $dist = shift;
Subroutine install: not called CC=1 SCAR=6.9
Pod documented
111 0 my %args = @_;
112  
113 ### store the arguments, so ->install can use them in recursive loops ###
114 0 $dist->status->_install_args( \%args );
115  
116 0 return $dist->status->installed( 1 );
117 }
118  
119 4 1;
« lib/CPANPLUS.pm ↑ Summary blib/lib/CPANPLUS/Config/HomeEnv.pm »