dbMan/Extension/CmdEval.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 50 CC 5 SCAR 21.6
CC
5
Cov
0%
handle_action
20.0
cmdcomplete
6.0
IDENTIFICATION
2.0
CRAP 8.7
1 package DBIx::dbMan::Extension::CmdEval;
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-000071-000002"; }
11  
12 sub preference { return 1000; }
13  
14 sub known_actions { return [ qw/COMMAND/ ]; }
15  
16 sub handle_action {
17 my ($obj,%action) = @_;
18  
19 if ($action{action} eq 'COMMAND') {
20 if ($action{cmd} =~ s/^eval\s+//i) {
21 $action{action} = 'EVAL';
22 $action{type} = 'perl';
23 $action{what} = $action{cmd};
24 } elsif ($action{cmd} =~ s/^system\s+//i) {
25 $action{action} = 'EVAL';
26 $action{type} = 'system';
27 $action{what} = $action{cmd};
28 }
29 }
30  
31 $action{processed} = 1;
32 return %action;
33 }
34  
35 sub cmdcomplete {
36 my ($obj,$text,$line,$start) = @_;
37 return qw/EVAL SYSTEM/ if $line =~ /^\s*[A-Z]*$/i;
38 }
39  
40 sub cmdhelp {
41 my $obj = shift;
42  
43 return [ 'EVAL <commands>' => 'Evaluate Perl commands',
44 'SYSTEM <command>' => 'Evaluate shell expression' ];
45 }