Commit d5e972eb authored by Ryan Niebur's avatar Ryan Niebur

[svn-upgrade] Integrating new upstream version, libsoftware-license-perl (0.012)

parent 34af4c85
Revision history for Software-License
0.012 2009-05-22
added guess_license_from_meta which is both JSON and YAML compatible
(BRICAS)
0.011 2009-05-19
clarify references to Perl in Perl_5 license
rename things that were YAML-specific to just be "meta"
......
......@@ -26,4 +26,4 @@ requires:
resources:
license: http://dev.perl.org/licenses/
repository: http://github.com/rjbs/software-license
version: 0.011
version: 0.012
......@@ -9,11 +9,11 @@ Software::License - packages that provide templated software licenses
=head1 VERSION
version 0.011
version 0.012
=cut
our $VERSION = '0.011';
our $VERSION = '0.012';
use Data::Section -setup => { header_re => qr/\A__([^_]+)__\Z/ };
use Sub::Install ();
......
......@@ -95,25 +95,27 @@ my %meta_keys = (
mozilla => [ map { "Mozilla_$_" } qw(1_0 1_1) ],
);
=head2 guess_license_from_meta_yml
=head2 guess_license_from_meta
my @guesses = Software::LicenseUtils->guess_license_from_meta_yml($yaml_str);
my @guesses = Software::LicenseUtils->guess_license_from_meta($meta_str);
Given the content of the META.yml file found in a CPAN distribution, this
Given the content of the META.(yml|json) file found in a CPAN distribution, this
method makes a guess as to which licenses may apply to the distribution. It
will return a list of zero or more Software::License instances or classes.
=cut
sub guess_license_from_meta_yml {
my ($class, $yaml_text) = @_;
sub guess_license_from_meta {
my ($class, $meta_text) = @_;
die "can't call guess_license_* in scalar context" unless wantarray;
my ($license_text) = $yaml_text =~ m{^license: (.+)}gm;
my ($license_text) = $meta_text =~ m{\b["']?license["']?\s*:\s*["']?([a-z_]+)["']?}gm;
return unless $license_text and my $license = $meta_keys{ $license_text };
return map { "Software::License::$_" } ref $license ? @$license : $license;
}
*guess_license_from_meta_yml = \&guess_license_from_meta;
1;
use strict;
use warnings;
use Test::More tests => 3;
use Test::More tests => 4;
use Software::LicenseUtils;
{
......@@ -89,7 +89,7 @@ tests: 't/*.t xt/*.t'
version: 0.002
END_YAML
my @guesses = Software::LicenseUtils->guess_license_from_meta_yml(
my @guesses = Software::LicenseUtils->guess_license_from_meta(
$fake_yaml
);
......@@ -103,3 +103,64 @@ END_YAML
"guessed okay"
);
}
{
my $fake_json = <<'END_JSON';
{
"resources" : {
"repository" : "http://github.com/rjbs/dist-zilla"
},
"generated_by" : "Dist::Zilla::Plugin::MetaJSON version 1.091370",
"version" : "1.091370",
"name" : "Dist-Zilla",
"requires" : {
"DateTime" : "0.44",
"Config::INI::MVP::Reader" : "0.018",
"Pod::Eventual" : "0",
"App::Cmd" : "0.200",
"String::RewritePrefix" : "0.002",
"Data::Section" : "0.004",
"File::chdir" : "0",
"YAML::XS" : "0",
"String::Format" : "0",
"Perl::Version" : "0",
"autobox" : "2.53",
"Software::License" : "0",
"Archive::Tar" : "0",
"MooseX::ClassAttribute" : "0",
"List::MoreUtils" : "0",
"Moose" : "0.65",
"ExtUtils::Manifest" : "1.54",
"String::Flogger" : "1",
"File::Find::Rule" : "0",
"Mixin::ExtraFields::Param" : "0",
"File::HomeDir" : "0",
"ExtUtils::MakeMaker" : "0",
"CPAN::Uploader" : "0",
"Moose::Autobox" : "0.09",
"Test::More" : "0",
"MooseX::Types::Path::Class" : "0",
"Hash::Merge::Simple" : "0",
"File::Temp" : "0",
"Path::Class" : "0",
"Text::Template" : "0"
},
"abstract" : "distribution builder; installer not included!",
"author" : [
"Ricardo SIGNES <rjbs@cpan.org>"
],
"license" : "perl"
}
END_JSON
my @guesses = Software::LicenseUtils->guess_license_from_meta(
$fake_json
);
is_deeply(
\@guesses,
[ 'Software::License::Perl_5' ],
"guessed okay"
);
}
......@@ -5,5 +5,5 @@ eval "use Test::Pod::Coverage 1.04";
plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
all_pod_coverage_ok({
coverage_class => 'Pod::Coverage::CountParents',
trustme => [ qw(meta_yml_name) ],
trustme => [ qw(meta_yml_name guess_license_from_meta_yml) ],
});
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