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