line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
2413809
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
136
|
|
2
|
5
|
|
|
5
|
|
19
|
use warnings; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
233
|
|
3
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::Keywords; # git description: v0.006-22-g3b1a3ad |
4
|
|
|
|
|
|
|
# vim: set ts=8 sts=4 sw=4 tw=115 et : |
5
|
|
|
|
|
|
|
# ABSTRACT: Add keywords to metadata in your distribution |
6
|
|
|
|
|
|
|
# KEYWORDS: plugin distribution metadata cpan-meta keywords |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.007'; |
9
|
|
|
|
|
|
|
|
10
|
5
|
|
|
5
|
|
16
|
use Moose; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
32
|
|
11
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::MetaProvider', |
12
|
|
|
|
|
|
|
'Dist::Zilla::Role::PPI' => { -version => '5.009' }; |
13
|
5
|
|
|
5
|
|
20152
|
use Moose::Util::TypeConstraints; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
34
|
|
14
|
5
|
|
|
5
|
|
5922
|
use MooseX::Types::Moose 'ArrayRef'; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
65
|
|
15
|
5
|
|
|
5
|
|
17294
|
use MooseX::Types::Common::String 'NonEmptySimpleStr'; |
|
5
|
|
|
|
|
248488
|
|
|
5
|
|
|
|
|
29
|
|
16
|
5
|
|
|
5
|
|
9291
|
use Encode (); |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
74
|
|
17
|
5
|
|
|
5
|
|
19
|
use namespace::autoclean; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
40
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $word = subtype NonEmptySimpleStr, |
20
|
|
|
|
|
|
|
where { !/\s/ }; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $wordlist = subtype ArrayRef[$word]; |
23
|
|
|
|
|
|
|
coerce $wordlist, from ArrayRef[NonEmptySimpleStr], |
24
|
|
|
|
|
|
|
via { [ map { split /\s+/, $_ } @$_ ] }; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
9
|
|
|
9
|
0
|
990
|
sub mvp_aliases { +{ keyword => 'keywords' } } |
28
|
9
|
|
|
9
|
0
|
136353
|
sub mvp_multivalue_args { qw(keywords) } |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has keywords => ( |
31
|
|
|
|
|
|
|
is => 'ro', isa => $wordlist, |
32
|
|
|
|
|
|
|
coerce => 1, |
33
|
|
|
|
|
|
|
lazy => 1, |
34
|
|
|
|
|
|
|
default => sub { |
35
|
|
|
|
|
|
|
my $self = shift; |
36
|
|
|
|
|
|
|
my @keywords = $self->keywords_from_file($self->zilla->main_module); |
37
|
|
|
|
|
|
|
\@keywords; |
38
|
|
|
|
|
|
|
}, |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
around dump_config => sub |
42
|
|
|
|
|
|
|
{ |
43
|
|
|
|
|
|
|
my ($orig, $self) = @_; |
44
|
|
|
|
|
|
|
my $config = $self->$orig; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$config->{+__PACKAGE__} = { |
47
|
|
|
|
|
|
|
keywords => $self->keywords, |
48
|
|
|
|
|
|
|
blessed($self) ne __PACKAGE__ ? ( version => $VERSION ) : (), |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
return $config; |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub metadata |
54
|
|
|
|
|
|
|
{ |
55
|
9
|
|
|
9
|
0
|
143131
|
my $self = shift; |
56
|
|
|
|
|
|
|
|
57
|
9
|
|
|
|
|
334
|
my $keywords = $self->keywords; |
58
|
|
|
|
|
|
|
return { |
59
|
9
|
100
|
|
|
|
56
|
@$keywords ? ( keywords => $keywords ) : () |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub keywords_from_file |
64
|
|
|
|
|
|
|
{ |
65
|
3
|
|
|
3
|
0
|
4183
|
my ($self, $file) = @_; |
66
|
|
|
|
|
|
|
|
67
|
3
|
|
|
|
|
16
|
my $document = $self->ppi_document_for_file($file); |
68
|
|
|
|
|
|
|
|
69
|
3
|
|
|
|
|
239498
|
my $keywords; |
70
|
|
|
|
|
|
|
$document->find( |
71
|
|
|
|
|
|
|
sub { |
72
|
33
|
100
|
100
|
33
|
|
313
|
die if $_[1]->isa('PPI::Token::Comment') |
73
|
|
|
|
|
|
|
and ($keywords) = $_[1]->content =~ m/^\s*#+\s*KEYWORDS:\s*(.+)$/m; |
74
|
|
|
|
|
|
|
} |
75
|
3
|
|
|
|
|
29
|
); |
76
|
3
|
100
|
|
|
|
60
|
return if not $keywords; |
77
|
|
|
|
|
|
|
|
78
|
2
|
50
|
|
|
|
4
|
if (not eval { Dist::Zilla::Role::PPI->VERSION('6.003') }) |
|
2
|
|
|
|
|
43
|
|
79
|
|
|
|
|
|
|
{ |
80
|
|
|
|
|
|
|
# older Dist::Zilla::Role::PPI passes encoded content to PPI |
81
|
2
|
|
|
|
|
75
|
$keywords = Encode::decode($file->encoding, $keywords, Encode::FB_CROAK); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
2
|
|
|
|
|
437
|
$self->log_debug('found keyword string in main module: ' . $keywords); |
85
|
2
|
|
|
|
|
767
|
return split /\s+/, $keywords; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=pod |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=encoding UTF-8 |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 NAME |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Dist::Zilla::Plugin::Keywords - Add keywords to metadata in your distribution |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 VERSION |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
version 0.007 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SYNOPSIS |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
In your F<dist.ini>: |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
[Keywords] |
109
|
|
|
|
|
|
|
keyword = plugin |
110
|
|
|
|
|
|
|
keyword = tool |
111
|
|
|
|
|
|
|
keywords = development Dist::Zilla |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Or, in your F<dist.ini>: |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
[Keywords] |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
And in your main module: |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# KEYWORDS: plugin development tool |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 DESCRIPTION |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This plugin adds metadata to your distribution under the C<keywords> field. |
124
|
|
|
|
|
|
|
The L<CPAN meta specification|CPAN::Meta::Spec/keywords> |
125
|
|
|
|
|
|
|
defines this field as: |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
A List of keywords that describe this distribution. Keywords must not include whitespace. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=for Pod::Coverage metadata mvp_aliases mvp_multivalue_args keywords_from_file |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 CONFIGURATION OPTIONS |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 C<keyword>, C<keywords> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
One or more words to be added as keywords. Can be repeated more than once. |
136
|
|
|
|
|
|
|
Strings are broken up by whitespace and added as separate words. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
If no configuration is provided, the main module of your distribution is |
139
|
|
|
|
|
|
|
scanned for the I<first> C<# KEYWORDS:> comment. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 SEE ALSO |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=over 4 |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item * |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
L<CPAN::Meta::Spec/keywords> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=back |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 SUPPORT |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-Keywords> |
154
|
|
|
|
|
|
|
(or L<bug-Dist-Zilla-Plugin-Keywords@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-Keywords@rt.cpan.org>). |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
157
|
|
|
|
|
|
|
L<http://dzil.org/#mailing-list>. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
160
|
|
|
|
|
|
|
L<C<#distzilla> on C<irc.perl.org>|irc://irc.perl.org/#distzilla>. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
I am also usually active on irc, as 'ether' at C<irc.perl.org>. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 AUTHOR |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Karen Etheridge. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
173
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |