API/File/MailRc.pm

filter: Statementstmt 94.4% 34 / 36 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 100% 3 / 3 totaltotal 90.3% 47 / 52 CC 4 SCAR 7.7
CC
4
Cov
92%
parse
4.0
__ANON__
2.0
default_location
2.0
CRAP 2.2
« API/File/PackagesDetails.pm ↑ Summary API/Role/Clonable.pm »
1 package CPAN::Index::API::File::MailRc;
2  
3 1 our $VERSION = '0.008';
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 with qw(
12 CPAN::Index::API::Role::Writable
13 CPAN::Index::API::Role::Readable
14 CPAN::Index::API::Role::Clonable
15 );
16  
17 has authors => (
18 is => 'bare',
19 isa => 'ArrayRef',
20 0 ▶ default => sub { [] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 1 traits => ['Array'],
22 handles => {
23 author_count => 'count',
24 authors => 'elements',
25 },
26 );
27  
28 1 ▶sub sorted_authors {
Subroutine sorted_authors: called CC=1 SCAR=0.0
Pod documented
29 1 my $self = shift;
30 1 return sort { $a->{authorid} cmp $b->{authorid} } $self->authors;
31 }
32  
33 1 ▶sub parse {
Subroutine parse: called CC=4 SCAR=13.9
Pod documented
34 1 my ( $self, $content ) = @_;
35  
36 1 my @authors;
37  
38 1 ▶ if ($content)
Branch: 1 branch
BranchTrueFalseTotal
if ($content) 1 0 1
39 {
40  
41 1 foreach my $line ( split "\n", $content ) {
42 3 my ( $alias, $authorid, $long ) = split ' ', $line, 3;
43 3 $long =~ s/^"//;
44 3 $long =~ s/"$//;
45 3 my ($name, $email) = $long =~ /(.*) <(.+)>$/;
46  
47 3 ▶ undef $email if $email eq 'CENSORED';
Branch: 1 branch
BranchTrueFalseTotal
if $email eq "CENSORED" 1 2 3
48  
49 3 my $author = {
50 authorid => $authorid,
51 name => $name,
52 email => $email,
53 };
54  
55 3 push @authors, $author;
56 }
57 }
58  
59 1 return ( authors => \@authors );
60 }
61  
62 0 ▶sub default_location { 'authors/01mailrc.txt.gz' }
Subroutine default_location: not called CC=1 SCAR=6.9
Pod documented
63  
64 1 __PACKAGE__->meta->make_immutable;
65  
66 =pod
67  
68 =encoding UTF-8
69  
70 =head1 NAME
71  
72 CPAN::Index::File::MailRc - Interface to C<01mailrc.txt>.
73  
74 =head1 SYNOPSIS
75  
76 my $mailrc = CPAN::Index::File::MailRc->parse_from_repo_uri(
77 'http://cpan.perl.org'
78 );
79  
80 foreach my $author ($mailrc->sorted_authors) {
81 ... # do something
82 }
83  
84 =head1 DESCRIPTION
85  
86 This is a class to read and write C<01mailrc.txt>.
87  
88 =head1 METHODS
89  
90 =head2 authors
91  
92 List of hashrefs containing author data. The structure of the hashrefs is
93 as follows:
94  
95 =over
96  
97 =item authorid
98  
99 CPAN id of the author. This should be a string containing only capital Latin
100 letters and is at least 2 characters long.
101  
102 =item name
103  
104 Author's full name.
105  
106 =item email
107  
108 Author's email.
109  
110 =back
111  
112 =head2 sorted_authors
113  
114 List of authors sorted by pause id.
115  
116 =head2 parse
117  
118 Parses the file and returns its representation as a data structure.
119  
120 =head2 default_location
121  
122 Default file location - C<authors/01mailrc.txt.gz>.
123  
124 =head1 METHODS FROM ROLES
125  
126 =over
127  
128 =item <CPAN::Index::API::Role::Readable/read_from_string>
129  
130 =item <CPAN::Index::API::Role::Readable/read_from_file>
131  
132 =item <CPAN::Index::API::Role::Readable/read_from_tarball>
133  
134 =item <CPAN::Index::API::Role::Readable/read_from_repo_path>
135  
136 =item <CPAN::Index::API::Role::Readable/read_from_repo_uri>
137  
138 =item L<CPAN::Index::API::Role::Writable/tarball_is_default>
139  
140 =item L<CPAN::Index::API::Role::Writable/repo_path>
141  
142 =item L<CPAN::Index::API::Role::Writable/template>
143  
144 =item L<CPAN::Index::API::Role::Writable/content>
145  
146 =item L<CPAN::Index::API::Role::Writable/write_to_file>
147  
148 =item L<CPAN::Index::API::Role::Writable/write_to_tarball>
149  
150 =item L<CPAN::Index::API::Role::Clonable/clone>
151  
152 =back
153  
154 =cut
155  
156 __DATA__
« API/File/PackagesDetails.pm ↑ Summary API/Role/Clonable.pm »