1Config::MVP::Reader(3)User Contributed Perl DocumentationConfig::MVP::Reader(3)
2
3
4
6 Config::MVP::Reader - object to read config from storage into an
7 assembler
8
10 version 2.200013
11
13 use Config::MVP::Reader::YAML; # this doesn't really exist
14
15 my $reader = Config::MVP::Reader::YAML->new;
16
17 my $sequence = $reader->read_config('/etc/foobar.yml');
18
20 A Config::MVP::Reader exists to read configuration data from storage
21 (like a file) and convert that data into instructions to a
22 Config::MVP::Assembler, which will in turn convert them into a
23 Config::MVP::Sequence, the final product.
24
26 This module should work on any version of perl still receiving updates
27 from the Perl 5 Porters. This means it should work on any version of
28 perl released in the last two to three years. (That is, if the most
29 recently released version is v5.40, then this module should work on
30 both v5.40 and v5.38.)
31
32 Although it may work on older versions of perl, no guarantee is made
33 that the minimum required version will not be increased. The version
34 may be increased for any reason, and there is no promise that patches
35 will be accepted to lower the minimum required perl.
36
38 add_cwd_to_lib
39 If true (which it is by default) then the current working directly will
40 be locally added to @INC during config loading. This helps deal with
41 changes made in Perl v5.26.1.
42
44 read_config
45 my $sequence = $reader->read_config($location, \%arg);
46
47 This method is passed a location, which has no set meaning, but should
48 be the mechanism by which the Reader is told how to locate
49 configuration. It might be a file name, a hashref of parameters, a
50 DBH, or anything else, depending on the needs of the specific Reader
51 subclass.
52
53 It is also passed a hashref of arguments, of which there is only one
54 valid argument:
55
56 assembler - the Assembler object into which to read the config
57
58 If no assembler argument is passed, one will be constructed by calling
59 the Reader's "build_assembler" method.
60
61 Subclasses should generally not override "read_config", but should
62 instead implement a "read_into_assembler" method, described below. If
63 a subclass does override "read_config" it should take care to respect
64 the "add_cwd_to_lib" attribute, above.
65
66 read_into_assembler
67 This method should not be called directly. It is called by
68 "read_config" with the following parameters:
69
70 my $sequence = $reader->read_into_assembler( $location, $assembler );
71
72 The method should read the configuration found at $location and use it
73 to instruct the $assembler (a Config::MVP::Assembler) what
74 configuration to perform.
75
76 The default implementation of this method will throw an exception
77 complaining that it should have been implemented by a subclass.
78
79 build_assembler
80 If no Assembler is provided to "read_config"'s "assembler" parameter,
81 this method will be called on the Reader to construct one.
82
83 It must return a Config::MVP::Assembler object, and by default will
84 return an entirely generic one.
85
87 Ricardo Signes <cpan@semiotic.systems>
88
90 This software is copyright (c) 2022 by Ricardo Signes.
91
92 This is free software; you can redistribute it and/or modify it under
93 the same terms as the Perl 5 programming language system itself.
94
95
96
97perl v5.38.0 2023-07-20 Config::MVP::Reader(3)