line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geoffrey::Template; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
656
|
use utf8; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
21
|
|
4
|
4
|
|
|
4
|
|
156
|
use 5.016; |
|
4
|
|
|
|
|
14
|
|
5
|
4
|
|
|
4
|
|
22
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
111
|
|
6
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
1915
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$Geoffrey::Template::VERSION = '0.000203'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub _handle_template { |
11
|
9
|
|
|
9
|
|
16
|
my ( $self, $hr_template ) = @_; |
12
|
9
|
100
|
100
|
|
|
26
|
if ( $hr_template->{template} |
13
|
6
|
|
|
|
|
19
|
&& scalar @{ $self->template( $hr_template->{template} ) } == 0 ) |
14
|
|
|
|
|
|
|
{ |
15
|
1
|
|
|
|
|
441
|
require Geoffrey::Exception::Template; |
16
|
1
|
|
|
|
|
6
|
Geoffrey::Exception::Template::throw_template_not_found( $hr_template->{template} ); |
17
|
|
|
|
|
|
|
} |
18
|
8
|
|
|
|
|
26
|
$self->_merge_templates( $hr_template->{name}, $hr_template->{template} ); |
19
|
8
|
|
|
|
|
13
|
push @{ $self->template( $hr_template->{name} ) }, $_ for @{ $hr_template->{columns} }; |
|
8
|
|
|
|
|
18
|
|
|
13
|
|
|
|
|
25
|
|
20
|
8
|
|
|
|
|
15
|
return 1; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _merge_templates { |
24
|
8
|
|
|
8
|
|
19
|
my ( $self, $s_destination_template, $s_source_template ) = @_; |
25
|
8
|
100
|
|
|
|
16
|
return if !$s_source_template; |
26
|
|
|
|
|
|
|
push |
27
|
5
|
|
|
|
|
12
|
@{ $self->template($s_destination_template) }, |
28
|
5
|
|
|
|
|
10
|
@{ $self->template($s_source_template) }; |
|
5
|
|
|
|
|
11
|
|
29
|
5
|
|
|
|
|
8
|
return 1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
33
|
2
|
|
|
2
|
1
|
1026
|
my $class = shift; |
34
|
2
|
|
|
|
|
6
|
my $self = {@_}; |
35
|
2
|
|
|
|
|
5
|
$self->{templates} = {}; |
36
|
2
|
|
|
|
|
14
|
return bless $self, $class; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub template { |
40
|
45
|
|
|
45
|
1
|
1031
|
my ( $self, $s_template_name, $hr_template_value ) = @_; |
41
|
45
|
50
|
|
|
|
96
|
return unless $s_template_name; |
42
|
45
|
|
50
|
|
|
82
|
$self->templates->{$s_template_name} //= $hr_template_value // []; |
|
|
|
66
|
|
|
|
|
43
|
45
|
|
|
|
|
80
|
return $self->templates->{$s_template_name}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub templates { |
48
|
90
|
|
|
90
|
1
|
176
|
my ( $self, $hr_templates ) = @_; |
49
|
90
|
50
|
|
|
|
138
|
$self->{templates} = $hr_templates if $hr_templates; |
50
|
90
|
|
|
|
|
316
|
return $self->{templates}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub load_templates { |
54
|
3
|
|
|
3
|
1
|
1153
|
my ( $self, $ar_templates ) = @_; |
55
|
3
|
|
|
|
|
7
|
$self->_handle_template($_) foreach @{$ar_templates}; |
|
3
|
|
|
|
|
12
|
|
56
|
2
|
|
|
|
|
9
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |