Omni/Session/Messages.pm

filter: Statementstmt 22.6% 12 / 53 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 30.0% 3 / 10 Podpod 100% 6 / 6 totaltotal 28.0% 21 / 75 CC 4 SCAR 12.9
CC
4
Cov
20%
next
6.0
prev
6.0
init
6.0
CRAP 3.6
« Omni/Utils.pm ↑ Summary Omni/Base.pm »
1 package Backup::Omni::Session::Messages;
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 constants => 'OMNIDB',
11 mutators => 'cur_pos',
12 constant => {
13 COMMAND => '%s -session %s -report %s',
14 },
15 vars => {
16 PARAMS => {
17 -session => 1,
18 -report => { optional => 1, default => ' ', regex => qr/warning|minor|major|critical|\w/ },
19 }
20 }
21 1 ;
22  
23 Params::Validate::validation_options(
24 0 ▶ on_fail => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
25 0 my $params = shift;
26 0 my $class = __PACKAGE__;
27 0 Backup::Omni::Base::validation_exception($params, $class);
28 }
29 1 );
30  
31 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 # ----------------------------------------------------------------------
34 # Public Methods
35 # ----------------------------------------------------------------------
36  
37 0 ▶sub all {
Subroutine all: not called CC=1 SCAR=6.9
Pod documented
38 0 my $self = shift;
39  
40 0 return $self->{results};
41  
42 }
43  
44 0 ▶sub next {
Subroutine next: not called CC=2 SCAR=17.9
Pod documented
45 0 my $self = shift;
46  
47 0 my $pos = $self->cur_pos;
48 0 my $end = scalar(@{$self->{results}}) - 1;
49  
50 0 $pos++;
51  
52 0 ▶ if ($pos <= $end) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos <= $end) { } 0 0 0
53  
54 0 $self->cur_pos($pos);
55 0 return $self->{results}->[$pos];
56  
57 } else {
58  
59 0 $self->cur_pos($pos);
60 0 return undef;
61  
62 }
63  
64 }
65  
66 0 ▶sub prev {
Subroutine prev: not called CC=2 SCAR=17.9
Pod documented
67 0 my $self = shift;
68  
69 0 my $pos = $self->cur_pos;
70  
71 0 $pos--;
72  
73 0 ▶ if ($pos < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos < 0) { } 0 0 0
74  
75 0 $self->cur_pos(0);
76 0 return undef;
77  
78 } else {
79  
80 0 $self->cur_pos($pos);
81 0 return $self->{results}->[$pos];
82  
83 }
84  
85 }
86  
87 0 ▶sub first {
Subroutine first: not called CC=1 SCAR=6.9
Pod documented
88 0 my $self = shift;
89  
90 0 $self->cur_pos(0);
91  
92 0 return $self->{results}->[0];
93  
94 }
95  
96 0 ▶sub last {
Subroutine last: not called CC=1 SCAR=6.9
Pod documented
97 0 my $self = shift;
98  
99 0 my $end = scalar(@{$self->{results}}) - 1;
100  
101 0 $self->cur_pos($end);
102
103 0 return $self->{results}->[$end];
104  
105 }
106  
107 # ----------------------------------------------------------------------
108 # Private Methods
109 # ----------------------------------------------------------------------
110  
111 0 ▶sub init {
Subroutine init: not called CC=2 SCAR=17.9
Pod documented
112 0 my $class = shift;
113  
114 0 my $self = $class->SUPER::init(@_);
115  
116 0 my $command = sprintf(COMMAND, OMNIDB, $self->session, $self->report);
117 0 my @result = `$command`;
118 0 my $rc = $?;
119  
120 0 ▶ unless (grep(/Normal/, @result)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep /Normal/, @result) 0 0 0
121  
122 0 $self->throw_msg(
123 'backup.omni.session.messages',
124 'noresults',
125 $self->session
126 );
127  
128 }
129  
130 0 $self->{cur_pos} = 0;
131 0 $self->{results} = \@result;
132
133 0 return $self;
134  
135 }
136  
137 1 1;
138  
139 __END__
« Omni/Utils.pm ↑ Summary Omni/Base.pm »