1CPAN::Distroprefs(3pm) Perl Programmers Reference Guide CPAN::Distroprefs(3pm)
2
3
4

NAME

6       CPAN::Distroprefs -- read and match distroprefs
7

SYNOPSIS

9           use CPAN::Distroprefs;
10
11           my %info = (... distribution/environment info ...);
12
13           my $finder = CPAN::Distroprefs->find($prefs_dir, \%ext_map);
14
15           while (my $result = $finder->next) {
16
17               die $result->as_string if $result->is_fatal;
18
19               warn($result->as_string), next if $result->is_warning;
20
21               for my $pref (@{ $result->prefs }) {
22                   if ($pref->matches(\%info)) {
23                       return $pref;
24                   }
25               }
26           }
27

DESCRIPTION

29       This module encapsulates reading Distroprefs and matching them against
30       CPAN distributions.
31

INTERFACE

33           my $finder = CPAN::Distroprefs->find($dir, \%ext_map);
34
35           while (my $result = $finder->next) { ... }
36
37       Build an iterator which finds distroprefs files in the given directory.
38
39       %ext_map is a hashref whose keys are file extensions and whose values
40       are modules used to load matching files:
41
42           {
43               'yml' => 'YAML::Syck',
44               'dd'  => 'Data::Dumper',
45               ...
46           }
47
48       Each time "$finder->next" is called, the iterator returns one of two
49       possible values:
50
51       ·   a CPAN::Distroprefs::Result object
52
53       ·   "undef", indicating that no prefs files remain to be found
54

RESULTS

56       "find()" returns CPAN::Distroprefs::Result objects to indicate success
57       or failure when reading a prefs file.
58
59   Common
60       All results share some common attributes:
61
62       type
63
64       "success", "warning", or "fatal"
65
66       file
67
68       the file from which these prefs were read, or to which this error
69       refers (relative filename)
70
71       ext
72
73       the file's extension, which determines how to load it
74
75       dir
76
77       the directory the file was read from
78
79       abs
80
81       the absolute path to the file
82
83   Errors
84       Error results (warning and fatal) contain:
85
86       msg
87
88       the error message (usually either $! or a YAML error)
89
90   Successes
91       Success results contain:
92
93       prefs
94
95       an arrayref of CPAN::Distroprefs::Pref objects
96

PREFS

98       CPAN::Distroprefs::Pref objects represent individual distroprefs
99       documents.  They are constructed automatically as part of "success"
100       results from "find()".
101
102       data
103
104       the pref information as a hashref, suitable for e.g. passing to Kwalify
105
106       match_attributes
107
108       returns a list of the valid match attributes (see the Distroprefs
109       section in CPAN)
110
111       currently: "env perl perlconfig distribution module"
112
113       has_any_match
114
115       true if this pref has a 'match' attribute at all
116
117       has_valid_subkeys
118
119       true if this pref has a 'match' attribute and at least one valid match
120       attribute
121
122       matches
123
124         if ($pref->matches(\%arg)) { ... }
125
126       true if this pref matches the passed-in hashref, which must have a
127       value for each of the "match_attributes" (above)
128

LICENSE

130       This program is free software; you can redistribute it and/or modify it
131       under the same terms as Perl itself.
132
133
134
135perl v5.16.3                      2013-03-04            CPAN::Distroprefs(3pm)
Impressum