blib/lib/Dist/Zilla/Plugin/ContributorsFromPod.pm

filter: Statementstmt 71.8% 23 / 32 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 0.0% 0 / 1 totaltotal 66.6% 30 / 45 CC 2 SCAR 7.4
CC
2
Cov
68%
metadata
6.0
_build__contributors
2.0
__ANON__
2.0
CRAP 2.1
↑ Summary
1 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Dist::Zilla::Plugin::ContributorsFromPod;
3 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 $Dist::Zilla::Plugin::ContributorsFromPod::AUTHORITY = 'cpan:RKITOVER';
5 }
6 1 $Dist::Zilla::Plugin::ContributorsFromPod::VERSION = '0.01';
7 1 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use MooseX::Types::Moose qw/ArrayRef Str/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Pod::Text;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use List::AllUtils 'apply';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 with 'Dist::Zilla::Role::MetaProvider';
14  
15 =encoding UTF-8
16  
17 =head1 NAME
18  
19 Dist::Zilla::Plugin::ContributorsFromPod - Populate meta x_contributors
20 from CONTRIBUTORS POD in the dist
21  
22 =head1 SYNOPSIS
23  
24 in dist.ini:
25  
26 [ContributorsFromPod]
27  
28 =head1 DESCRIPTION
29  
30 If you have a
31  
32 =head1 CONTRIBUTORS
33  
34 section in your main file in your distribution, this L<Dist::Zilla>
35 plugin will populate your META.json x_contributors list from it.
36  
37 The format should be:
38  
39 Some Name <some@email.com>
40  
41 nicknames are also supported:
42  
43 ircnick: Some Name <some@email.com>
44  
45 B<NOTE:> the word C<CONTRIBUTORS> must be in upper case, and the
46 following C<=head1> section must also be in upper case. C<CONTRIBUTORS>
47 being the last C<=head1> section is also fine. This is because we use a
48 regex to parse out the list from Pod::Text.
49  
50 =cut
51  
52 1 has _contributors => (is => 'ro', isa => ArrayRef[Str], lazy_build => 1);
53  
54 0 ▶sub metadata {
Subroutine metadata: not called CC=2 SCAR=17.9
Pod undocumented
55 0 my $self = shift;
56  
57 0 ▶ return $self->_contributors ? { 'x_contributors' => $self->_contributors } : {};
Branch: 1 branch
BranchTrueFalseTotal
$self->_contributors ? : 0 0 0
58 }
59  
60 0 ▶sub _build__contributors {
Subroutine _build__contributors: not called CC=1 SCAR=6.9
61 0 my $self = shift;
62  
63 0 my $pod_parser = Pod::Text->new(
64 code => 1,
65 errors => 'die',
66 indent => 0,
67 quotes => 'none',
68 width => ~0
69 );
70  
71 0 $pod_parser->output_string(\my $output);
72  
73 0 $pod_parser->parse_file($self->zilla->main_module->name);
74  
75 # grab the actual contributors section
76  
77 0 my ($emails) = $output =~ /^CONTRIBUTOR[[:upper:]\s]*\s (.+?) (?:^[[:upper:][:punct:]\s]+$ | \s*\Z)/msx;
78  
79 return [
80 0 ▶ apply { s/^\S+?:\s*// } # strip irc_nic: ... prefixes
Subroutine __ANON__: not called CC=1 SCAR=6.9
81 0 grep /^[^<>@]+ <[^<>]+ \@ [^<>]+> \s*$/x, # loose filter for contributor lines
82 split /\s*(?:\r?\n)+\s*/, $emails # split by newline
83 ];
84 }
85  
86 =head1 SEE ALSO
87  
88 =over 4
89  
90 =item * L<Dist::Zilla::Plugin::ContributorsFromGit>
91  
92 =item * L<Dist::Zilla::Role::MetaProvider>
93  
94 =back
95  
96 =head1 AUTHOR
97  
98 Rafael Kitover <rkitover@cpan.org>
99  
100 =cut
101  
102 1 __PACKAGE__->meta->make_immutable;
103  
104 1 __PACKAGE__; # End of Dist::Zilla::Plugin::ContributorsFromPod
↑ Summary