dbMan/Extension/ShowTablesOracle.pm untested

filter: Statementstmt 0.0% 0 / 49 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 22 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 115 CC 11 SCAR 44.0
CC
11
Cov
0%
handle_action
132.0
IDENTIFICATION
2.0
preference
2.0
CRAP 81.4
1 package DBIx::dbMan::Extension::ShowTablesOracle;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5 use Text::FormatTable;
6 use Term::ANSIColor;
7  
8 our $VERSION = '0.08';
9  
10 1;
11  
12 sub IDENTIFICATION { return "000001-000039-000008"; }
13  
14 sub preference { return 50; }
15  
16 sub known_actions { return [ qw/SHOW_TABLES/ ]; }
17  
18 sub handle_action {
19 my ($obj,%action) = @_;
20  
21 if ($action{action} eq 'SHOW_TABLES' and $obj->{-dbi}->driver eq 'Oracle') {
22 my $colorized = $obj->{-mempool}->get('output_format') eq 'colortable';
23 my $table = new Text::FormatTable '| l | l |';
24 $table->rule;
25 $table->head( map { $colorized ? color( $obj->{-config}->tablecolor_head || 'bright_yellow' ) . $_ . color( $obj->{-config}->tablecolor_lines || 'reset' ) : $_; } 'NAME','TYPE');
26 $table->rule;
27  
28 my $sth = $obj->{-dbi}->table_info( { TABLE_SCHEM => uc($obj->{-dbi}->login) } );
29 if (defined $sth) {
30 my $ret = $sth->fetchall_arrayref();
31 study $action{mask};
32 eval {
33 if (defined $ret) {
34 for (sort { $a->[2] cmp $b->[2] } @$ret) {
35 if (($action{type} eq 'object'
36 or $action{type} eq lc $_->[3]) and
37 $action{mask} and $_->[2] =~ /$action{mask}/i) {
38 $table->row(map { $colorized ? color( $obj->{-config}->tablecolor_content || 'bright_white' ) . $_ . color( $obj->{-config}->tablecolor_lines || 'reset' ) : $_; } $_->[2],$_->[3]);
39 }
40 }
41 }
42 };
43 $sth->finish;
44 $table->rule;
45 if ( $@ ) {
46 $obj->{ -interface }->error( "Invalid regular expression." );
47 }
48 $action{output} = $@ ? '' : ( $colorized ? color( $obj->{-config}->tablecolor_lines || 'reset' ) : '' ) . $table->render($obj->{-interface}->render_size) . ( $colorized ? color( 'reset' ) : '' );
49 } else {
50 $action{output} = '';
51 $obj->{ -interface }->error( "Interrupted." );
52 }
53 $action{action} = 'OUTPUT';
54 }
55  
56 $action{processed} = 1;
57 return %action;
58 }