Skip to content

Commit

Permalink
fix conversion of restricted/restrictive license
Browse files Browse the repository at this point in the history
Version 1.4 had 'restrictive', but version 2 has 'restricted'.
This commit fixes the conversion between them.
  • Loading branch information
xdg committed Jun 9, 2010
1 parent d229f43 commit db7a635
Show file tree
Hide file tree
Showing 5 changed files with 318 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -2,6 +2,9 @@ Revision history for CPAN-Meta

{{$NEXT}}

- improve conversion of restricted/restrictive license keys between
spec versions 1.4 and 2 [reported by Alexander Hartmaier]

2.101591 2010-06-08 09:56:17 EST5EDT

- added 'as_struct' method to CPAN::Meta to get a deep copy of
Expand Down
14 changes: 5 additions & 9 deletions lib/CPAN/Meta/Converter.pm
Expand Up @@ -155,6 +155,7 @@ my %license_map_2 = (
lgpl => 'lgpl_2_1',
mozilla => 'mozilla_1_0',
perl => 'perl_5',
restrictive => 'restricted',
);

sub _license_2 {
Expand Down Expand Up @@ -196,7 +197,7 @@ my %license_downgrade_map = qw(
sun open_source
zlib open_source
open_source open_source
restricted restricted
restricted restrictive
unrestricted unrestricted
unknown unknown
);
Expand All @@ -208,18 +209,13 @@ sub _downgrade_license {
}
elsif( ref $element eq 'ARRAY' ) {
if ( @$element == 1 ) {
return $license_downgrade_map{$element->[0]};
}
else {
return 'unknown';
return $license_downgrade_map{$element->[0]} || "unknown";
}
}
elsif ( ! ref $element ) {
return $license_downgrade_map{$element};
}
else {
return "unknown";
return $license_downgrade_map{$element} || "unknown";
}
return "unknown";
}

my $no_index_spec_1_2 = {
Expand Down
89 changes: 89 additions & 0 deletions t/data-bad/restrictive-2.json
@@ -0,0 +1,89 @@
{
"resources" : {
"license" : [
"http://dev.perl.org/licenses/"
],
"repository" : {
"url" : "svn://repo.example.com/foo-bar#fakeanchor",
"web" : "http://www.example.com"
}
},
"generated_by" : "Module::Build version 0.36",
"meta-spec" : {
"version" : "2",
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec"
},
"version" : "0.36",
"name" : "Module-Build",
"dynamic_config" : 1,
"author" : [
"Ken Williams <kwilliams@cpan.org>",
"Module-Build List <module-build@perl.org>"
],
"release_status" : "stable",
"license" : [
"restrictive"
],
"description" : "Module::Build is a system for building, testing, and installing Perl modules. It is meant to be an alternative to ExtUtils::MakeMaker... blah blah blah",
"keywords" : [
"toolchain",
"cpan",
"dual-life"
],
"prereqs" : {
"runtime" : {
"requires" : {
"File::Copy" : "0",
"IO::File" : "0",
"Data::Dumper" : "0",
"File::Spec" : "0",
"Config" : "0",
"ExtUtils::Install" : "0",
"perl" : "5.006",
"File::Compare" : "0",
"File::Find" : "0",
"File::Path" : "0",
"File::Basename" : "0",
"Cwd" : "0"
},
"recommends" : {
"YAML" : "0.35",
"ExtUtils::ParseXS" : "2.02",
"Pod::Text" : "0",
"ExtUtils::Install" : "0.3",
"Archive::Tar" : "1.00"
}
},
"build" : {
"requires" : {
"Build::Requires": "1.1",
"Test::More" : "0"
}
},
"test" : {
"requires" : {
"Test::More" : "0.88",
"Test::Requires" : "1.2"
}
}
},
"optional_features" : {
"domination" : {
"prereqs" : {
"develop" : {
"requires" : {
"Genius::Evil" : "1.234"
}
},
"runtime" : {
"requires" : {
"Machine::Weather" : "2.0"
}
}
},
"description" : "Take over the world"
}
},
"abstract" : "Build and install Perl modules",
"x_whatever" : "Custom key"
}
89 changes: 89 additions & 0 deletions t/data/restricted-2.json
@@ -0,0 +1,89 @@
{
"resources" : {
"license" : [
"http://dev.perl.org/licenses/"
],
"repository" : {
"url" : "svn://repo.example.com/foo-bar#fakeanchor",
"web" : "http://www.example.com"
}
},
"generated_by" : "Module::Build version 0.36",
"meta-spec" : {
"version" : "2",
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec"
},
"version" : "0.36",
"name" : "Module-Build",
"dynamic_config" : 1,
"author" : [
"Ken Williams <kwilliams@cpan.org>",
"Module-Build List <module-build@perl.org>"
],
"release_status" : "stable",
"license" : [
"restricted"
],
"description" : "Module::Build is a system for building, testing, and installing Perl modules. It is meant to be an alternative to ExtUtils::MakeMaker... blah blah blah",
"keywords" : [
"toolchain",
"cpan",
"dual-life"
],
"prereqs" : {
"runtime" : {
"requires" : {
"File::Copy" : "0",
"IO::File" : "0",
"Data::Dumper" : "0",
"File::Spec" : "0",
"Config" : "0",
"ExtUtils::Install" : "0",
"perl" : "5.006",
"File::Compare" : "0",
"File::Find" : "0",
"File::Path" : "0",
"File::Basename" : "0",
"Cwd" : "0"
},
"recommends" : {
"YAML" : "0.35",
"ExtUtils::ParseXS" : "2.02",
"Pod::Text" : "0",
"ExtUtils::Install" : "0.3",
"Archive::Tar" : "1.00"
}
},
"build" : {
"requires" : {
"Build::Requires": "1.1",
"Test::More" : "0"
}
},
"test" : {
"requires" : {
"Test::More" : "0.88",
"Test::Requires" : "1.2"
}
}
},
"optional_features" : {
"domination" : {
"prereqs" : {
"develop" : {
"requires" : {
"Genius::Evil" : "1.234"
}
},
"runtime" : {
"requires" : {
"Machine::Weather" : "2.0"
}
}
},
"description" : "Take over the world"
}
},
"abstract" : "Build and install Perl modules",
"x_whatever" : "Custom key"
}
132 changes: 132 additions & 0 deletions t/data/restrictive-1_4.yml
@@ -0,0 +1,132 @@
---
abstract: 'Build and install Perl modules'
author:
- 'Ken Williams <kwilliams@cpan.org>'
- "Development questions, bug reports, and patches should be sent to the\nModule-Build mailing list at <module-build@perl.org>."
build_requires:
File::Temp: 0.15
Test::Harness: 3.16
Test::More: 0.49
generated_by: 'Module::Build version 0.3608'
license: restrictive
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: Module-Build
provides:
Module::Build:
file: lib/Module/Build.pm
version: 0.36_08
Module::Build::Base:
file: lib/Module/Build/Base.pm
version: 0.36_08
Module::Build::Compat:
file: lib/Module/Build/Compat.pm
version: 0.36_08
Module::Build::Config:
file: lib/Module/Build/Config.pm
version: 0.36_08
Module::Build::Cookbook:
file: lib/Module/Build/Cookbook.pm
version: 0.36_08
Module::Build::Dumper:
file: lib/Module/Build/Dumper.pm
version: 0.36_08
Module::Build::ModuleInfo:
file: lib/Module/Build/ModuleInfo.pm
version: 0.36_08
Module::Build::Notes:
file: lib/Module/Build/Notes.pm
version: 0.36_08
Module::Build::PPMMaker:
file: lib/Module/Build/PPMMaker.pm
version: 0.36_08
Module::Build::Platform::Amiga:
file: lib/Module/Build/Platform/Amiga.pm
version: 0.36_08
Module::Build::Platform::Default:
file: lib/Module/Build/Platform/Default.pm
version: 0.36_08
Module::Build::Platform::EBCDIC:
file: lib/Module/Build/Platform/EBCDIC.pm
version: 0.36_08
Module::Build::Platform::MPEiX:
file: lib/Module/Build/Platform/MPEiX.pm
version: 0.36_08
Module::Build::Platform::MacOS:
file: lib/Module/Build/Platform/MacOS.pm
version: 0.36_08
Module::Build::Platform::RiscOS:
file: lib/Module/Build/Platform/RiscOS.pm
version: 0.36_08
Module::Build::Platform::Unix:
file: lib/Module/Build/Platform/Unix.pm
version: 0.36_08
Module::Build::Platform::VMS:
file: lib/Module/Build/Platform/VMS.pm
version: 0.36_08
Module::Build::Platform::VOS:
file: lib/Module/Build/Platform/VOS.pm
version: 0.36_08
Module::Build::Platform::Windows:
file: lib/Module/Build/Platform/Windows.pm
version: 0.36_08
Module::Build::Platform::aix:
file: lib/Module/Build/Platform/aix.pm
version: 0.36_08
Module::Build::Platform::cygwin:
file: lib/Module/Build/Platform/cygwin.pm
version: 0.36_08
Module::Build::Platform::darwin:
file: lib/Module/Build/Platform/darwin.pm
version: 0.36_08
Module::Build::Platform::os2:
file: lib/Module/Build/Platform/os2.pm
version: 0.36_08
Module::Build::PodParser:
file: lib/Module/Build/PodParser.pm
version: 0.36_08
Module::Build::Version:
file: lib/Module/Build/Version.pm
version: 0.77
Module::Build::YAML:
file: lib/Module/Build/YAML.pm
version: 1.40
inc::latest:
file: lib/inc/latest.pm
version: 0.36_08
inc::latest::private:
file: lib/inc/latest/private.pm
version: 0.36_08
recommends:
ExtUtils::Install: 0.3
ExtUtils::Manifest: 1.54
version: 0.74
requires:
Cwd: 0
Data::Dumper: 0
ExtUtils::CBuilder: 0.27
ExtUtils::Install: 0
ExtUtils::Manifest: 0
ExtUtils::Mkbootstrap: 0
ExtUtils::ParseXS: 2.21
File::Basename: 0
File::Compare: 0
File::Copy: 0
File::Find: 0
File::Path: 0
File::Spec: 0.82
Getopt::Long: 0
IO::File: 0
Test::Harness: 0
Text::Abbrev: 0
Text::ParseWords: 0
perl: 5.006001
resources:
MailingList: mailto:module-build@perl.org
license: http://dev.perl.org/licenses/
repository: http://github.com/dagolden/module-build/
version: 0.36_08
x-whatever: this is a custom field
x_whatelse: so is this
XWhatNow: and this

0 comments on commit db7a635

Please sign in to comment.