| 1 | package Geoffrey::Template; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use 5.016; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 4 | $Geoffrey::Template::VERSION = '0.000206'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 9 | ▶ | sub _handle_template { | ||||||||||||||||||||||||||
|
Subroutine
_handle_template: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 11 | 9 | my ( $self, $hr_template ) = @_; | |||||||||||||||||||||||||||
| 12 | 9 | ▶ | if ( $hr_template->{template} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$hr_template->{"template"} and scalar @{$self->template($hr_template->{"template"});} == 0
MC/DC100%2/2
$hr_template->{"template"} and scalar @{$self->template($hr_template->{"template"});} == 0
$hr_template->{"template"}
scalar @{$self->template($hr_template->{"template"});} == 0
Truth table100%3/3
A and B
A= $hr_template->{"template"}B= scalar @{$self->template($hr_template->{"template"});} == 0
| |||||||||||||||||||||||||||||
| 13 | 6 | && scalar @{ $self->template( $hr_template->{template} ) } == 0 ) | |||||||||||||||||||||||||||
| 14 | { | ||||||||||||||||||||||||||||
| 15 | 1 | require Geoffrey::Exception::Template; | |||||||||||||||||||||||||||
| 16 | 1 | Geoffrey::Exception::Template::throw_template_not_found( $hr_template->{template} ); | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | 8 | $self->_merge_templates( $hr_template->{name}, $hr_template->{template} ); | |||||||||||||||||||||||||||
| 19 | 8 | push @{ $self->template( $hr_template->{name} ) }, $_ for @{ $hr_template->{columns} }; | |||||||||||||||||||||||||||
| 20 | 8 | return 1; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 8 | ▶ | sub _merge_templates { | ||||||||||||||||||||||||||
|
Subroutine
_merge_templates: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 24 | 8 | my ( $self, $s_destination_template, $s_source_template ) = @_; | |||||||||||||||||||||||||||
| 25 | 8 | ▶ | return if !$s_source_template; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | push | ||||||||||||||||||||||||||||
| 27 | 5 | @{ $self->template($s_destination_template) }, | |||||||||||||||||||||||||||
| 28 | 5 | @{ $self->template($s_source_template) }; | |||||||||||||||||||||||||||
| 29 | 5 | return 1; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 33 | 2 | my $class = shift; | |||||||||||||||||||||||||||
| 34 | 2 | my $self = {@_}; | |||||||||||||||||||||||||||
| 35 | 2 | $self->{templates} = {}; | |||||||||||||||||||||||||||
| 36 | 2 | return bless $self, $class; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 45 | ▶ | sub template { | ||||||||||||||||||||||||||
|
Subroutine
template: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||
| 40 | 45 | my ( $self, $s_template_name, $hr_template_value ) = @_; | |||||||||||||||||||||||||||
| 41 | 45 | ▶ | return unless $s_template_name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 45 | ▶ | $self->templates->{$s_template_name} //= $hr_template_value // []; | ||||||||||||||||||||||||||
|
Condition75%3/4
$self->templates->{$s_template_name} //= $hr_template_value // []
$hr_template_value // []
MC/DC100%1/1
$self->templates->{$s_template_name} //= $hr_template_value // []
$self->templates->{$s_template_name}
Truth table100%2/2
A
A= $self->templates->{$s_template_name}
| |||||||||||||||||||||||||||||
| 43 | 45 | return $self->templates->{$s_template_name}; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 90 | ▶ | sub templates { | ||||||||||||||||||||||||||
|
Subroutine
templates: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 48 | 90 | my ( $self, $hr_templates ) = @_; | |||||||||||||||||||||||||||
| 49 | 90 | ▶ | $self->{templates} = $hr_templates if $hr_templates; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 90 | return $self->{templates}; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 3 | ▶ | sub load_templates { | ||||||||||||||||||||||||||
|
Subroutine
load_templates: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 54 | 3 | my ( $self, $ar_templates ) = @_; | |||||||||||||||||||||||||||
| 55 | 3 | $self->_handle_template($_) foreach @{$ar_templates}; | |||||||||||||||||||||||||||
| 56 | 2 | return $self; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 4 | 1; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||||||||||