1CPAN::Meta::Merge(3)  User Contributed Perl Documentation CPAN::Meta::Merge(3)
2
3
4

NAME

6       CPAN::Meta::Merge - Merging CPAN Meta fragments
7

VERSION

9       version 2.150010
10

SYNOPSIS

12        my $merger = CPAN::Meta::Merge->new(default_version => "2");
13        my $meta = $merger->merge($base, @additional);
14

DESCRIPTION

METHODS

17   new
18       This creates a CPAN::Meta::Merge object. It takes one mandatory named
19       argument, "version", declaring the version of the meta-spec that must
20       be used for the merge. It can optionally take an "extra_mappings"
21       argument that allows one to add additional merging functions for
22       specific elements.
23
24       The "extra_mappings" arguments takes a hash ref with the same type of
25       structure as described in CPAN::Meta::Spec, except with its values as
26       one of the defined merge strategies or a code ref to a merging
27       function.
28
29         my $merger = CPAN::Meta::Merge->new(
30             default_version => '2',
31             extra_mappings => {
32                 'optional_features' => \&custom_merge_function,
33                 'x_custom' => 'set_addition',
34                 'x_meta_meta' => {
35                     name => 'identical',
36                     tags => 'set_addition',
37                 }
38             }
39         );
40
41   merge(@fragments)
42       Merge all @fragments together. It will accept both CPAN::Meta objects
43       and (possibly incomplete) hashrefs of metadata.
44

MERGE STRATEGIES

46       "merge" uses various strategies to combine different elements of the
47       CPAN::Meta objects.  The following strategies can be used with the
48       extra_mappings argument of "new":
49
50       identical
51           The elements must be identical
52
53       set_addition
54           The union of two array refs
55
56             [ a, b ] U [ a, c]  = [ a, b, c ]
57
58       uniq_map
59           Key value pairs from the right hash are merged to the left hash.
60           Key collisions are only allowed if their values are the same.  This
61           merge function will recurse into nested hash refs following the
62           same merge rules.
63
64       improvise
65           This merge strategy will try to pick the appropriate predefined
66           strategy based on what element type.  Array refs will try to use
67           the "set_addition" strategy,  Hash refs will try to use the
68           "uniq_map" strategy, and everything else will try the "identical"
69           strategy.
70

AUTHORS

72       •   David Golden <dagolden@cpan.org>
73
74       •   Ricardo Signes <rjbs@cpan.org>
75
76       •   Adam Kennedy <adamk@cpan.org>
77
79       This software is copyright (c) 2010 by David Golden, Ricardo Signes,
80       Adam Kennedy and Contributors.
81
82       This is free software; you can redistribute it and/or modify it under
83       the same terms as the Perl 5 programming language system itself.
84
85
86
87perl v5.36.0                      2022-07-22              CPAN::Meta::Merge(3)
Impressum