Commit fe9f3fc1 authored by Dominique Dumont's avatar Dominique Dumont

short_name patch: also find license for short names with version, e.g. Apache-2.0

parent 59eacf73
......@@ -4,15 +4,18 @@ Forwarded: https://github.com/rjbs/Software-License/pull/31
Author: dod
--- a/lib/Software/LicenseUtils.pm
+++ b/lib/Software/LicenseUtils.pm
@@ -212,14 +212,13 @@
@@ -211,15 +211,15 @@
Carp::croak "no license short name specified"
unless defined $arg->{short_name};
my $short = delete $arg->{short_name};
- my $short = delete $arg->{short_name};
- Carp::croak "Unknow license with short name $short"
- unless $short_name{$short};
+ my $subclass = my $short = delete $arg->{short_name};
+ $subclass =~ s/[\-.]/_/g;
- my $info = $short_name{$short} ;
+ my $info = $short_name{$short} || "Software::License::$short";
+ my $info = $short_name{$short} || "Software::License::$subclass";
my @infos = ref $info ? @$info : ($info);
my $lic_file = my $lic_class = shift @infos;
$lic_file =~ s!::!/!g;
......@@ -22,7 +25,7 @@ Author: dod
return $lic_class->new( { %$arg, @infos } );
}
@@ -276,7 +275,10 @@
@@ -276,7 +276,10 @@
Create a new L<Software::License> object from the license specified
with C<short_name>. Known short license names are C<GPL-*>, C<LGPL-*> ,
......@@ -41,11 +44,11 @@ Author: dod
use warnings;
-use Test::More tests => 6;
+use Test::More tests => 7;
+use Test::More tests => 8;
my $class = 'Software::LicenseUtils';
require_ok($class);
@@ -17,3 +17,10 @@
@@ -17,3 +17,16 @@
isa_ok($license,'Software::License::GPL_1',"license class");
like($license->name, qr/version 1/i, "license name");
like($license->fulltext, qr/general public/i, 'license text');
......@@ -56,3 +59,9 @@ Author: dod
+ holder => 'X. Ample'
+});
+isa_ok($mit_lic,'Software::License::MIT',"license class");
+
+my $apache_lic = $class->new_from_short_name({
+ short_name => 'Apache-2.0',
+ holder => 'X. Ample'
+});
+isa_ok($apache_lic,'Software::License::Apache_2_0',"license class");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment