diff options
author | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2015-06-11 16:28:11 +0100 |
---|---|---|
committer | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2015-06-11 16:28:11 +0100 |
commit | 2b771c51706b5815f1928ec88c49b535095adea6 (patch) | |
tree | 575c0e4775e4b2a3a493cc5ce1cba3abe6b7a0ff /cpan/CPAN-Meta/lib/CPAN/Meta/Merge.pm | |
parent | 89d84ff965b644c21c4c0633253e4cb21f72b62c (diff) | |
download | perl-2b771c51706b5815f1928ec88c49b535095adea6.tar.gz |
Update CPAN-Meta to CPAN release 2.150005
[DELTA]
2.150005 2015-06-09 19:08:44-06:00 America/Denver
[TESTING]
- Changed some test data from UTF-8 to ASCII
2.150004 2015-05-19 11:25:53-04:00 America/New_York (TRIAL RELEASE)
[DOCUMENTED]
- Noted explicitly that historical META spec files are licensed under
the same terms as Perl
[TESTING]
- Added test for 'x_deprecated' field in "provides"
[META]
- declared extra developer prereq
2.150003 2015-04-21 19:41:15-04:00 America/New_York (TRIAL RELEASE)
[CHANGED]
- Serialized CPAN::Meta objects now include a x_serialization_backend
entry
2.150002 2015-04-19 01:00:10+02:00 Europe/Berlin (TRIAL RELEASE)
[CHANGED]
- Metadata merging now does deep hash merging as long as keys
don't conflict
Diffstat (limited to 'cpan/CPAN-Meta/lib/CPAN/Meta/Merge.pm')
-rw-r--r-- | cpan/CPAN-Meta/lib/CPAN/Meta/Merge.pm | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/cpan/CPAN-Meta/lib/CPAN/Meta/Merge.pm b/cpan/CPAN-Meta/lib/CPAN/Meta/Merge.pm index f4c12869c4..05a18ea973 100644 --- a/cpan/CPAN-Meta/lib/CPAN/Meta/Merge.pm +++ b/cpan/CPAN-Meta/lib/CPAN/Meta/Merge.pm @@ -3,15 +3,24 @@ use warnings; package CPAN::Meta::Merge; -our $VERSION = '2.150001'; +our $VERSION = '2.150005'; use Carp qw/croak/; use Scalar::Util qw/blessed/; use CPAN::Meta::Converter 2.141170; +sub _is_identical { + my ($left, $right) = @_; + return + (not defined $left and not defined $right) + # if either of these are references, we compare the serialized value + || (defined $left and defined $right and $left eq $right); +} + sub _identical { my ($left, $right, $path) = @_; - croak sprintf "Can't merge attribute %s: '%s' does not equal '%s'", join('.', @{$path}), $left, $right unless $left eq $right; + croak sprintf "Can't merge attribute %s: '%s' does not equal '%s'", join('.', @{$path}), $left, $right + unless _is_identical($left, $right); return $left; } @@ -50,6 +59,13 @@ sub _uniq_map { if (not exists $left->{$key}) { $left->{$key} = $right->{$key}; } + # identical strings or references are merged identically + elsif (_is_identical($left->{$key}, $right->{$key})) { + 1; # do nothing - keep left + } + elsif (ref $left->{$key} eq 'HASH' and ref $right->{$key} eq 'HASH') { + $left->{$key} = _uniq_map($left->{$key}, $right->{$key}, [ @{$path}, $key ]); + } else { croak 'Duplication of element ' . join '.', @{$path}, $key; } @@ -219,6 +235,9 @@ sub merge { # ABSTRACT: Merging CPAN Meta fragments + +# vim: ts=2 sts=2 sw=2 et : + __END__ =pod @@ -231,7 +250,7 @@ CPAN::Meta::Merge - Merging CPAN Meta fragments =head1 VERSION -version 2.150001 +version 2.150005 =head1 SYNOPSIS |