Debian Codegraph @

upstream/mageia-cauldron/man3pm/CPAN::Distroprefs.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::Distroprefs 3pm"
61 .TH CPAN::Distroprefs 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::Distroprefs \-\- read and match distroprefs
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 .Vb 1
71 \& use CPAN::Distroprefs;
72 \&
73 \& my %info = (... distribution/environment info ...);
74 \&
75 \& my $finder = CPAN::Distroprefs\->find($prefs_dir, \e%ext_map);
76 \&
77 \& while (my $result = $finder\->next) {
78 \&
79 \& die $result\->as_string if $result\->is_fatal;
80 \&
81 \& warn($result\->as_string), next if $result\->is_warning;
82 \&
83 \& for my $pref (@{ $result\->prefs }) {
84 \& if ($pref\->matches(\e%info)) {
85 \& return $pref;
86 \& }
87 \& }
88 \& }
89 .Ve
90 .SH DESCRIPTION
91 .IX Header "DESCRIPTION"
92 This module encapsulates reading Distroprefs and matching them against CPAN distributions.
93 .SH INTERFACE
94 .IX Header "INTERFACE"
95 .Vb 1
96 \& my $finder = CPAN::Distroprefs\->find($dir, \e%ext_map);
97 \&
98 \& while (my $result = $finder\->next) { ... }
99 .Ve
100 .PP
101 Build an iterator which finds distroprefs files in the tree below the
102 given directory. Within the tree directories matching \f(CW\*(C`m/^[._]/\*(C'\fR are
103 pruned.
104 .PP
105 \&\f(CW%ext_map\fR is a hashref whose keys are file extensions and whose values are
106 modules used to load matching files:
107 .PP
108 .Vb 5
109 \& {
110 \& \*(Aqyml\*(Aq => \*(AqYAML::Syck\*(Aq,
111 \& \*(Aqdd\*(Aq => \*(AqData::Dumper\*(Aq,
112 \& ...
113 \& }
114 .Ve
115 .PP
116 Each time \f(CW\*(C`$finder\->next\*(C'\fR is called, the iterator returns one of two
117 possible values:
118 .IP \(bu 4
119 a CPAN::Distroprefs::Result object
120 .IP \(bu 4
121 \&\f(CW\*(C`undef\*(C'\fR, indicating that no prefs files remain to be found
122 .SH RESULTS
123 .IX Header "RESULTS"
124 \&\f(CWfind()\fR returns CPAN::Distroprefs::Result objects to
125 indicate success or failure when reading a prefs file.
126 .SS Common
127 .IX Subsection "Common"
128 All results share some common attributes:
129 .PP
130 \fItype\fR
131 .IX Subsection "type"
132 .PP
133 \&\f(CW\*(C`success\*(C'\fR, \f(CW\*(C`warning\*(C'\fR, or \f(CW\*(C`fatal\*(C'\fR
134 .PP
135 \fIfile\fR
136 .IX Subsection "file"
137 .PP
138 the file from which these prefs were read, or to which this error refers (relative filename)
139 .PP
140 \fIext\fR
141 .IX Subsection "ext"
142 .PP
143 the file\*(Aqs extension, which determines how to load it
144 .PP
145 \fIdir\fR
146 .IX Subsection "dir"
147 .PP
148 the directory the file was read from
149 .PP
150 \fIabs\fR
151 .IX Subsection "abs"
152 .PP
153 the absolute path to the file
154 .SS Errors
155 .IX Subsection "Errors"
156 Error results (warning and fatal) contain:
157 .PP
158 \fImsg\fR
159 .IX Subsection "msg"
160 .PP
161 the error message (usually either \f(CW$!\fR or a YAML error)
162 .SS Successes
163 .IX Subsection "Successes"
164 Success results contain:
165 .PP
166 \fIprefs\fR
167 .IX Subsection "prefs"
168 .PP
169 an arrayref of CPAN::Distroprefs::Pref objects
170 .SH PREFS
171 .IX Header "PREFS"
172 CPAN::Distroprefs::Pref objects represent individual distroprefs documents.
173 They are constructed automatically as part of \f(CW\*(C`success\*(C'\fR results from \f(CWfind()\fR.
174 .PP
175 \fIdata\fR
176 .IX Subsection "data"
177 .PP
178 the pref information as a hashref, suitable for e.g. passing to Kwalify
179 .PP
180 \fImatch_attributes\fR
181 .IX Subsection "match_attributes"
182 .PP
183 returns a list of the valid match attributes (see the Distroprefs section in CPAN)
184 .PP
185 currently: \f(CW\*(C`env perl perlconfig distribution module\*(C'\fR
186 .PP
187 \fIhas_any_match\fR
188 .IX Subsection "has_any_match"
189 .PP
190 true if this pref has a \*(Aqmatch\*(Aq attribute at all
191 .PP
192 \fIhas_valid_subkeys\fR
193 .IX Subsection "has_valid_subkeys"
194 .PP
195 true if this pref has a \*(Aqmatch\*(Aq attribute and at least one valid match attribute
196 .PP
197 \fImatches\fR
198 .IX Subsection "matches"
199 .PP
200 .Vb 1
201 \& if ($pref\->matches(\e%arg)) { ... }
202 .Ve
203 .PP
204 true if this pref matches the passed\-in hashref, which must have a value for
205 each of the \f(CW\*(C`match_attributes\*(C'\fR (above)
206 .SH LICENSE
207 .IX Header "LICENSE"
208 This program is free software; you can redistribute it and/or modify it under
209 the same terms as Perl itself.