line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::TestBase::Block; |
2
|
14
|
|
|
14
|
|
80
|
use strict; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
469
|
|
3
|
14
|
|
|
14
|
|
76
|
use warnings; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
401
|
|
4
|
14
|
|
|
14
|
|
1259
|
use utf8; |
|
14
|
|
|
|
|
34
|
|
|
14
|
|
|
|
|
97
|
|
5
|
|
|
|
|
|
|
use Class::Accessor::Lite ( |
6
|
14
|
|
|
|
|
245
|
ro => [qw/name description/], |
7
|
14
|
|
|
14
|
|
616
|
); |
|
14
|
|
|
|
|
25
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
33
|
|
|
33
|
0
|
328
|
my $class = shift; |
11
|
33
|
50
|
|
|
|
239
|
my %args = @_==1 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
0
|
|
12
|
33
|
|
|
|
|
318
|
bless { |
13
|
|
|
|
|
|
|
_section_order => [], |
14
|
|
|
|
|
|
|
%args |
15
|
|
|
|
|
|
|
}, $class; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub has_section { |
19
|
94
|
|
|
94
|
1
|
897
|
my ($self, $key) = @_; |
20
|
94
|
|
|
|
|
925
|
return exists($self->{_value_map}->{$key}); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub get_section { |
24
|
68
|
|
|
68
|
1
|
11071
|
my ($self, $key) = @_; |
25
|
68
|
|
|
|
|
149
|
my $value = $self->{_value_map}->{$key}; |
26
|
68
|
50
|
|
|
|
174
|
return undef unless defined $value; |
27
|
68
|
100
|
|
|
|
392
|
return wantarray ? @$value : $value->[0]; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub get_sections { |
31
|
0
|
|
|
0
|
1
|
0
|
my ($self, $key) = @_; |
32
|
0
|
|
|
|
|
0
|
map { $self->{_value_map}->{$_} } $self->get_section_names(); |
|
0
|
|
|
|
|
0
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub get_section_names { |
36
|
26
|
|
|
26
|
0
|
46
|
my ($self, $key) = @_; |
37
|
26
|
|
|
|
|
41
|
@{$self->{_section_order}}; |
|
26
|
|
|
|
|
108
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_filter { |
41
|
0
|
|
|
0
|
1
|
0
|
my ($self, $key) = @_; |
42
|
0
|
|
|
|
|
0
|
$self->{_filter_map}->{$key}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub get_lineno { |
46
|
13
|
|
|
13
|
0
|
4951
|
my $self = shift; |
47
|
13
|
|
|
|
|
343
|
return $self->{_lineno}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub push_section { |
51
|
48
|
|
|
48
|
0
|
108
|
my ($self, $key, $value, $filters) = @_; |
52
|
48
|
|
|
|
|
220
|
$self->{_filter_map}->{$key} = $filters; |
53
|
48
|
|
|
|
|
189
|
$self->{_value_map}->{$key} = [$value]; |
54
|
48
|
|
|
|
|
83
|
push @{$self->{_section_order}}, $key; |
|
48
|
|
|
|
|
265
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub set_section { |
58
|
37
|
|
|
37
|
0
|
199
|
my ($self, $key, @values) = @_; |
59
|
37
|
|
|
|
|
266
|
$self->{_value_map}->{$key} = [@values]; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
our $AUTOLOAD; |
63
|
|
|
|
|
|
|
sub AUTOLOAD { |
64
|
17
|
|
|
17
|
|
170
|
$AUTOLOAD =~ s/.*:://; |
65
|
17
|
|
|
|
|
40
|
my $self = shift; |
66
|
17
|
50
|
|
|
|
61
|
return if $AUTOLOAD eq 'DESTROY'; |
67
|
17
|
50
|
|
|
|
47
|
unless ($self->has_section($AUTOLOAD)) { |
68
|
0
|
|
|
|
|
0
|
Carp::croak("There is no $AUTOLOAD' sction in the block."); |
69
|
|
|
|
|
|
|
} |
70
|
17
|
|
|
|
|
52
|
$self->get_section($AUTOLOAD); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
__END__ |