dbMan/Extension/GuiInputFile.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 67 CC 5 SCAR 24.8
CC
5
Cov
0%
handle_action
30.0
IDENTIFICATION
2.0
preference
2.0
CRAP 12.0
1 package DBIx::dbMan::Extension::GuiInputFile;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5 use Curses::UI;
6 use Cwd;
7  
8 our $VERSION = '0.01';
9  
10 1;
11  
12 sub IDENTIFICATION { return "000001-000094-000001"; }
13  
14 sub preference { return 800; }
15  
16 sub known_actions { return [ qw/GUI/ ]; }
17  
18 sub menu {
19 my $obj = shift;
20  
21 return ( { label => 'Input', submenu => [
22 { label => 'Execute SQL script...',
23 action => { action => 'GUI', operation => 'input_sql_file' } }
24 ] } );
25 }
26  
27 sub load_ok {
28 my $obj = shift;
29  
30 return $obj->{-interface}->gui();
31 }
32  
33 sub handle_action {
34 my ($obj,%action) = @_;
35  
36 if ($action{action} eq 'GUI') {
37 if ($action{operation} eq 'input_sql_file') {
38 if ($obj->{-interface}->can('is_curses')
39 and $obj->{-interface}->is_curses()) {
40 $action{action} = 'NONE';
41  
42 if (my $val = $obj->{-interface}->{ui}->loadfilebrowser(
43 -title => 'Execute SQL script', -path => getcwd(),
44 -mask => [ [ '.', 'All files (*)' ],
45 [ '\.sql$', 'SQL scripts (*.sql)' ] ],
46 -mask_selected => 1 )) {
47 $action{action} = 'INPUT_FILE';
48 $action{file} = $val;
49 }
50 }
51 }
52 }
53  
54 $action{processed} = 1;
55 return %action;
56 }