dbMan/Extension/CmdEditObjects.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 79 CC 11 SCAR 33.8
CC
11
Cov
0%
cmdcomplete
56.0
handle_action
30.0
IDENTIFICATION
2.0
CRAP 29.3
1 package DBIx::dbMan::Extension::CmdEditObjects;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5  
6 our $VERSION = '0.05';
7  
8 1;
9  
10 sub IDENTIFICATION { return "000001-000042-000005"; }
11  
12 sub preference { return 1000; }
13  
14 sub known_actions { return [ qw/COMMAND/ ]; }
15  
16 sub init {
17 my $obj = shift;
18 $obj->{-mempool}->set('edit_object_errors',1);
19 }
20  
21 sub handle_action {
22 my ($obj,%action) = @_;
23  
24 if ($action{action} eq 'COMMAND') {
25 if ($action{cmd} =~ /^edit\s+(?:(.*)\s+)?(\S+)$/i) {
26 $action{action} = 'EDIT_OBJECT';
27 $action{type} = $1;
28 $action{what} = $2;
29 } elsif ($action{cmd} =~ /^set\s+edit\s+object\s+errors\s+(on|off)$/i) {
30 my $want = lc $1; my $owant = $want;
31 $want = ($want eq 'off')?0:1;
32 $obj->{-mempool}->set('edit_object_errors',$want);
33 $action{action} = 'OUTPUT';
34 $action{output} = "Edit object errors $owant.\n";
35 }
36 }
37  
38 $action{processed} = 1;
39 return %action;
40 }
41  
42 sub cmdhelp {
43 return [
44 'EDIT <objectname>' => 'Edit object with <objectname>',
45 'SET EDIT OBJECT ERRORS [ON|OFF]' => 'Set edit object errors on or off.'
46 ];
47 }
48  
49 sub cmdcomplete {
50 my ($obj,$text,$line,$start) = @_;
51 return qw/ON OFF/ if $line =~ /^\s*SET\s+EDIT\s+OBJECT\s+ERRORS\s+\S*$/i;
52 return qw/ERRORS/ if $line =~ /^\s*SET\s+EDIT\s+OBJECT\s+\S*$/i;
53 return qw/OBJECT/ if $line =~ /^\s*SET\s+EDIT\s+\S*$/i;
54 return qw/EDIT/ if $line =~ /^\s*SET\s+\S*$/i;
55 return qw/SET/ if $line =~ /^\s*[A-Z]*$/i and not $obj->{-dbi}->current;
56 return qw/SET EDIT/ if $line =~ /^\s*[A-Z]*$/i;
57 return ();
58 }