File Coverage

lib/CPANPLUS/Module/Author/Fake.pm
Criterion Covered Total %
statement 25 27 92.6
branch 3 6 50.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 36 41 87.8


line stmt bran cond sub pod time code
1             package CPANPLUS::Module::Author::Fake;
2              
3              
4 15     15   526 use CPANPLUS::Module::Author;
  15         155  
  15         384  
5 15     15   287 use CPANPLUS::Internals;
  15         281  
  15         351  
6 15     15   883 use CPANPLUS::Error;
  15         183  
  15         3122  
7              
8 15     15   246 use strict;
  15         174  
  15         208  
9 15     15   243 use vars qw[@ISA];
  15         140  
  15         359  
10 15     15   283 use Params::Check qw[check];
  15         140  
  15         342  
11              
12             @ISA = qw[CPANPLUS::Module::Author];
13              
14             $Params::Check::VERBOSE = 1;
15              
16             =pod
17            
18             =head1 NAME
19            
20             CPANPLUS::Module::Author::Fake
21            
22             =head1 SYNOPSIS
23            
24             my $auth = CPANPLUS::Module::Author::Fake->new(
25             name => 'Foo Bar',
26             email => 'luser@foo.com',
27             cpanid => 'FOO',
28             _id => $cpan->id,
29             );
30            
31             =head1 DESCRIPTION
32            
33             A class for creating fake author objects, for shortcut use internally
34             by CPANPLUS.
35            
36             Inherits from C<CPANPLUS::Module::Author>.
37            
38             =head1 METHODS
39            
40             =head2 new( _id => DIGIT )
41            
42             Creates a dummy author object. It can take the same options as
43             C<< CPANPLUS::Module::Author->new >>, but will fill in default ones
44             if none are provided. Only the _id key is required.
45            
46             =cut
47              
48             sub new {
49 42     42 1 2616     my $class = shift;
50 42         598     my %hash = @_;
51              
52 42         1214     my $tmpl = {
53                     author => { default => 'CPANPLUS Internals' },
54                     email => { default => 'cpanplus-info@lists.sf.net' },
55                     cpanid => { default => 'CPANPLUS' },
56                     _id => { default => CPANPLUS::Internals->_last_id },
57                 };
58              
59 42 50       773     my $args = check( $tmpl, \%hash ) or return;
60              
61 42 50       1788     my $obj = CPANPLUS::Module::Author->new( %$args ) or return;
62              
63 42 50       1311     unless( $obj->_id ) {
64 0         0         error(loc("No '%1' specified -- No CPANPLUS object associated!",'_id'));
65 0         0         return;
66                 }
67              
68             ### rebless object ###
69 42         1527     return bless $obj, $class;
70             }
71              
72             1;
73              
74              
75             # Local variables:
76             # c-indentation-style: bsd
77             # c-basic-offset: 4
78             # indent-tabs-mode: nil
79             # End:
80             # vim: expandtab shiftwidth=4:
81