1 package CPANPLUS::Module::Author;
6 use Params::Check qw[check];
7 use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext';
9 local $Params::Check::VERBOSE = 1;
15 CPANPLUS::Module::Author
19 my $author = CPANPLUS::Module::Author->new(
20 author => 'Jack Ashton',
22 _id => INTERNALS_OBJECT_ID,
29 @dists = $author->distributions;
30 @mods = $author->modules;
32 @accessors = CPANPLUS::Module::Author->accessors;
36 C<CPANPLUS::Module::Author> creates objects from the information in the
37 source files. These can then be used to query on.
39 These objects should only be created internally. For C<fake> objects,
40 there's the C<CPANPLUS::Module::Author::Fake> class.
44 An objects of this class has the following accessors:
54 The CPAN id of the author.
58 The email address of the author, which defaults to '' if not provided.
62 The C<CPANPLUS::Internals::Object> that spawned this module object.
69 author => { required => 1 }, # full name of the author
70 cpanid => { required => 1 }, # cpan id
71 email => { default => '' }, # email address of the author
72 _id => { required => 1 }, # id of the Internals object that spawned us
75 ### autogenerate accessors ###
76 for my $key ( keys %$tmpl ) {
78 *{__PACKAGE__."::$key"} = sub {
80 $self->{$key} = $_[0] if @_;
87 my $obj = CPANPLUS::Internals->_retrieve_id( $self->_id );
96 =head2 $auth = CPANPLUS::Module::Author->new( author => AUTHOR_NAME, cpanid => CPAN_ID, _id => INTERNALS_ID [, email => AUTHOR_EMAIL] )
98 This method returns a C<CPANPLUS::Module::Author> object, based on the given
101 Returns false on failure.
109 ### don't check the template for sanity
110 ### -- we know it's good and saves a lot of performance
111 local $Params::Check::SANITY_CHECK_TEMPLATE = 0;
113 my $object = check( $tmpl, \%hash ) or return;
115 return bless $object, $class;
120 =head2 @mod_objs = $auth->modules()
122 Return a list of module objects this author has released.
128 my $cb = $self->parent;
130 my $aref = $cb->_search_module_tree(
134 return @$aref if $aref;
140 =head2 @dists = $auth->distributions()
142 Returns a list of module objects representing all the distributions
143 this author has released.
151 local $Params::Check::ALLOW_UNKNOWN = 1;
152 local $Params::Check::NO_DUPLICATES = 1;
156 module => { default => '', store => \$mod },
159 my $args = check( $tmpl, \%hash ) or return;
161 ### if we didn't get a module object passed, we'll find one ourselves ###
163 my @list = $self->modules;
167 error( loc( "This author has released no modules" ) );
172 my $file = $mod->checksums( %hash );
173 my $href = $mod->_parse_checksums_file( file => $file ) or return;
176 for my $dist ( keys %$href ) {
177 my $clone = $mod->clone;
179 $clone->package( $dist );
180 $clone->module( $clone->package_name );
181 $clone->version( $clone->package_version );
182 $clone->mtime( $href->{$dist}->{'mtime'} ); # release date
184 ### .meta files are now also in the checksums file,
185 ### which means we have to filter out things that dont
187 push @rv, $clone if $clone->package_extension;
200 Returns a list of all accessor methods to the object
204 sub accessors { return keys %$tmpl };
209 # c-indentation-style: bsd
211 # indent-tabs-mode: nil
213 # vim: expandtab shiftwidth=4: