CPAN-Index-API
view release on metacpan or search on metacpan
lib/CPAN/Index/API/File/MailRc.pm view on Meta::CPAN
package CPAN::Index::API::File::MailRc;
our $VERSION = '0.008';
use strict;
use warnings;
use Scalar::Util qw(blessed);
use namespace::autoclean;
use Moose;
with qw(
CPAN::Index::API::Role::Writable
CPAN::Index::API::Role::Readable
CPAN::Index::API::Role::Clonable
);
has authors => (
is => 'bare',
isa => 'ArrayRef',
default => sub { [] },
traits => ['Array'],
handles => {
author_count => 'count',
authors => 'elements',
},
);
sub sorted_authors {
my $self = shift;
return sort { $a->{authorid} cmp $b->{authorid} } $self->authors;
}
sub parse {
my ( $self, $content ) = @_;
my @authors;
if ($content)
{
foreach my $line ( split "\n", $content ) {
my ( $alias, $authorid, $long ) = split ' ', $line, 3;
$long =~ s/^"//;
$long =~ s/"$//;
my ($name, $email) = $long =~ /(.*) <(.+)>$/;
undef $email if $email eq 'CENSORED';
my $author = {
authorid => $authorid,
name => $name,
email => $email,
};
push @authors, $author;
}
}
return ( authors => \@authors );
}
sub default_location { 'authors/01mailrc.txt.gz' }
__PACKAGE__->meta->make_immutable;
=pod
=encoding UTF-8
( run in 0.684 second using v1.01-cache-2.11-cpan-39bf76dae61 )