Debian Codegraph @

upstream/mageia-cauldron/man3pm/CPAN::Meta::Merge.3pm

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (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 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "CPAN::Meta::Merge 3pm"
61 .TH CPAN::Meta::Merge 3pm 2023-12-22 "perl v5.42.0" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 CPAN::Meta::Merge \- Merging CPAN Meta fragments
68 .SH VERSION
69 .IX Header "VERSION"
70 version 2.150010
71 .SH SYNOPSIS
72 .IX Header "SYNOPSIS"
73 .Vb 2
74 \& my $merger = CPAN::Meta::Merge\->new(default_version => "2");
75 \& my $meta = $merger\->merge($base, @additional);
76 .Ve
77 .SH DESCRIPTION
78 .IX Header "DESCRIPTION"
79 .SH METHODS
80 .IX Header "METHODS"
81 .SS new
82 .IX Subsection "new"
83 This creates a CPAN::Meta::Merge object. It takes one mandatory named
84 argument, \f(CW\*(C`version\*(C'\fR, declaring the version of the meta\-spec that must be
85 used for the merge. It can optionally take an \f(CW\*(C`extra_mappings\*(C'\fR argument
86 that allows one to add additional merging functions for specific elements.
87 .PP
88 The \f(CW\*(C`extra_mappings\*(C'\fR arguments takes a hash ref with the same type of
89 structure as described in CPAN::Meta::Spec, except with its values as
90 one of the defined merge strategies or a code ref
91 to a merging function.
92 .PP
93 .Vb 11
94 \& my $merger = CPAN::Meta::Merge\->new(
95 \& default_version => \*(Aq2\*(Aq,
96 \& extra_mappings => {
97 \& \*(Aqoptional_features\*(Aq => \e&custom_merge_function,
98 \& \*(Aqx_custom\*(Aq => \*(Aqset_addition\*(Aq,
99 \& \*(Aqx_meta_meta\*(Aq => {
100 \& name => \*(Aqidentical\*(Aq,
101 \& tags => \*(Aqset_addition\*(Aq,
102 \& }
103 \& }
104 \& );
105 .Ve
106 .SS merge(@fragments)
107 .IX Subsection "merge(@fragments)"
108 Merge all \f(CW@fragments\fR together. It will accept both CPAN::Meta objects and
109 (possibly incomplete) hashrefs of metadata.
110 .SH "MERGE STRATEGIES"
111 .IX Header "MERGE STRATEGIES"
112 \&\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:
113 .IP identical 4
114 .IX Item "identical"
115 The elements must be identical
116 .IP set_addition 4
117 .IX Item "set_addition"
118 The union of two array refs
119 .Sp
120 .Vb 1
121 \& [ a, b ] U [ a, c] = [ a, b, c ]
122 .Ve
123 .IP uniq_map 4
124 .IX Item "uniq_map"
125 Key value pairs from the right hash are merged to the left hash. Key
126 collisions are only allowed if their values are the same. This merge
127 function will recurse into nested hash refs following the same merge
128 rules.
129 .IP improvise 4
130 .IX Item "improvise"
131 This merge strategy will try to pick the appropriate predefined strategy
132 based on what element type. Array refs will try to use the
133 \&\f(CW\*(C`set_addition\*(C'\fR strategy, Hash refs will try to use the \f(CW\*(C`uniq_map\*(C'\fR
134 strategy, and everything else will try the \f(CW\*(C`identical\*(C'\fR strategy.
135 .SH AUTHORS
136 .IX Header "AUTHORS"
137 .IP \(bu 4
138 David Golden <[email protected]>
139 .IP \(bu 4
140 Ricardo Signes <[email protected]>
141 .IP \(bu 4
142 Adam Kennedy <[email protected]>
143 .SH "COPYRIGHT AND LICENSE"
144 .IX Header "COPYRIGHT AND LICENSE"
145 This software is copyright (c) 2010 by David Golden, Ricardo Signes, Adam Kennedy and Contributors.
146 .PP
147 This is free software; you can redistribute it and/or modify it under
148 the same terms as the Perl 5 programming language system itself.