Skip to content

Commit

Permalink
also tries short name using Apache_2_0 instead of Apache-2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dod38fr committed Sep 27, 2014
1 parent 870af56 commit 2bd30f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/Software/LicenseUtils.pm
Expand Up @@ -197,7 +197,8 @@ with C<short_name>. Known short license names are C<GPL-*>, C<LGPL-*> ,
C<Artistic> and C<Artistic-*>. If the short name is not know, this
method will try to create a license object with C<Software::License::> and
the specified short name (e.g. C<Software::License::MIT> with
C<< short_name => 'MIT' >>.
C<< short_name => 'MIT' >> or C<Software::License::Apache_2_0> with
C<< short_name => 'Apapche-2.0' >>).
=cut

Expand All @@ -206,10 +207,12 @@ sub new_from_short_name {

Carp::croak "no license short name specified"
unless defined $arg->{short_name};
my $short = delete $arg->{short_name};
my $subclass = my $short = delete $arg->{short_name};
$subclass =~ s/[\-.]/_/g;

my $lic_file = my $lic_class
= $short_name{$short} || "Software::License::$short";
= $short_name{$short} || "Software::License::$subclass";

$lic_file =~ s!::!/!g;
eval { require "$lic_file.pm"; } ;
Carp::croak "Unknow license with short name $short ($@)" if $@;
Expand Down
8 changes: 7 additions & 1 deletion t/short_name.t
Expand Up @@ -2,7 +2,7 @@
use strict;
use warnings;

use Test::More tests => 7;
use Test::More tests => 8;

my $class = 'Software::LicenseUtils';
require_ok($class);
Expand All @@ -24,3 +24,9 @@ my $mit_lic = $class->new_from_short_name({
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");

0 comments on commit 2bd30f4

Please sign in to comment.