diff options
Diffstat (limited to 'lib/Config/HAProxy.pm')
-rw-r--r-- | lib/Config/HAProxy.pm | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/lib/Config/HAProxy.pm b/lib/Config/HAProxy.pm index 175e402..f220051 100644 --- a/lib/Config/HAProxy.pm +++ b/lib/Config/HAProxy.pm | |||
@@ -16,13 +16,14 @@ use File::Spec; | |||
16 | use IPC::Cmd qw(run); | 16 | use IPC::Cmd qw(run); |
17 | use Carp; | 17 | use Carp; |
18 | 18 | ||
19 | our $VERSION = '1.04'; | 19 | our $VERSION = '1.08'; |
20 | 20 | ||
21 | my %sections = ( | 21 | my %sections = ( |
22 | global => 1, | 22 | global => 1, |
23 | defaults => 1, | 23 | defaults => 1, |
24 | frontend => 1, | 24 | frontend => 1, |
25 | backend => 1, | 25 | backend => 1, |
26 | resolvers => 1 | ||
26 | ); | 27 | ); |
27 | 28 | ||
28 | sub new { | 29 | sub new { |
@@ -88,6 +89,16 @@ sub parse { | |||
88 | return $self; | 89 | return $self; |
89 | } | 90 | } |
90 | 91 | ||
92 | sub declare_section { | ||
93 | my ($class, $name) = @_; | ||
94 | $sections{$name} = 1; | ||
95 | } | ||
96 | |||
97 | sub undeclare_section { | ||
98 | my ($class, $name) = @_; | ||
99 | $sections{$name} = 0; | ||
100 | } | ||
101 | |||
91 | sub reset { | 102 | sub reset { |
92 | my $self = shift; | 103 | my $self = shift; |
93 | $self->{_stack} = [ new Config::HAProxy::Node::Root() ]; | 104 | $self->{_stack} = [ new Config::HAProxy::Node::Root() ]; |
@@ -344,7 +355,9 @@ Represents a simple statement. | |||
344 | 355 | ||
345 | A container, representing a C<compound statement>, i.e. a statement that | 356 | A container, representing a C<compound statement>, i.e. a statement that |
346 | contains multiple sub-statements. Compound statements are: B<global>, | 357 | contains multiple sub-statements. Compound statements are: B<global>, |
347 | B<defaults>, B<frontend>, and B<backend>. | 358 | B<defaults>, B<frontend>, B<backend>, and B<resolvers>. The list of |
359 | compound statements may be modified using the B<declare_section> and | ||
360 | B<undeclare_section> class methods (see below). | ||
348 | 361 | ||
349 | =back | 362 | =back |
350 | 363 | ||
@@ -369,7 +382,17 @@ Additionally, section nodes provide methods for accessing their subtrees. | |||
369 | 382 | ||
370 | For a detailed description of the node class and its methods, please refer to | 383 | For a detailed description of the node class and its methods, please refer to |
371 | B<Config::HAProxy::Node>. | 384 | B<Config::HAProxy::Node>. |
372 | 385 | ||
386 | =head1 CLASS METHODS | ||
387 | |||
388 | $cfg = Config::HAProxy::declare_section($name) | ||
389 | |||
390 | Declares B<$name> as a top-level section. | ||
391 | |||
392 | $cfg = Config::HAProxy::undeclare_section($name) | ||
393 | |||
394 | Cancels declaration of B<$name> as a top-level section. | ||
395 | |||
373 | =head1 CONSTRUCTOR | 396 | =head1 CONSTRUCTOR |
374 | 397 | ||
375 | $cfg = new Config::HAProxy($filename); | 398 | $cfg = new Config::HAProxy($filename); |