blib/lib/MYDan/Diagnosis.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 60 CC 7 SCAR 24.8
CC
7
Cov
0%
do
20.0
run
12.0
new
6.0
CRAP 12.0
1 package MYDan::Diagnosis;
2 use warnings;
3 use strict;
4  
5 sub new
6 {
7 my ( $class, %self ) = @_;
8 map{
9 die "$_ defined error" unless $self{$_} && $self{$_} =~ /^[a-zA-Z0-9_:\-]+$/
10 }qw( os arch );
11 bless \%self, ref $class || $class;
12 }
13  
14 sub run
15 {
16 my ( $this, $path, $x ) = splice @_, 0, 2;
17 die "path undef" unless defined $path;
18  
19 map { $x += -f $_ ? $this->do( $_ ) : $this->run( $_ ); }glob "$path/*";
20 return $x;
21 }
22  
23 sub do
24 {
25 my ( $this, $path ) = @_;
26  
27 die "path undef" unless defined $path;
28  
29 my $title = $path; $title =~ s#.*/plugin/code/##;
30 print "=" x 75, "\n$title\n";
31  
32 my $temp = $path;
33 $temp =~ s#/plugin/code/#/plugin/$this->{os}/$this->{arch}/code/#;
34  
35 my $code = do ( -f $temp ? $temp : $path );
36 die "load code: $path fail" unless $code && ref $code eq 'CODE';
37 &$code();
38 }
39  
40 1;