lib/CPANPLUS/Module/Fake.pm

filter: Statementstmt 94.4% 34 / 36 Branchbran 50.0% 3 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 85.7% 48 / 56 SCAR 16.2
CC
5
Cov
87%
new
5.7
BEGIN
1.0
BEGIN
1.0
CRAP 5.1
« blib/lib/CPANPLUS/Module/Fake.pm ↑ Summary lib/CPANPLUS/Module/Author/Fake.pm »
1 package CPANPLUS::Module::Fake;
2  
3  
4 16 ▶use CPANPLUS::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 16 ▶use CPANPLUS::Module;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 16 ▶use CPANPLUS::Module::Author::Fake;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 16 ▶use CPANPLUS::Internals;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 16 ▶use vars qw[@ISA $VERSION];
Subroutine BEGIN: called CC=1 SCAR=0.0
11 16 ▶use Params::Check qw[check];
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 16 $VERSION = "0.9912";
14 16 @ISA = qw[CPANPLUS::Module];
15 16 $Params::Check::VERBOSE = 1;
16  
17 =pod
18  
19 =head1 NAME
20  
21 CPANPLUS::Module::Fake - fake module object for internal use
22  
23 =head1 SYNOPSIS
24  
25 my $obj = CPANPLUS::Module::Fake->new(
26 module => 'Foo',
27 path => 'ftp/path/to/foo',
28 author => CPANPLUS::Module::Author::Fake->new,
29 package => 'fake-1.1.tgz',
30 _id => $cpan->_id,
31 );
32  
33 =head1 DESCRIPTION
34  
35 A class for creating fake module objects, for shortcut use internally
36 by CPANPLUS.
37  
38 Inherits from C<CPANPLUS::Module>.
39  
40 =head1 METHODS
41  
42 =head2 new( module => $mod, path => $path, package => $pkg, [_id => DIGIT] )
43  
44 Creates a dummy module object from the above parameters. It can
45 take more options (same as C<< CPANPLUS::Module->new >> but the above
46 are required.
47  
48 =cut
49  
50 sub new {
51 147 ▶ my $class = shift;
Subroutine new: called CC=5 SCAR=17.4
Pod documented
52 147 my %hash = @_;
53  
54 147 local $Params::Check::ALLOW_UNKNOWN = 1;
55  
56 147 my $tmpl = {
57 module => { required => 1 },
58 path => { required => 1 },
59 package => { required => 1 },
60 _id => { default => CPANPLUS::Internals->_last_id },
61 author => { default => '' },
62 };
63  
64 147 ▶ my $args = check( $tmpl, \%hash ) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $args = check($tmpl, \%hash) or return 0 147 147
65  
66 $args->{author} ||= CPANPLUS::Module::Author::Fake->new(
67 147 ▶ _id => $args->{_id} );
Condition66%2/3
$args->{"author"} ||= "CPANPLUS::Module::Author::Fake"->new("_id", $args->{"_id"})
l!l&&r!l&&!r
116310
MC/DC0%0/2
$args->{"author"} ||= "CPANPLUS::Module::Author::Fake"->new("_id", $args->{"_id"})
$args->{"author"} "CPANPLUS::Module::Author::Fake"->new("_id", $args->{"_id"})
Truth table66%2/3
A ||= B
A= $args->{"author"}B= "CPANPLUS::Module::Author::Fake"->new("_id", $args->{"_id"})
ABresult
1X1
011
000
68  
69 147 ▶ my $obj = CPANPLUS::Module->new( %$args ) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $obj = "CPANPLUS::Module"->new(%$args) or return 0 147 147
70  
71 147 ▶ unless( $obj->_id ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($obj->_id) 0 147 147
72 0 error(loc("No '%1' specified -- No CPANPLUS object associated!",'_id'));
73 0 return;
74 }
75  
76 ### rebless object ###
77 147 return bless $obj, $class;
78 }
79  
80 16 1;
81  
82 # Local variables:
83 # c-indentation-style: bsd
84 # c-basic-offset: 4
85 # indent-tabs-mode: nil
86 # End:
87 # vim: expandtab shiftwidth=4:
« blib/lib/CPANPLUS/Module/Fake.pm ↑ Summary lib/CPANPLUS/Module/Author/Fake.pm »