| 1 | # Comment.pm | ||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||
| 3 | # Copyright Karthik Krishnamurthy <karthik.k@extremix.net> | ||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | Unix::Conf::Bind8::Conf::Comment - Class for handling comments | ||||||||||||||||||||||||||||||||
| 8 | between directives. | ||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | use Unix::Conf::Bind8; | ||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | my ($conf, $acl); | ||||||||||||||||||||||||||||||||
| 15 | $conf = Unix::Conf::Bind8->new_conf ( | ||||||||||||||||||||||||||||||||
| 16 | FILE => '/etc/named.conf', | ||||||||||||||||||||||||||||||||
| 17 | SECURE_OPEN => 1, | ||||||||||||||||||||||||||||||||
| 18 | ) or $conf->die ("couldn't open `named.conf'"); | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | $acl = $conf->new_acl ( | ||||||||||||||||||||||||||||||||
| 21 | NAME => 'extremix.net-slaves', | ||||||||||||||||||||||||||||||||
| 22 | ELEMENTS => [ qw (10.0.0.2 10.0.0.3) ], | ||||||||||||||||||||||||||||||||
| 23 | ) or $acl->die ("couldn't create acl `extremix.net-slaves'"); | ||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | $comment = $conf->new_comment ( | ||||||||||||||||||||||||||||||||
| 26 | COMMENT => '// Elements of this Acl are allowed to transfer this zone', | ||||||||||||||||||||||||||||||||
| 27 | WHERE => 'BEFORE', | ||||||||||||||||||||||||||||||||
| 28 | WARG => $acl, | ||||||||||||||||||||||||||||||||
| 29 | ) or $comment->die ("couldn't create comment"); | ||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | This class is not meant to be used directly, but is used instead by the | ||||||||||||||||||||||||||||||||
| 32 | parser to store intra directive comments. | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | =head1 METHODS | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | =cut | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | package Unix::Conf::Bind8::Conf::Comment; | ||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 41 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 42 | 10 | ▶ | use base qw (Unix::Conf::Bind8::Conf::Directive); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | =over 4 | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | =item new () | ||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | Arguments | ||||||||||||||||||||||||||||||||
| 49 | COMMENT => 'comment', | ||||||||||||||||||||||||||||||||
| 50 | WHERE => 'FIRST'|'LAST'|'BEFORE'|'AFTER' | ||||||||||||||||||||||||||||||||
| 51 | WARG => Unix::Conf::Bind8::Conf::Directive subclass object | ||||||||||||||||||||||||||||||||
| 52 | # WARG is to be provided only in case WHERE eq 'BEFORE | ||||||||||||||||||||||||||||||||
| 53 | # or WHERE eq 'AFTER' | ||||||||||||||||||||||||||||||||
| 54 | PARENT => reference, # to the Conf object datastructure. | ||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | Class constructor | ||||||||||||||||||||||||||||||||
| 57 | Creates a Unix::Conf::Bind8::Conf::Comment object and returns it, | ||||||||||||||||||||||||||||||||
| 58 | on success, an Err object otherwise. Do not use this constructor directly. | ||||||||||||||||||||||||||||||||
| 59 | Use the Unix::Conf::Bind8::Conf::new_comment method () instead. | ||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | =cut | ||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | sub new | ||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 65 | 0 | my $self = shift (); | |||||||||||||||||||||||||||||||
| 66 | 0 | my $new = bless ({}); | |||||||||||||||||||||||||||||||
| 67 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||
| 68 | 0 | my $ret; | |||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | return (Unix::Conf->_err ('new', "PARENT not defined")) | ||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | unless ($args{PARENT}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | $ret = $new->_parent ($args{PARENT}) or return ($ret); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 73 | $ret = $new->comment ($args{COMMENT}) or return ($ret) | ||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ($args{COMMENT}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$args{'COMMENT'} && (($ret = $new->comment($args{'COMMENT'})) || (return $ret))
$ret = $new->comment($args{"COMMENT"}) or return $ret
MC/DC0%0/2
$args{'COMMENT'} && (($ret = $new->comment($args{'COMMENT'})) || (return $ret))
$args{'COMMENT'}
$ret = $new->comment($args{"COMMENT"})
Truth table0%0/3
A && B
A= $args{'COMMENT'}B= $ret = $new->comment($args{"COMMENT"})
| |||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | $args{WHERE} = 'LAST' unless ($args{WHERE}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 76 | $ret = Unix::Conf::Bind8::Conf::_insert_in_list ($new, $args{WHERE}, $args{WARG}) | ||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | or return ($ret); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 78 | 0 | return ($new); | |||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | =item comment () | ||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | Object method. | ||||||||||||||||||||||||||||||||
| 84 | Get/set the comment. If argument is passed, sets the comment, and returns | ||||||||||||||||||||||||||||||||
| 85 | true on success, an Err object otherwise. If no argument is passed, returns | ||||||||||||||||||||||||||||||||
| 86 | the set value. | ||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | =cut | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | sub comment | ||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
comment: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 92 | 0 | my ($self, $comment) = @_; | |||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if ($comment) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 95 | 0 | $self->_rstring (\$comment); | |||||||||||||||||||||||||||||||
| 96 | 0 | return (1) | |||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||
| 98 | 0 | return (${$self->_rstring ()}); | |||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||
| 101 | sub __render | ||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
__render: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 103 | 0 | return (1); | |||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | 10 | 1; | |||||||||||||||||||||||||||||||