176
178
$self->{values}->{perl_version} = $version;
181
perl => 'http://dev.perl.org/licenses/',
182
apache => 'http://apache.org/licenses/LICENSE-2.0',
183
artistic => 'http://opensource.org/licenses/artistic-license.php',
184
artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php',
185
lgpl => 'http://opensource.org/licenses/lgpl-license.php',
186
lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php',
187
lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html',
188
bsd => 'http://opensource.org/licenses/bsd-license.php',
189
gpl => 'http://opensource.org/licenses/gpl-license.php',
190
gpl2 => 'http://opensource.org/licenses/gpl-2.0.php',
191
gpl3 => 'http://opensource.org/licenses/gpl-3.0.html',
192
mit => 'http://opensource.org/licenses/mit-license.php',
193
mozilla => 'http://opensource.org/licenses/mozilla1.1.php',
194
open_source => undef,
195
unrestricted => undef,
196
restrictive => undef,
202
return $self->{values}->{license} unless @_;
203
my $license = shift or die(
204
'Did not provide a value to license()'
206
$self->{values}->{license} = $license;
208
# Automatically fill in license URLs
209
if ( $license_urls{$license} ) {
210
$self->resources( license => $license_urls{$license} );
217
182
my ( $self, $file ) = @_;
430
398
my $author = $1 || $2;
431
$author =~ s{E<lt>}{<}g;
432
$author =~ s{E<gt>}{>}g;
400
# XXX: ugly but should work anyway...
401
if (eval "require Pod::Escapes; 1") {
402
# Pod::Escapes has a mapping table.
403
# It's in core of perl >= 5.9.3, and should be installed
404
# as one of the Pod::Simple's prereqs, which is a prereq
405
# of Pod::Text 3.x (see also below).
406
$author =~ s{ E<( (\d+) | ([A-Za-z]+) )> }
410
: defined $Pod::Escapes::Name2character_number{$1}
411
? chr($Pod::Escapes::Name2character_number{$1})
413
warn "Unknown escape: E<$1>";
418
elsif (eval "require Pod::Text; 1" && $Pod::Text::VERSION < 3) {
419
# Pod::Text < 3.0 has yet another mapping table,
420
# though the table name of 2.x and 1.x are different.
421
# (1.x is in core of Perl < 5.6, 2.x is in core of
423
my $mapping = ($Pod::Text::VERSION < 2)
424
? \%Pod::Text::HTML_Escapes
425
: \%Pod::Text::ESCAPES;
426
$author =~ s{ E<( (\d+) | ([A-Za-z]+) )> }
430
: defined $mapping->{$1}
433
warn "Unknown escape: E<$1>";
439
$author =~ s{E<lt>}{<}g;
440
$author =~ s{E<gt>}{>}g;
433
442
$self->author($author);
435
444
warn "Cannot determine author info from $_[0]\n";
450
perl => 'http://dev.perl.org/licenses/',
451
apache => 'http://apache.org/licenses/LICENSE-2.0',
452
apache_1_1 => 'http://apache.org/licenses/LICENSE-1.1',
453
artistic => 'http://opensource.org/licenses/artistic-license.php',
454
artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php',
455
lgpl => 'http://opensource.org/licenses/lgpl-license.php',
456
lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php',
457
lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html',
458
bsd => 'http://opensource.org/licenses/bsd-license.php',
459
gpl => 'http://opensource.org/licenses/gpl-license.php',
460
gpl2 => 'http://opensource.org/licenses/gpl-2.0.php',
461
gpl3 => 'http://opensource.org/licenses/gpl-3.0.html',
462
mit => 'http://opensource.org/licenses/mit-license.php',
463
mozilla => 'http://opensource.org/licenses/mozilla1.1.php',
464
open_source => undef,
465
unrestricted => undef,
466
restrictive => undef,
472
return $self->{values}->{license} unless @_;
473
my $license = shift or die(
474
'Did not provide a value to license()'
476
$license = __extract_license($license) || lc $license;
477
$self->{values}->{license} = $license;
479
# Automatically fill in license URLs
480
if ( $license_urls{$license} ) {
481
$self->resources( license => $license_urls{$license} );
439
487
sub _extract_license {
444
(?:licen[cs]e|licensing|copyrights?|legal)\b
450
my $license_text = $1;
452
'under the same (?:terms|license) as (?:perl|the perl programming language)' => 'perl', 1,
453
'under the terms of (?:perl|the perl programming language) itself' => 'perl', 1,
454
'Artistic and GPL' => 'perl', 1,
455
'GNU general public license' => 'gpl', 1,
456
'GNU public license' => 'gpl', 1,
457
'GNU lesser general public license' => 'lgpl', 1,
458
'GNU lesser public license' => 'lgpl', 1,
459
'GNU library general public license' => 'lgpl', 1,
460
'GNU library public license' => 'lgpl', 1,
461
'BSD license' => 'bsd', 1,
462
'Artistic license' => 'artistic', 1,
466
'Artistic' => 'artistic', 1,
468
'proprietary' => 'proprietary', 0,
470
while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) {
471
$pattern =~ s#\s+#\\s+#gs;
472
if ( $license_text =~ /\b$pattern\b/i ) {
490
return __extract_license(
491
($matched) = $pod =~ m/
492
(=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?)
493
(=head \d.*|=cut.*|)\z
495
) || __extract_license(
496
($matched) = $pod =~ m/
497
(=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?)
498
(=head \d.*|=cut.*|)\z
503
sub __extract_license {
504
my $license_text = shift or return;
506
'(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1,
507
'(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1,
508
'Artistic and GPL' => 'perl', 1,
509
'GNU general public license' => 'gpl', 1,
510
'GNU public license' => 'gpl', 1,
511
'GNU lesser general public license' => 'lgpl', 1,
512
'GNU lesser public license' => 'lgpl', 1,
513
'GNU library general public license' => 'lgpl', 1,
514
'GNU library public license' => 'lgpl', 1,
515
'GNU Free Documentation license' => 'unrestricted', 1,
516
'GNU Affero General Public License' => 'open_source', 1,
517
'(?:Free)?BSD license' => 'bsd', 1,
518
'Artistic license' => 'artistic', 1,
519
'Apache (?:Software )?license' => 'apache', 1,
523
'Artistic' => 'artistic', 1,
525
'Mozilla Public License' => 'mozilla', 1,
526
'Q Public License' => 'open_source', 1,
527
'OpenSSL License' => 'unrestricted', 1,
528
'SSLeay License' => 'unrestricted', 1,
529
'zlib License' => 'open_source', 1,
530
'proprietary' => 'proprietary', 0,
532
while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) {
533
$pattern =~ s#\s+#\\s+#gs;
534
if ( $license_text =~ /\b$pattern\b/i ) {
481
541
sub license_from {