Skip to content

Commit 1a458a2

Browse files
author
Eugene Ponizovsky
committed
Imrovements and fixes in POD
1 parent d494dc6 commit 1a458a2

File tree

2 files changed

+44
-40
lines changed

2 files changed

+44
-40
lines changed

README

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ To install this module type the following:
1212

1313
DESCRIPTION
1414

15-
Config::Processor is the cascading configuration files processor with file inclusions
16-
and variables interpolation support.
15+
Config::Processor is the cascading configuration files processor, which
16+
supports file inclusions, variables interpolation and other manipulations with
17+
configuration tree. Works with YAML and JSON file formats. File format is
18+
determined by the extension. Supports following file extensions: ".yml",
19+
".yaml", ".jsn", ".json". See POD documentation for more information.
1720

1821
AUTHOR
1922

lib/Config/Processor.pm

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -312,28 +312,27 @@ features
312312
dirs => [ qw( /etc/myapp /home/username/etc/myapp ) ],
313313
);
314314
315-
my $config = $config_processor->load( qw( main.yml db.json metrics/* ),
316-
{ db => {
317-
frontend_master => {
318-
host => 'localhost',
319-
port => '4321',
315+
my $config = $config_processor->load( qw( dirs.yml db.json metrics/* ),
316+
{ myapp => {
317+
db => {
318+
connectors => {
319+
stat_master => {
320+
host => 'localhost',
321+
port => '4321',
322+
},
323+
},
320324
},
321-
322-
frontend_slave => {
323-
host => 'localhost',
324-
port => '4321',
325-
}
326325
},
327-
}
326+
},
328327
);
329328
330329
=head1 DESCRIPTION
331330
332331
Config::Processor is the cascading configuration files processor, which
333-
supports file inclusions, variables interpolation and other configuration tree
334-
manipulations. Works with YAML and JSON file formats. File format is defined by
335-
file extension. Supports following file extensions: F<.yml>, F<.yaml>, F<.jsn>,
336-
F<.json>.
332+
supports file inclusions, variables interpolation and other manipulations with
333+
configuration tree. Works with YAML and JSON file formats. File format is
334+
determined by the extension. Supports following file extensions: F<.yml>,
335+
F<.yaml>, F<.jsn>, F<.json>.
337336
338337
=head1 CONSTRUCTOR
339338
@@ -343,7 +342,7 @@ F<.json>.
343342
dirs => [ qw( /etc/myapp /home/username/myapp/etc ) ],
344343
);
345344
346-
my $another_config_processor = Config::Processor->new(
345+
$config_processor = Config::Processor->new(
347346
dirs => [ qw( /etc/myapp /home/username/myapp/etc ) ],
348347
interpolate_variables => 0,
349348
process_directives => 0,
@@ -353,27 +352,23 @@ F<.json>.
353352
354353
=item dirs => \@dirs
355354
356-
List of directories in which configuration files will be serched.
355+
List of directories, in which configuration processor will search files.
357356
358357
=item interpolate_variables => $boolean
359358
360-
Enables or disables variable interpolation in configuration files.
361-
362-
Enabled by default.
359+
Enables or disables variable interpolation. Enabled by default.
363360
364361
=item process_directives => $boolean
365362
366-
Enables or disables directive processing in configuration files.
367-
368-
Enabled by default.
363+
Enables or disables directive processing. Enabled by default.
369364
370365
=back
371366
372367
=head1 METHODS
373368
374369
=head2 load( @config_sections )
375370
376-
my $config = $config_processor->load( qw( myapp.yml metrics/* ),
371+
my $config = $config_processor->load( qw( dirs.yml db.json metrics/* ),
377372
\%local_config );
378373
379374
Attempts to load all configuration sections and returns reference to resulting
@@ -420,7 +415,7 @@ For example, we have two configuration files. F<db.yml> at the left side:
420415
username: "stat_writer"
421416
password: "stat_writer_pass"
422417
423-
And F<db_test.yml> at the right side.
418+
And F<db_test.yml> at the right side:
424419
425420
db:
426421
connectors:
@@ -429,13 +424,13 @@ And F<db_test.yml> at the right side.
429424
username: "test"
430425
password: "test_pass"
431426
432-
After processing of two files we will get:
427+
After merging of two files we will get:
433428
434429
db => {
435430
connectors => {
436431
stat_writer => {
437432
host => "localhost",
438-
port: => "4321",
433+
port: => "1234",
439434
dbname: => "stat",
440435
username: => "test",
441436
password: => "test_pass",
@@ -477,7 +472,7 @@ After processing of the file we will get:
477472
},
478473
},
479474
480-
To escape variable interpolation add one more "$" symbol.
475+
To escape variable interpolation add one more "$" symbol before variable.
481476
482477
templates_dir: "$${myapp.dirs.root_dir}/templates"
483478
@@ -489,7 +484,7 @@ After processing we will get:
489484
490485
=over
491486
492-
=item var
487+
=item var: varname
493488
494489
Assigns configuration parameter value to another configuration parameter.
495490
@@ -517,12 +512,12 @@ Assigns configuration parameter value to another configuration parameter.
517512
password: "stat_reader_pass"
518513
options: { var: myapp.db.generic_options }
519514
520-
=item include
515+
=item include: filename
521516
522517
Loads configuration parameters from file or multiple files and assigns it to
523518
specified configuration parameter. Argument of C<include> directive can be
524519
relative filename or a filename with wildcard characters. If loading multiple
525-
files, configuration data from them will be merged before assignment.
520+
files, configuration parameters from them will be merged before assignment.
526521
527522
myapp:
528523
db:
@@ -537,9 +532,12 @@ files, configuration data from them will be merged before assignment.
537532
538533
=item underlay
539534
540-
Merges configuration parameters from variables or files with configuration
541-
parameters at the same nesting level and can be overrided by them. For example,
542-
you can use C<underlay> directive to set default parameters.
535+
Merges specified configuration parameters with parameters located at the same
536+
context. Configuration parameters from the context overrides parameters from
537+
the directive. C<underlay> directive most usefull in combination with C<var>
538+
and C<include> directives.
539+
540+
For example, you can use this directive to set default values of parameters.
543541
544542
myapp:
545543
db:
@@ -592,10 +590,13 @@ You can move default parameters in separate file.
592590
593591
=item overlay
594592
595-
Merges configuration parameters from variables or files with configuration
596-
parameters at the same nesting level and can override them. For example, you
597-
can use C<overlay> directive to temporaly overriding regular configuration
598-
parameters.
593+
Merges specified configuration parameters with parameters located at the same
594+
context. Configuration parameters from the directive overrides parameters from
595+
the context. C<overlay> directive most usefull in combination with C<var> and
596+
C<include> directives.
597+
598+
For example, you can use C<overlay> directive to temporaly overriding regular
599+
configuration parameters.
599600
600601
myapp:
601602
db:

0 commit comments

Comments
 (0)