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