File Coverage

lib/Config/Pound.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 15 16 93.7


line stmt bran cond sub pod time code
1             package Config::Pound;
2 3     3   313229 use strict;
  3         5  
  3         94  
3 3     3   11 use warnings;
  3         4  
  3         146  
4 3     3   40 use parent 'Config::Proxy';
  3         4  
  3         16  
5              
6             sub new {
7 3     3 0 738917 my $class = shift;
8 3         37 return $class->SUPER::new('pound', @_);
9             }
10              
11             1;
12             =head1 NAME
13              
14             Config::Pound - Parser for Pound configuration file
15              
16             =head1 SYNOPSIS
17              
18             use Config::Pound;
19             $cfg = new Config::Pound([$filename, $linter_program]);
20             $cfg->parse;
21              
22             $name = $cfg->filename;
23              
24             @listeners = $cfg->select(name => 'ListenHTTP');
25              
26             $itr = $cfg->iterator(inorder => 1);
27             while (defined($node = $itr->next)) {
28             # do something with $node
29             }
30              
31             $cfg->lint(enable => 1, command => 'pound -c -f',
32             path => '/sbin:/usr/sbin')
33              
34             $cfg->save(%hash);
35              
36             $cfg->write($file_or_handle, %hash);
37              
38             $cfg->backup;
39             $name = $self->backup_name;
40              
41             $cfg->reset;
42             $cfg->push($node);
43             $node = $cfg->pop;
44             $node = $cfg->tos;
45             $node = $cfg->tree;
46              
47             =head1 DESCRIPTION
48              
49             The B class is a parser that converts the B
50             configuration file to a parse tree and provides methods for various
51             operations on this tree, such as: searching, modifying and saving it
52             to a file.
53              
54             An object of this class contains a I representing the
55             configuration read from the file (or created from scratch). See
56             L, for a detailed discussion. The following
57             describes nodes, specific for B configuration files:
58              
59             =over 4
60              
61             =item IP (L)
62              
63             Objects of this type represent IP addresses or CIDRs from an
64             B section in Pound configuration section.
65              
66             =item Section (L)
67              
68             A container, representing a C, or C
: a
69             statement that contains multiple sub-statements. Examples of compound
70             statements in B configuration file are: B,
71             B
, and B (the list is not exhaustive).
72              
73             =item Verbatim (L)
74              
75             Objects of this class represent verbatim context embedded in
76             a Pound configuration. Currently it is used to represent contents of
77             B statement in B section.
78              
79             =back
80              
81             =head1 CONSTRUCTOR
82              
83             $cfg = new Config::Pound([$filename, $linter]);
84              
85             Creates and returns a new object for manipulating Pound configuration file.
86             Optional B<$filename> specifies the name of the file to read configuration
87             from. It defaults to F.
88              
89             Optional B<$linter> parameter supplies a shell command to be called in order
90             to check configuration file syntax. The command will be called by B and
91             B methods before saving the configuration file. See
92             L and L. Default linter command
93             is F.
94              
95             =head1 METHODS AND ATTRIBUTES
96              
97             See L, for a detailed discussion of these.
98              
99             =head1 SEE ALSO
100              
101             L,
102             L,
103             L,
104             L,
105             L,
106             L
107             L,
108             L,
109             L,
110             L.
111              
112             =head1 AUTHOR
113              
114             Sergey Poznyakoff, Egray@gnu.orgE
115              
116             =head1 COPYRIGHT AND LICENSE
117              
118             Copyright (C) 2023, 2024 by Sergey Poznyakoff
119              
120             This library is free software; you can redistribute it and/or modify it
121             under the terms of the GNU General Public License as published by the
122             Free Software Foundation; either version 3 of the License, or (at your
123             option) any later version.
124              
125             It is distributed in the hope that it will be useful,
126             but WITHOUT ANY WARRANTY; without even the implied warranty of
127             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
128             GNU General Public License for more details.
129              
130             You should have received a copy of the GNU General Public License along
131             with this library. If not, see .
132              
133             =cut