line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::HAProxy::Node; |
2
|
2
|
|
|
2
|
|
581
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
44
|
|
3
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
34
|
|
4
|
2
|
|
|
2
|
|
7
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
90
|
|
5
|
2
|
|
|
2
|
|
593
|
use Config::HAProxy::Iterator; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
182
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
34
|
|
|
34
|
0
|
81
|
my $class = shift; |
9
|
34
|
|
|
|
|
87
|
local %_ = @_; |
10
|
|
|
|
|
|
|
bless { |
11
|
|
|
|
|
|
|
_kw => $_{kw}, |
12
|
|
|
|
|
|
|
_argv => $_{argv} // [], |
13
|
|
|
|
|
|
|
_orig => $_{orig}, |
14
|
|
|
|
|
|
|
_locus => $_{locus}, |
15
|
|
|
|
|
|
|
_parent => $_{parent}, |
16
|
34
|
|
100
|
|
|
206
|
_index => -1 |
17
|
|
|
|
|
|
|
}, $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my @ATTRIBUTES = qw(kw orig locus parent index); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
{ |
23
|
2
|
|
|
2
|
|
12
|
no strict 'refs'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
869
|
|
24
|
|
|
|
|
|
|
foreach my $attribute (@ATTRIBUTES) { |
25
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . $attribute } = sub { |
26
|
243
|
|
|
243
|
|
234
|
my $self = shift; |
27
|
243
|
100
|
|
|
|
279
|
if (defined(my $val = shift)) { |
28
|
60
|
50
|
|
|
|
71
|
croak "too many arguments" if @_; |
29
|
60
|
|
|
|
|
77
|
$self->{'_'.$attribute} = $val; |
30
|
|
|
|
|
|
|
} |
31
|
243
|
|
|
|
|
392
|
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
|
33
|
my $self = shift; |
47
|
30
|
|
|
|
|
25
|
my $n = shift; |
48
|
30
|
50
|
|
|
|
43
|
if (my $val = shift) { |
49
|
0
|
0
|
|
|
|
0
|
croak "too many arguments" if @_; |
50
|
0
|
|
|
|
|
0
|
$self->{_argv}[$n] = $val; |
51
|
|
|
|
|
|
|
} |
52
|
30
|
|
|
|
|
64
|
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
|
41
|
return new Config::HAProxy::Iterator(@_); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub depth { |
65
|
37
|
|
|
37
|
1
|
35
|
my $self = shift; |
66
|
37
|
|
|
|
|
28
|
my $n = 0; |
67
|
37
|
|
|
|
|
39
|
while ($self = $self->parent) { |
68
|
62
|
|
|
|
|
73
|
$n++; |
69
|
|
|
|
|
|
|
} |
70
|
37
|
|
|
|
|
60
|
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
|
48
|
my $self = shift; |
83
|
52
|
50
|
|
|
|
56
|
if (defined(my $v = $self->orig)) { |
84
|
52
|
|
|
|
|
79
|
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
|
72
|
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
|
44
|
sub is_comment { 0 } |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
__END__ |