dbMan/Extension/Eval.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 44 CC 4 SCAR 23.0
CC
4
Cov
0%
handle_action
20.0
IDENTIFICATION
2.0
preference
2.0
CRAP 10.0
1 package DBIx::dbMan::Extension::Eval;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5  
6 our $VERSION = '0.02';
7  
8 1;
9  
10 sub IDENTIFICATION { return "000001-000072-000002"; }
11  
12 sub preference { return 0; }
13  
14 sub known_actions { return [ qw/EVAL/ ]; }
15  
16 sub handle_action {
17 my ($obj,%action) = @_;
18  
19 if ($action{action} eq 'EVAL') {
20 if ($action{type} eq 'perl') {
21 my $code = $action{what};
22 eval $code;
23 $action{action} = 'OUTPUT';
24 $action{output} = $@ || '';
25 } elsif ($action{type} eq 'system') {
26 my $code = $action{what};
27 $action{action} = 'OUTPUT';
28 $action{output} = `$code`;
29 } else {
30 return %action;
31 }
32 }
33  
34 $action{processed} = 1;
35 return %action;
36 }