summaryrefslogtreecommitdiff
path: root/lib/Config/HAProxy/Node/Section.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Config/HAProxy/Node/Section.pm')
-rw-r--r--lib/Config/HAProxy/Node/Section.pm153
1 files changed, 152 insertions, 1 deletions
diff --git a/lib/Config/HAProxy/Node/Section.pm b/lib/Config/HAProxy/Node/Section.pm
index c332155..3ef1cf0 100644
--- a/lib/Config/HAProxy/Node/Section.pm
+++ b/lib/Config/HAProxy/Node/Section.pm
@@ -6,2 +6,14 @@ use Carp;
+=head1 NAME
+
+Config::HAProxy::Node::Section - HAProxy configuration section
+
+=head1 DESCRIPTION
+
+Objects of this class represent a C<section> in the HAProxy configuration file.
+A section is a statement that can contain sub-statements. The following
+statements form sections: B<global>, B<defaults>, B<frontend>, and B<backend>.
+
+=cut
+
sub new {
@@ -13,4 +25,47 @@ sub new {
+=head1 ATTRIBUTES
+
+=head2 is_section
+
+Always true.
+
+=cut
+
sub is_section { 1 }
+=head1 METHODS
+
+=head2 kw
+
+Returns the configuration keyword.
+
+=head2 argv
+
+Returns the list of arguments to the configuration keyword.
+
+=head2 arg
+
+ $s = $node->arg($n)
+
+Returns the B<$n>th argument.
+
+=head2 orig
+
+Returns original line as it appeared in the configuration file.
+
+=head2 locus
+
+Returns the location of this statement in the configuration file (the
+B<Text::Locus> object).
+
+=head2 append_node
+
+ $section->append_node(@nodes);
+
+Takes a list of objects of B<Config::HAProxy::Node> derived classes as
+arguments. Adds these objects after the last node in the subtree in this
+section.
+
+=cut
+
sub append_node {
@@ -26,2 +81,11 @@ sub append_node {
+=head2 append_node_nonempty
+
+ $section->append_node_nonempty(@nodes);
+
+Same as B<append_node>, but adds new nodes after the last non-empty
+node in the subtree.
+
+=cut
+
sub append_node_nonempty {
@@ -34,3 +98,11 @@ sub append_node_nonempty {
}
-
+
+=head2 insert_node
+
+ $section->insert_node($idx, @nodes);
+
+Inserts B<@nodes> after subnode in position B<$idx> (0-based).
+
+=cut
+
sub insert_node {
@@ -50,2 +122,10 @@ sub insert_node {
+=head2 delete_node
+
+ $section->delete_node($i);
+
+Deletes B<$i>th subnode from the B<$section>.
+
+=cut
+
sub delete_node {
@@ -59,2 +139,14 @@ sub delete_node {
+=head2 tree
+
+ @nodes = $section->tree;
+
+Returns subnodes as a list of B<Config::HAProxy::Node> derived objects.
+
+ $node = $section->tree($i);
+
+Returns B<$i>th subnode from the B<$section>.
+
+=cut
+
sub tree {
@@ -68,2 +160,11 @@ sub tree {
+=head2 ends_in_empty
+
+ $bool = $section->ends_in_empty
+
+Returns true if the last node in the list of sub-nodes in B<$section> is
+an empty node.
+
+=cut
+
sub ends_in_empty {
@@ -112,2 +213,46 @@ my %match = (
+=head2 select
+
+ @nodes = $section->select(%cond);
+
+Returns nodes from B<$section> that match conditions in B<%cond>. Valid
+conditions are:
+
+=over 4
+
+=item B<name =E<gt>> I<$s>
+
+Node matches if its keyword (B<kw>) equals I<$s>.
+
+=item B<arg =E<gt>> B<{ n =E<gt>> I<$n>, B<v> =E<gt> I<$s> B<}>
+
+Node mathches if its I<$n>th argument equals I<$s>.
+
+=item B<section =E<gt>> I<$bool>
+
+Node matches if it is (or is not, if I<$bool> is false) a section.
+
+=item B<statement =E<gt>> I<$bool>
+
+Node matches if it is (not) a simple statement.
+
+=item B<comment =E<gt>> I<$bool>
+
+Node matches if it is (not) a comment.
+
+=back
+
+Multiple conditions are checked in the order of their appearance in the
+argument list and are joined by the short-circuit logical C<and>.
+
+For example, to return all B<frontend> statements:
+
+ @fe = $section->select(name => 'frontend');
+
+To return the frontend named C<in>:
+
+ ($fe) = $section->select( name => 'frontend',
+ arg => { n => 0, v => 'in' } );
+
+=cut
@@ -140,2 +285,8 @@ sub _test_node {
+=head1 SEE ALSO
+
+B<Config::HAProxy::Node>, B<Config::HAProxy>, B<Text::Locus>.
+
+=cut
+
1;

Return to:

Send suggestions and report system problems to the System administrator.