dbMan/Extension/InputFile.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 43 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::InputFile;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5  
6 our $VERSION = '0.04';
7  
8 1;
9  
10 sub IDENTIFICATION { return "000001-000024-000004"; }
11  
12 sub preference { return 0; }
13  
14 sub known_actions { return [ qw/INPUT_FILE/ ]; }
15  
16 sub handle_action {
17 my ($obj,%action) = @_;
18  
19 if ($action{action} eq 'INPUT_FILE') {
20 $action{action} = 'NONE';
21 unless (open F,$action{file}) {
22 $obj->{-interface}->error("Can't load input file $action{file}.");
23 return %action;
24 }
25 if ( $obj->{ -interface }->is_utf8 ) {
26 binmode F, ':utf8';
27 }
28 while (<F>) {
29 chomp;
30 my $newaction = { action => 'COMMAND', cmd => $_ };
31 $obj->{-interface}->add_to_actionlist($newaction);
32 }
33 close F;
34 }
35  
36 $action{processed} = 1;
37 return %action;
38 }