Omni/Session/Filesystem.pm

filter: Statementstmt 25.0% 9 / 36 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 2 / 4 Podpod 100% 1 / 1 totaltotal 25.5% 12 / 47 CC 5 SCAR 29.6
CC
5
Cov
21%
init
30.0
__ANON__
2.0
BEGIN
1.0
CRAP 19.2
« Omni/Session/Monitor.pm ↑ Summary Omni/Session/Results.pm »
1 package Backup::Omni::Session::Filesystem;
2  
3 1 our $VERSION = '0.01';
4  
5 1 ▶use Params::Validate ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 use Backup::Omni::Class
8 1 ▶ version => $VERSION,
Subroutine BEGIN: called CC=1 SCAR=0.0
9 base => 'Backup::Omni::Base',
10 utils => 'db2dt omni2dt trim',
11 constants => 'OMNIDB',
12 constant => {
13 COMMAND => '%s -filesystem %s:%s "%s" -detail -since %s -until %s 2>&1',
14 },
15 vars => {
16 PARAMS => {
17 -host => 1,
18 -date => { regex => qr/\d{4}-\d\d-\d\d/ },
19 -path => { optional => 1, default => '/archive' },
20 -label => { optional => 1, default => '/archive' },
21 }
22 }
23 1 ;
24  
25 Params::Validate::validation_options(
26 0 ▶ on_fail => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
27 0 my $params = shift;
28 0 my $class = __PACKAGE__;
29 0 Backup::Omni::Base::validation_exception($params, $class);
30 }
31 1 );
32  
33 # ----------------------------------------------------------------------
34 # Public Methods
35 # ----------------------------------------------------------------------
36  
37 # ----------------------------------------------------------------------
38 # Private Methods
39 # ----------------------------------------------------------------------
40  
41 0 ▶sub init {
Subroutine init: not called CC=5 SCAR=34.0
Pod documented
42 0 my $class = shift;
43  
44 0 my $self = $class->SUPER::init(@_);
45  
46 0 my $date = $self->date . ' 00:00:00';
47 0 my $since = db2dt($date);
48 0 my $until = $since->clone->add(days => 1);
49  
50 0 my $command = sprintf(COMMAND, OMNIDB, $self->host, $self->path, $self->label, $since->ymd('-'), $until->ymd('-'));
51 0 my @result = `$command`;
52 0 my $rc = $?;
53  
54 0 ▶ unless (grep(/SessionID/, @result)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep /SessionID/, @result) 0 0 0
55  
56 0 $self->throw_msg(
57 'backup.omni.session.filesystem',
58 'nosession',
59 $self->host, $self->date
60 );
61  
62 }
63  
64 0 foreach my $line (@result) {
65  
66 0 chomp($line);
67 0 ▶ next if ($line eq '');
Branch: 1 branch
BranchTrueFalseTotal
if $line eq "" 0 0 0
68  
69 0 $line =~ m/^(.*): (.*)/;
70  
71 0 my $key = $1;
72 0 my $value = $2;
73  
74 0 $key = trim($key);
75 0 $key =~ s/ /_/g;
76 0 $key = lc($key);
77  
78 0 $value = trim($value);
79 0 ▶ $value = omni2dt($value) if ($value =~ /\w\w\w \d\d \w\w\w \d\d\d\d/);
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /\w\w\w \d\d \w\w\w \d\d\d\d/ 0 0 0
80
81 # order is important here. Don't change
82  
83 0 $self->class->accessors($key); # may cause redefination errors
84 0 $self->{$key} = $value;
85  
86 }
87  
88 0 return $self;
89  
90 }
91  
92 1 1;
93  
94 __END__
« Omni/Session/Monitor.pm ↑ Summary Omni/Session/Results.pm »