| 1 | ###################################################################### | ||||||||||||||||||||||||||||
| 2 | # $Id: YAMLBackend.pm,v 1.3 2005/10/27 19:00:20 nachbaur Exp $ | ||||||||||||||||||||||||||||
| 3 | # Copyright (C) 2005 Michael Nachbaur All Rights Reserved | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # Software distributed under the License is distributed on an "AS | ||||||||||||||||||||||||||||
| 6 | # IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or | ||||||||||||||||||||||||||||
| 7 | # implied. See the License for the specific language governing | ||||||||||||||||||||||||||||
| 8 | # rights and limitations under the License. | ||||||||||||||||||||||||||||
| 9 | ###################################################################### | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | package Cache::YAMLBackend; | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use vars qw( @ISA ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Cache::CacheUtils qw( Assert_Defined Build_Path ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use YAML; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | @ISA = qw( Cache::FileBackend ); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub _read_data { | ||||||||||||||||||||||||||
|
Subroutine
_read_data: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 21 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 22 | 0 | my ($p_path) = @_; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | Assert_Defined($p_path); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | my $frozen_data_ref = Cache::FileBackend::_Read_File_Without_Time_Modification($p_path) or | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | return [ undef, undef ]; | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | my $data_ref = eval { | |||||||||||||||||||||||||||
| 30 | 0 | $self->_yaml->load($$frozen_data_ref); | |||||||||||||||||||||||||||
| 31 | }; | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | if ($@ || (ref($data_ref) ne 'ARRAY')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$@ or ref $data_ref ne "ARRAY"
MC/DC0%0/2
$@ or ref $data_ref ne "ARRAY"
$@
ref $data_ref ne "ARRAY"
Truth table0%0/3
A or B
A= $@B= ref $data_ref ne "ARRAY"
| |||||||||||||||||||||||||||||
| 34 | 0 | unlink Cache::FileBackend::_Untaint_Path($p_path); | |||||||||||||||||||||||||||
| 35 | 0 | return [undef, undef]; | |||||||||||||||||||||||||||
| 36 | } else { | ||||||||||||||||||||||||||||
| 37 | 0 | return $data_ref; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub store { | ||||||||||||||||||||||||||
|
Subroutine
store: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 42 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 43 | 0 | return $self->SUPER::store(@_); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub _write_data { | ||||||||||||||||||||||||||
|
Subroutine
_write_data: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 47 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 48 | 0 | my ($self, $p_path, $p_data) = @_; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | Assert_Defined($p_path); | |||||||||||||||||||||||||||
| 51 | 0 | Assert_Defined($p_data); | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | Cache::FileBackend::_Make_Path($p_path, $self->get_directory_umask()); | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | my $frozen_file = $self->_yaml->dump($p_data); | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | Cache::FileBackend::_Write_File($p_path, \$frozen_file); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub _yaml { | ||||||||||||||||||||||||||
|
Subroutine
_yaml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 61 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 62 | 0 | my $y = YAML->new; | |||||||||||||||||||||||||||
| 63 | 0 | return $y; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 1 | 1; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | __END__ | ||||||||||||||||||||||||||||