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