line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Stash::Contributors; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:YANICK'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Stash containing list of contributors |
4
|
|
|
|
|
|
|
$Dist::Zilla::Stash::Contributors::VERSION = '0.1.1'; |
5
|
1
|
|
|
1
|
|
425
|
use strict; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
23
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
420
|
use Moose; |
|
1
|
|
|
|
|
374748
|
|
|
1
|
|
|
|
|
6
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6511
|
use Dist::Zilla::Stash::Contributors::Contributor; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
270
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has contributors => ( |
13
|
|
|
|
|
|
|
traits => [ 'Hash' ], |
14
|
|
|
|
|
|
|
isa => 'HashRef[Dist::Zilla::Stash::Contributors::Contributor]', |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
default => sub { {} }, |
17
|
|
|
|
|
|
|
handles => { |
18
|
|
|
|
|
|
|
_all_contributors => 'values', |
19
|
|
|
|
|
|
|
nbr_contributors => 'count', |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub all_contributors { |
25
|
2
|
|
|
2
|
1
|
8
|
my $self = shift; |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
76
|
return sort { $a->stringify cmp $b->stringify } $self->_all_contributors; |
|
2
|
|
|
|
|
6
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub add_contributors { |
32
|
1
|
|
|
1
|
1
|
9
|
my ( $self, @contributors ) = @_; |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
3
|
for my $c ( @contributors ) { |
35
|
3
|
|
|
|
|
6
|
my $name = $c; |
36
|
3
|
|
|
|
|
4
|
my $email; |
37
|
3
|
50
|
|
|
|
20
|
$email = $1 if $name =~ s/\s*<(.*?)>\s*//; |
38
|
|
|
|
|
|
|
|
39
|
3
|
|
|
|
|
97
|
my $object = Dist::Zilla::Stash::Contributors::Contributor->new( |
40
|
|
|
|
|
|
|
name => $name, email => $email |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
3
|
|
66
|
|
|
95
|
$self->contributors->{ $object->stringify } ||= $object; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=pod |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=encoding UTF-8 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Dist::Zilla::Stash::Contributors - Stash containing list of contributors |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 VERSION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
version 0.1.1 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SYNOPSIS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $contrib_stash = $self->zilla->stash_named('%Contributors'); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
unless ( $contrib_stash ) { |
71
|
|
|
|
|
|
|
$contrib_stash = Dist::Zilla::Stash::Contributors->new; |
72
|
|
|
|
|
|
|
$self->_register_stash('%Contributors', $contrib_stash ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$contrib_stash->add_contributors( 'Yanick Champoux <yanick@cpan.org>' ); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 DESCRIPTION |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
If you are a L<Dist::Zilla> user, avert your eyes and read no more: this |
80
|
|
|
|
|
|
|
module is not for general consumption but for authors of plugins dealing |
81
|
|
|
|
|
|
|
with contributors harvesting or processing. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Oh, you're one of those? Excellent. Well, here's the deal: this is a |
84
|
|
|
|
|
|
|
stash that is meant to carry the contributors' information between plugins. |
85
|
|
|
|
|
|
|
Plugins that gather contributors can populate the list with code looking like |
86
|
|
|
|
|
|
|
this: |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub before_build { |
89
|
|
|
|
|
|
|
my $self = shift; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
...; # gather @collaborators, somehow |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my $contrib_stash = $self->zilla->stash_named('%Contributors'); |
94
|
|
|
|
|
|
|
unless ( $contrib_stash ) { |
95
|
|
|
|
|
|
|
$contrib_stash = Dist::Zilla::Stash::Contributors->new; |
96
|
|
|
|
|
|
|
$self->_register_stash('%Contributors', $contrib_stash ); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$contrib_stash->add_contributors( @contributors ); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
and plugin that use them: |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# of course, make sure this is run *after* the gatherers did their job |
105
|
|
|
|
|
|
|
sub before_build { |
106
|
|
|
|
|
|
|
my $self = shift; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $contrib_stash = $self->zilla->stash_named('%Contributors') |
109
|
|
|
|
|
|
|
or return; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my @contributors = $contrib_stash->all_contributors; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
And that's pretty much all you need to know beside that, internally, each contributor is represented by |
115
|
|
|
|
|
|
|
a L<Dist::Zilla::Stash::Contributors::Contributor> object. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 METHODS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 all_contributors() |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns all contributors as C<Dist::Zilla::Stash::Contributors::Contributor> |
122
|
|
|
|
|
|
|
objects. The collaborators are sorted alphabetically. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 nbr_contributors() |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Returns the number of contributors. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 add_contributors( @contributors ) |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Adds the C<@contributors> to the stash. Duplicates are filtered out. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Contributors can be L<Dist::Zilla::Stash::Contributors::Contributor> objects |
133
|
|
|
|
|
|
|
or strings of the format 'Full Name <email@address.org>'. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 AUTHOR |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Yanick Champoux <yanick@cpan.org> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This software is copyright (c) 2019, 2013 by Yanick Champoux. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
144
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |