|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Geoffrey::Template;  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
3
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
715
 | 
 use utf8;  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
24
 | 
    | 
| 
4
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
154
 | 
 use 5.016;  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
13
 | 
    | 
| 
5
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
21
 | 
 use strict;  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
106
 | 
    | 
| 
6
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
23
 | 
 use warnings;  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1959
 | 
    | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $Geoffrey::Template::VERSION = '0.000204';  | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _handle_template {  | 
| 
11
 | 
9
 | 
 
 | 
 
 | 
  
9
  
 | 
 
 | 
14
 | 
     my ( $self, $hr_template ) = @_;  | 
| 
12
 | 
9
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
27
 | 
     if ( $hr_template->{template}  | 
| 
13
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
22
 | 
         && scalar @{ $self->template( $hr_template->{template} ) } == 0 )  | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     {  | 
| 
15
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
523
 | 
         require Geoffrey::Exception::Template;  | 
| 
16
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
         Geoffrey::Exception::Template::throw_template_not_found( $hr_template->{template} );  | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
18
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
25
 | 
     $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
 | 
 
 | 
 
 | 
 
 | 
 
 | 
24
 | 
    | 
| 
20
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
17
 | 
     return 1;  | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _merge_templates {  | 
| 
24
 | 
8
 | 
 
 | 
 
 | 
  
8
  
 | 
 
 | 
21
 | 
     my ( $self, $s_destination_template, $s_source_template ) = @_;  | 
| 
25
 | 
8
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
20
 | 
     return if !$s_source_template;  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     push  | 
| 
27
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11
 | 
       @{ $self->template($s_destination_template) },  | 
| 
28
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
       @{ $self->template($s_source_template) };  | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11
 | 
    | 
| 
29
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
     return 1;  | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
31
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub new {  | 
| 
33
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
  
1
  
 | 
1012
 | 
     my $class = shift;  | 
| 
34
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     my $self  = {@_};  | 
| 
35
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     $self->{templates} = {};  | 
| 
36
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
13
 | 
     return bless $self, $class;  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub template {  | 
| 
40
 | 
45
 | 
 
 | 
 
 | 
  
45
  
 | 
  
1
  
 | 
1055
 | 
     my ( $self, $s_template_name, $hr_template_value ) = @_;  | 
| 
41
 | 
45
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
88
 | 
     return unless $s_template_name;  | 
| 
42
 | 
45
 | 
 
 | 
  
 50
  
 | 
 
 | 
 
 | 
97
 | 
     $self->templates->{$s_template_name} //= $hr_template_value // [];  | 
| 
 
 | 
 
 | 
 
 | 
  
 66
  
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
43
 | 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
246
 | 
     return $self->templates->{$s_template_name};  | 
| 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
46
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub templates {  | 
| 
48
 | 
90
 | 
 
 | 
 
 | 
  
90
  
 | 
  
1
  
 | 
128
 | 
     my ( $self, $hr_templates ) = @_;  | 
| 
49
 | 
90
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
159
 | 
     $self->{templates} = $hr_templates if $hr_templates;  | 
| 
50
 | 
90
 | 
 
 | 
 
 | 
 
 | 
 
 | 
331
 | 
     return $self->{templates};  | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
52
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub load_templates {  | 
| 
54
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
  
1
  
 | 
1146
 | 
     my ( $self, $ar_templates ) = @_;  | 
| 
55
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     $self->_handle_template($_) foreach @{$ar_templates};  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
14
 | 
    | 
| 
56
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
     return $self;  | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
58
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
60
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |