Omni/Base.pm

filter: Statementstmt 40.9% 18 / 44 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 55.5% 5 / 9 Podpod 100% 3 / 3 totaltotal 43.3% 26 / 60 CC 3 SCAR 9.2
CC
3
Cov
38%
validation_exception
6.0
init
3.3
config
2.0
CRAP 2.5
« Omni/Session/Messages.pm ↑ Summary Omni/Constants.pm »
1 package Backup::Omni::Base;
2  
3 1 our $VERSION = '0.01';
4 1 our $EXCEPTION = 'Backup::Omni::Exception';
5  
6 1 ▶use Backup::Omni::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Params::Validate ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 use Backup::Omni::Class
10 1 ▶ base => 'Backup::Omni Badger::Base',
Subroutine BEGIN: called CC=1 SCAR=0.0
11 version => $VERSION,
12 messages => {
13 noresults => 'unable to find any results for %s',
14 nosession => 'no session data found for %s on %s',
15 baddate => 'unable to perform date parsing, reason: %s',
16 badtemp => 'bad temporary session id',
17 badparams => 'invalid parameters passed from %s at line %s',
18 invparams => 'invalid paramters passed, reason: %s',
19 nosubmit => 'unable to submit a restore for %s',
20 },
21 vars => {
22 PARAMS => {}
23 }
24 1 ;
25  
26 # ----------------------------------------------------------------------
27 # Public Methods
28 # ----------------------------------------------------------------------
29  
30 0 ▶sub config {
Subroutine config: not called CC=1 SCAR=6.9
Pod documented
31 0 my ($class, $p) = @_;
32  
33 0 return $class->{config}->{$p};
34  
35 }
36  
37 0 ▶sub validation_exception {
Subroutine validation_exception: not called CC=2 SCAR=17.9
Pod documented
38 0 my $param = shift;
39 0 my $class = shift;
40  
41 0 my $x = index($param, $class);
42 0 my $y = index($param, ' ', $x);
43 0 my $method;
44  
45 0 ▶ if ($y > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($y > 0) { } 0 0 0
46  
47 0 my $l = $y - $x;
48 0 $method = substr($param, $x, $l);
49  
50 } else {
51  
52 0 $method = substr($param, $x);
53  
54 }
55  
56 0 chomp($method);
57 0 $method =~ s/::/./g;
58 0 $method = lc($method) . '.invparams';
59  
60 0 $class->throw_msg($method, 'invparams', $param);
61  
62 }
63  
64 # ----------------------------------------------------------------------
65 # Private Methods
66 # ----------------------------------------------------------------------
67  
68 0 ▶sub init {
Subroutine init: not called CC=2 SCAR=11.9
Pod documented
69 0 my $self = shift;
70  
71 0 my $params = $self->class->hash_vars('PARAMS');
72 0 my %p = validate(@_, $params);
73
74 0 $self->{config} = \%p;
75
76 1 ▶ no strict "refs"; # to register new methods in package
Subroutine BEGIN: called CC=1 SCAR=0.0
77 1 ▶ no warnings; # turn off warnings
Subroutine BEGIN: called CC=1 SCAR=0.0
78  
79 0 ▶ while (my ($key, $value) = each(%p)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %p) 0 0 0
80  
81 0 $key =~ s/^-//;
82 0 $self->{$key} = $value;
83  
84 0 ▶ *$key = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
85 0 my $self = shift;
86 0 return $self->{$key};
87 0 };
88  
89 }
90  
91 0 return $self;
92  
93 }
94  
95 1 1;
96  
97 __END__
« Omni/Session/Messages.pm ↑ Summary Omni/Constants.pm »