1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
|
use strict;
use warnings;
use Test::More tests => 7;
use Software::LicenseUtils;
{
my $fake_pm = <<'END_PM';
"magic true value";
__END__
=head1 LICENSE
This is released under the same terms as perl itself.
=cut
END_PM
my @guesses = Software::LicenseUtils->guess_license_from_pod($fake_pm);
is_deeply(
\@guesses,
[ 'Software::License::Perl_5' ],
"guessed okay"
);
}
{
my $fake_pm = <<'END_PM';
"magic true value";
__END__
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2013 by David Golden.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
=cut
END_PM
my @guesses = Software::LicenseUtils->guess_license_from_pod($fake_pm);
is_deeply(
\@guesses,
[ 'Software::License::Apache_2_0' ],
"guessed okay"
);
}
{
my $fake_pm = <<'END_PM';
"magic true value";
__END__
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2015.
This program is released under the following license: GPL v3
=cut
END_PM
my @guesses = Software::LicenseUtils->guess_license_from_pod($fake_pm);
is_deeply(
\@guesses,
[ 'Software::License::GPL_3' ],
"guessed okay"
);
}
{
my $fake_yaml = <<'END_YAML';
---
abstract: 'packages that provide templated software licenses'
author:
- 'Ricardo Signes <rjbs@cpan.org>'
distribution_type: module
generated_by: 'Module::Install version 0.71'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.3.html
version: 1.3
name: Software-License
no_index:
directory:
- inc
- t
requires:
Class::ISA: 0.000
Sub::Install: 0.000
Text::Template: 0.000
perl: 5.6.0
tests: 't/*.t xt/*.t'
version: 0.002
END_YAML
my @guesses = Software::LicenseUtils->guess_license_from_meta_yml(
$fake_yaml
);
is_deeply(
\@guesses,
[ 'Software::License::Perl_5' ],
"guessed okay"
);
}
{
my $fake_yaml = <<'END_YAML';
---
abstract: 'packages that provide templated software licenses'
author:
- 'Ricardo Signes <rjbs@cpan.org>'
distribution_type: module
generated_by: 'Module::Install version 0.71'
license: gpl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.3.html
version: 1.3
name: Software-License
no_index:
directory:
- inc
- t
requires:
Class::ISA: 0.000
Sub::Install: 0.000
Text::Template: 0.000
perl: 5.6.0
tests: 't/*.t xt/*.t'
version: 0.002
END_YAML
my @guesses = Software::LicenseUtils->guess_license_from_meta(
$fake_yaml
);
is_deeply(
\@guesses,
[ qw(
Software::License::GPL_1
Software::License::GPL_2
Software::License::GPL_3
) ],
"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::Formatter" : "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"
);
}
{
my $fake_pm = <<'END_PM';
"magic true value";
__END__
=head1 COPYRIGHT AND LICENSE
唐鳳 has dedicated the work to the Commons by waiving all of his or her rights to the work worldwide under copyright law and all related or neighboring legal rights he or she had in the work, to the extent allowable by law.
Works under CC0 do not require attribution. When citing the work, you should not imply endorsement by the author.
This work is published from Taiwan.
L<http://creativecommons.org/publicdomain/zero/1.0>
=cut
END_PM
my @guesses = Software::LicenseUtils->guess_license_from_pod($fake_pm);
is_deeply(
\@guesses,
[ 'Software::License::CC0_1_0' ],
"guessed okay"
);
}
|