Debian Codegraph @

upstream/debian-unstable/man3/CPAN::Meta::Merge.3perl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "CPAN::Meta::Merge 3perl"
58 .TH CPAN::Meta::Merge 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide"
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 CPAN::Meta::Merge \- Merging CPAN Meta fragments
65 .SH VERSION
66 .IX Header "VERSION"
67 version 2.150010
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 .Vb 2
71 \& my $merger = CPAN::Meta::Merge\->new(default_version => "2");
72 \& my $meta = $merger\->merge($base, @additional);
73 .Ve
74 .SH DESCRIPTION
75 .IX Header "DESCRIPTION"
76 .SH METHODS
77 .IX Header "METHODS"
78 .SS new
79 .IX Subsection "new"
80 This creates a CPAN::Meta::Merge object. It takes one mandatory named
81 argument, \f(CW\*(C`version\*(C'\fR, declaring the version of the meta-spec that must be
82 used for the merge. It can optionally take an \f(CW\*(C`extra_mappings\*(C'\fR argument
83 that allows one to add additional merging functions for specific elements.
84 .PP
85 The \f(CW\*(C`extra_mappings\*(C'\fR arguments takes a hash ref with the same type of
86 structure as described in CPAN::Meta::Spec, except with its values as
87 one of the defined merge strategies or a code ref
88 to a merging function.
89 .PP
90 .Vb 11
91 \& my $merger = CPAN::Meta::Merge\->new(
92 \& default_version => \*(Aq2\*(Aq,
93 \& extra_mappings => {
94 \& \*(Aqoptional_features\*(Aq => \e&custom_merge_function,
95 \& \*(Aqx_custom\*(Aq => \*(Aqset_addition\*(Aq,
96 \& \*(Aqx_meta_meta\*(Aq => {
97 \& name => \*(Aqidentical\*(Aq,
98 \& tags => \*(Aqset_addition\*(Aq,
99 \& }
100 \& }
101 \& );
102 .Ve
103 .SS merge(@fragments)
104 .IX Subsection "merge(@fragments)"
105 Merge all \f(CW@fragments\fR together. It will accept both CPAN::Meta objects and
106 (possibly incomplete) hashrefs of metadata.
107 .SH "MERGE STRATEGIES"
108 .IX Header "MERGE STRATEGIES"
109 \&\f(CW\*(C`merge\*(C'\fR uses various strategies to combine different elements of the CPAN::Meta objects. The following strategies can be used with the extra_mappings argument of \f(CW\*(C`new\*(C'\fR:
110 .IP identical 4
111 .IX Item "identical"
112 The elements must be identical
113 .IP set_addition 4
114 .IX Item "set_addition"
115 The union of two array refs
116 .Sp
117 .Vb 1
118 \& [ a, b ] U [ a, c] = [ a, b, c ]
119 .Ve
120 .IP uniq_map 4
121 .IX Item "uniq_map"
122 Key value pairs from the right hash are merged to the left hash. Key
123 collisions are only allowed if their values are the same. This merge
124 function will recurse into nested hash refs following the same merge
125 rules.
126 .IP improvise 4
127 .IX Item "improvise"
128 This merge strategy will try to pick the appropriate predefined strategy
129 based on what element type. Array refs will try to use the
130 \&\f(CW\*(C`set_addition\*(C'\fR strategy, Hash refs will try to use the \f(CW\*(C`uniq_map\*(C'\fR
131 strategy, and everything else will try the \f(CW\*(C`identical\*(C'\fR strategy.
132 .SH AUTHORS
133 .IX Header "AUTHORS"
134 .IP \(bu 4
135 David Golden <[email protected]>
136 .IP \(bu 4
137 Ricardo Signes <[email protected]>
138 .IP \(bu 4
139 Adam Kennedy <[email protected]>
140 .SH "COPYRIGHT AND LICENSE"
141 .IX Header "COPYRIGHT AND LICENSE"
142 This software is copyright (c) 2010 by David Golden, Ricardo Signes, Adam Kennedy and Contributors.
143 .PP
144 This is free software; you can redistribute it and/or modify it under
145 the same terms as the Perl 5 programming language system itself.