blib/lib/MYDan/Deploy/Cache.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 61 CC 7 SCAR 35.1
CC
7
Cov
0%
load
56.0
BEGIN
2.0
BEGIN
2.0
CRAP 33.5
1 package MYDan::Deploy::Cache;
2 use strict;
3 use warnings;
4 use Carp;
5  
6 use YAML::XS;
7  
8 use Data::Dumper;
9  
10 sub load
11 {
12 my ( $class, $cache, $maint ) = splice @_;
13  
14 confess "no code" unless $cache;
15  
16 $cache = eval{ YAML::XS::LoadFile $cache };
17 confess "load cache error: $@" if $@;
18 confess "cache not HASH" if ref $cache ne 'HASH';
19  
20  
21 my ( $node, $step, $glob )
22 = map{ $cache->{$_} || confess "no find $_" }qw( node step glob );
23
24  
25 confess "maint & step & glob no match"
26 unless @$maint == @$step && @$step == @$glob;
27  
28 for my $i ( 0 .. @$step -1 )
29 {
30 my $error = "mould is error no step#$i";
31 my ( $g, $t ) = map{ $maint->[$i]{$_} || 0 }qw( global title );
32  
33 confess "$error: title no match $t ne $step->[$i]" if $t ne $step->[$i];
34  
35 confess "$error: global no match" if $g ne $glob->[$i];
36 }
37  
38 return $cache;
39 }
40  
41 1;