line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::HAProxy::Node; |
2
|
3
|
|
|
3
|
|
1197
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
86
|
|
3
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
65
|
|
4
|
3
|
|
|
3
|
|
14
|
use Carp; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
153
|
|
5
|
3
|
|
|
3
|
|
1159
|
use Config::HAProxy::Iterator; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
301
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
40
|
|
|
40
|
0
|
55
|
my $class = shift; |
9
|
40
|
|
|
|
|
128
|
local %_ = @_; |
10
|
|
|
|
|
|
|
bless { |
11
|
|
|
|
|
|
|
_kw => $_{kw}, |
12
|
|
|
|
|
|
|
_argv => $_{argv} // [], |
13
|
|
|
|
|
|
|
_orig => $_{orig}, |
14
|
|
|
|
|
|
|
_locus => $_{locus}, |
15
|
|
|
|
|
|
|
_parent => $_{parent}, |
16
|
40
|
|
100
|
|
|
305
|
_index => -1 |
17
|
|
|
|
|
|
|
}, $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my @ATTRIBUTES = qw(kw orig locus parent index); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
{ |
23
|
3
|
|
|
3
|
|
40
|
no strict 'refs'; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
1647
|
|
24
|
|
|
|
|
|
|
foreach my $attribute (@ATTRIBUTES) { |
25
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . $attribute } = sub { |
26
|
251
|
|
|
251
|
|
258
|
my $self = shift; |
27
|
251
|
100
|
|
|
|
364
|
if (defined(my $val = shift)) { |
28
|
68
|
50
|
|
|
|
93
|
croak "too many arguments" if @_; |
29
|
68
|
|
|
|
|
113
|
$self->{'_'.$attribute} = $val; |
30
|
|
|
|
|
|
|
} |
31
|
251
|
|
|
|
|
539
|
return $self->{'_'.$attribute}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub argv { |
37
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
38
|
0
|
0
|
|
|
|
0
|
if (my $val = shift) { |
39
|
0
|
0
|
|
|
|
0
|
croak "too many arguments" if @_; |
40
|
0
|
|
|
|
|
0
|
$self->{_argv} = $val; |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
0
|
return @{$self->{_argv}}; |
|
0
|
|
|
|
|
0
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub arg { |
46
|
30
|
|
|
30
|
1
|
43
|
my $self = shift; |
47
|
30
|
|
|
|
|
29
|
my $n = shift; |
48
|
30
|
50
|
|
|
|
47
|
if (my $val = shift) { |
49
|
0
|
0
|
|
|
|
0
|
croak "too many arguments" if @_; |
50
|
0
|
|
|
|
|
0
|
$self->{_argv}[$n] = $val; |
51
|
|
|
|
|
|
|
} |
52
|
30
|
|
|
|
|
76
|
return $self->{_argv}[$n]; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub drop { |
56
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
57
|
0
|
|
|
|
|
0
|
$self->parent->delete_node($self->index); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub iterator { |
61
|
20
|
|
|
20
|
1
|
51
|
return new Config::HAProxy::Iterator(@_); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub depth { |
65
|
37
|
|
|
37
|
1
|
41
|
my $self = shift; |
66
|
37
|
|
|
|
|
36
|
my $n = 0; |
67
|
37
|
|
|
|
|
50
|
while ($self = $self->parent) { |
68
|
62
|
|
|
|
|
83
|
$n++; |
69
|
|
|
|
|
|
|
} |
70
|
37
|
|
|
|
|
69
|
return $n - 1; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub root { |
74
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
75
|
0
|
|
|
|
|
0
|
while ($self->parent()) { |
76
|
0
|
|
|
|
|
0
|
$self = $self->parent(); |
77
|
|
|
|
|
|
|
} |
78
|
0
|
|
|
|
|
0
|
return $self; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub as_string { |
82
|
52
|
|
|
52
|
1
|
61
|
my $self = shift; |
83
|
52
|
50
|
|
|
|
66
|
if (defined(my $v = $self->orig)) { |
84
|
52
|
|
|
|
|
93
|
return $v; |
85
|
|
|
|
|
|
|
} |
86
|
0
|
0
|
|
|
|
0
|
return '' unless $self->kw; |
87
|
0
|
|
|
|
|
0
|
return $self->orig(join(' ', ($self->kw, $self->argv()))); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# use overload |
91
|
|
|
|
|
|
|
# '""' => sub { shift->as_string }; |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
0
|
1
|
0
|
sub is_root { 0 } |
94
|
36
|
|
|
36
|
1
|
83
|
sub is_section { 0 } |
95
|
0
|
|
|
0
|
1
|
0
|
sub is_statement { 0 } |
96
|
0
|
|
|
0
|
1
|
0
|
sub is_empty { 0 } |
97
|
36
|
|
|
36
|
1
|
54
|
sub is_comment { 0 } |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
__END__ |