line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Meta;
|
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
27206
|
use 5.005;
|
|
3
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
#use warnings;
|
5
|
3
|
|
|
3
|
|
10
|
use strict;
|
|
3
|
|
|
|
|
1
|
|
|
3
|
|
|
|
|
60
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Perl::Meta - Extract metadata from perl/pod text.
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.03
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut
|
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
3
|
|
9
|
use vars '$VERSION';
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1586
|
|
18
|
|
|
|
|
|
|
$VERSION = '0.03';
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use Perl::Meta;
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $pv = Perl::Meta::extract_perl_version(' use 5.10.1;');
|
26
|
|
|
|
|
|
|
...
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 extract_license
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Returns license code for META.yml/json from perl/pod text by matching several patterns.
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 extract_perl_version
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Returns perl version required in perl text.
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 extract_bugtracker
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Searches for bug tracker pod links in text. rt.cpan.org, github.com,
|
41
|
|
|
|
|
|
|
code.google.com are supported.
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub extract_license {
|
46
|
10
|
|
|
10
|
1
|
2305
|
my $pod = shift;
|
47
|
10
|
|
|
|
|
7
|
my $matched;
|
48
|
10
|
|
66
|
|
|
107
|
return _extract_license(
|
49
|
|
|
|
|
|
|
($matched) = $pod =~ m/
|
50
|
|
|
|
|
|
|
(=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?)
|
51
|
|
|
|
|
|
|
(=head \d.*|=cut.*|)\z
|
52
|
|
|
|
|
|
|
/xms
|
53
|
|
|
|
|
|
|
) || _extract_license(
|
54
|
|
|
|
|
|
|
($matched) = $pod =~ m/
|
55
|
|
|
|
|
|
|
(=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?)
|
56
|
|
|
|
|
|
|
(=head \d.*|=cut.*|)\z
|
57
|
|
|
|
|
|
|
/xms
|
58
|
|
|
|
|
|
|
);
|
59
|
|
|
|
|
|
|
}
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _extract_license {
|
62
|
16
|
100
|
|
16
|
|
125
|
my $license_text = shift or return;
|
63
|
10
|
|
|
|
|
76
|
my @phrases = (
|
64
|
|
|
|
|
|
|
'(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1,
|
65
|
|
|
|
|
|
|
'(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1,
|
66
|
|
|
|
|
|
|
'under the terms of either the GNU General Public License or the Artistic License' => 'perl', 1,
|
67
|
|
|
|
|
|
|
'Artistic and GPL' => 'perl', 1,
|
68
|
|
|
|
|
|
|
'GNU general public license' => 'gpl', 1,
|
69
|
|
|
|
|
|
|
'GNU public license' => 'gpl', 1,
|
70
|
|
|
|
|
|
|
'GNU lesser general public license' => 'lgpl', 1,
|
71
|
|
|
|
|
|
|
'GNU lesser public license' => 'lgpl', 1,
|
72
|
|
|
|
|
|
|
'GNU library general public license' => 'lgpl', 1,
|
73
|
|
|
|
|
|
|
'GNU library public license' => 'lgpl', 1,
|
74
|
|
|
|
|
|
|
'GNU Free Documentation license' => 'unrestricted', 1,
|
75
|
|
|
|
|
|
|
'GNU Affero General Public License' => 'open_source', 1,
|
76
|
|
|
|
|
|
|
'(?:Free)?BSD license' => 'bsd', 1,
|
77
|
|
|
|
|
|
|
'Artistic license 2\.0' => 'artistic_2', 1,
|
78
|
|
|
|
|
|
|
'Artistic license' => 'artistic', 1,
|
79
|
|
|
|
|
|
|
'Apache (?:Software )?license' => 'apache', 1,
|
80
|
|
|
|
|
|
|
'GPL' => 'gpl', 1,
|
81
|
|
|
|
|
|
|
'LGPL' => 'lgpl', 1,
|
82
|
|
|
|
|
|
|
'BSD' => 'bsd', 1,
|
83
|
|
|
|
|
|
|
'Artistic' => 'artistic', 1,
|
84
|
|
|
|
|
|
|
'MIT' => 'mit', 1,
|
85
|
|
|
|
|
|
|
'Mozilla Public License' => 'mozilla', 1,
|
86
|
|
|
|
|
|
|
'Q Public License' => 'open_source', 1,
|
87
|
|
|
|
|
|
|
'OpenSSL License' => 'unrestricted', 1,
|
88
|
|
|
|
|
|
|
'SSLeay License' => 'unrestricted', 1,
|
89
|
|
|
|
|
|
|
'The beer-?ware license' => 'unrestricted', 1,
|
90
|
|
|
|
|
|
|
'zlib License' => 'open_source', 1,
|
91
|
|
|
|
|
|
|
'proprietary' => 'proprietary', 0,
|
92
|
|
|
|
|
|
|
);
|
93
|
10
|
|
|
|
|
27
|
while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) {
|
94
|
43
|
|
|
|
|
163
|
$pattern =~ s#\s+#\\s+#gs;
|
95
|
43
|
100
|
|
|
|
656
|
if ( $license_text =~ /\b$pattern\b/i ) {
|
96
|
10
|
|
|
|
|
54
|
return $license;
|
97
|
|
|
|
|
|
|
}
|
98
|
|
|
|
|
|
|
}
|
99
|
0
|
|
|
|
|
0
|
return '';
|
100
|
|
|
|
|
|
|
}
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub extract_perl_version {
|
104
|
3
|
100
|
|
3
|
1
|
726
|
if (
|
105
|
|
|
|
|
|
|
$_[0] =~ m/
|
106
|
|
|
|
|
|
|
^\s*
|
107
|
|
|
|
|
|
|
(?:use|require) \s*
|
108
|
|
|
|
|
|
|
v?
|
109
|
|
|
|
|
|
|
([\d_\.]+)
|
110
|
|
|
|
|
|
|
\s* ;
|
111
|
|
|
|
|
|
|
/ixms
|
112
|
|
|
|
|
|
|
) {
|
113
|
2
|
|
|
|
|
4
|
my $perl_version = $1;
|
114
|
2
|
|
|
|
|
2
|
$perl_version =~ s{_}{}g;
|
115
|
2
|
|
|
|
|
4
|
return $perl_version;
|
116
|
|
|
|
|
|
|
} else {
|
117
|
1
|
|
|
|
|
2
|
return;
|
118
|
|
|
|
|
|
|
}
|
119
|
|
|
|
|
|
|
}
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub extract_bugtracker {
|
123
|
6
|
|
|
6
|
1
|
1950
|
my @links = $_[0] =~ m#L<(
|
124
|
|
|
|
|
|
|
https?\Q://rt.cpan.org/\E[^>]+|
|
125
|
|
|
|
|
|
|
https?\Q://github.com/\E[\w_]+/[\w_]+/issues|
|
126
|
|
|
|
|
|
|
https?\Q://code.google.com/p/\E[\w_\-]+/issues/list
|
127
|
|
|
|
|
|
|
)>#gx;
|
128
|
6
|
|
|
|
|
6
|
my %links;
|
129
|
6
|
|
|
|
|
10
|
@links{@links}=();
|
130
|
6
|
|
|
|
|
12
|
@links=keys %links;
|
131
|
6
|
|
|
|
|
14
|
return @links;
|
132
|
|
|
|
|
|
|
}
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 AUTHOR
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Alexandr Ciornii, C<< >>
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 BUGS
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through
|
141
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll
|
142
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes.
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 SUPPORT
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command.
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
perldoc Perl::Meta
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
You can also look for information at:
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=over 4
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
L
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
L
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item * CPAN Ratings
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
L
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item * Search CPAN
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
L
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=back
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT
|
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Copyright 2010 - 2017 Alexandr Ciornii.
|
183
|
|
|
|
|
|
|
Copyright 2002 - 2011 Brian Ingerson, Audrey Tang and Adam Kennedy.
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
186
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published
|
187
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License.
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information.
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=cut
|
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
1; # End of Perl::Meta
|