@@ -312,28 +312,27 @@ features
312
312
dirs => [ qw( /etc/myapp /home/username/etc/myapp ) ],
313
313
);
314
314
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
+ },
320
324
},
321
-
322
- frontend_slave => {
323
- host => 'localhost',
324
- port => '4321',
325
- }
326
325
},
327
- }
326
+ },
328
327
);
329
328
330
329
=head1 DESCRIPTION
331
330
332
331
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> .
337
336
338
337
=head1 CONSTRUCTOR
339
338
@@ -343,7 +342,7 @@ F<.json>.
343
342
dirs => [ qw( /etc/myapp /home/username/myapp/etc ) ],
344
343
);
345
344
346
- my $another_config_processor = Config::Processor->new(
345
+ $config_processor = Config::Processor->new(
347
346
dirs => [ qw( /etc/myapp /home/username/myapp/etc ) ],
348
347
interpolate_variables => 0,
349
348
process_directives => 0,
@@ -353,27 +352,23 @@ F<.json>.
353
352
354
353
=item dirs => \@dirs
355
354
356
- List of directories in which configuration files will be serched .
355
+ List of directories, in which configuration processor will search files .
357
356
358
357
=item interpolate_variables => $boolean
359
358
360
- Enables or disables variable interpolation in configuration files.
361
-
362
- Enabled by default.
359
+ Enables or disables variable interpolation. Enabled by default.
363
360
364
361
=item process_directives => $boolean
365
362
366
- Enables or disables directive processing in configuration files.
367
-
368
- Enabled by default.
363
+ Enables or disables directive processing. Enabled by default.
369
364
370
365
=back
371
366
372
367
=head1 METHODS
373
368
374
369
=head2 load( @config_sections )
375
370
376
- my $config = $config_processor->load( qw( myapp .yml metrics/* ),
371
+ my $config = $config_processor->load( qw( dirs .yml db.json metrics/* ),
377
372
\%local_config );
378
373
379
374
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:
420
415
username: "stat_writer"
421
416
password: "stat_writer_pass"
422
417
423
- And F<db_test.yml> at the right side.
418
+ And F<db_test.yml> at the right side:
424
419
425
420
db:
426
421
connectors:
@@ -429,13 +424,13 @@ And F<db_test.yml> at the right side.
429
424
username: "test"
430
425
password: "test_pass"
431
426
432
- After processing of two files we will get:
427
+ After merging of two files we will get:
433
428
434
429
db => {
435
430
connectors => {
436
431
stat_writer => {
437
432
host => "localhost",
438
- port: => "4321 ",
433
+ port: => "1234 ",
439
434
dbname: => "stat",
440
435
username: => "test",
441
436
password: => "test_pass",
@@ -477,7 +472,7 @@ After processing of the file we will get:
477
472
},
478
473
},
479
474
480
- To escape variable interpolation add one more "$" symbol.
475
+ To escape variable interpolation add one more "$" symbol before variable .
481
476
482
477
templates_dir: "$${myapp.dirs.root_dir}/templates"
483
478
@@ -489,7 +484,7 @@ After processing we will get:
489
484
490
485
=over
491
486
492
- =item var
487
+ =item var: varname
493
488
494
489
Assigns configuration parameter value to another configuration parameter.
495
490
@@ -517,12 +512,12 @@ Assigns configuration parameter value to another configuration parameter.
517
512
password: "stat_reader_pass"
518
513
options: { var: myapp.db.generic_options }
519
514
520
- =item include
515
+ =item include: filename
521
516
522
517
Loads configuration parameters from file or multiple files and assigns it to
523
518
specified configuration parameter. Argument of C<include > directive can be
524
519
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.
526
521
527
522
myapp:
528
523
db:
@@ -537,9 +532,12 @@ files, configuration data from them will be merged before assignment.
537
532
538
533
=item underlay
539
534
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.
543
541
544
542
myapp:
545
543
db:
@@ -592,10 +590,13 @@ You can move default parameters in separate file.
592
590
593
591
=item overlay
594
592
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.
599
600
600
601
myapp:
601
602
db:
0 commit comments