ETLp/Plugin/Iterative/OS.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 52 CC 1 SCAR 6.9
CC
1
Cov
0%
type
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package ETLp::Plugin::Iterative::OS;
2  
3 use MooseX::Declare;
4  
5 =head1 NAME
6  
7 ETLp::Plugin::Iterative::OS - Plugin for calling the Operating System
8  
9 =cut
10  
11 class ETLp::Plugin::Iterative::OS extends ETLp::Plugin {
12 use File::Basename;
13 use ETLp::Utility::Command;
14 use Data::Dumper;
15  
16 =head1 METHODS
17  
18 =head2 type
19  
20 Registers the plugin type.
21  
22 =cut
23  
24 sub type {
25 return 'os';
26 }
27  
28 =head2 run
29  
30 Executes the supplied Command.
31  
32 =head3 parameters
33  
34 * filename - the name of the file currently being processed
35
36 =head3 returns
37  
38 * new filename - the name for the file following
39
40 =head1 ITEM
41  
42 The item attribute hashref contains specific configuration information
43 for ETLp::Plugin::Iterative::OS:
44  
45 =head2 command
46  
47 The operating system command being run
48  
49 =head2 timeout
50  
51 This is an optional parameter that specifies when the command execution
52 should abort (in seconds).
53  
54 =cut
55  
56 method run(Str $filename) {
57 my $item = $self->item;
58 my $command = $item->{command};
59 my $timeout = $item->{timeout} || 20;
60
61 $self->logger->debug(Dumper($self->config));
62  
63 my $message;
64  
65 $self->logger->debug("Raw command:\n$command");
66 $self->logger->debug("Timeout:\n$timeout");
67  
68 my $aud_file_process = $self->audit->item->file_process;
69  
70 if ($item->{hide_command}) {
71 $message = $item->{command};
72 } else {
73 $message = $command;
74 }
75  
76 $aud_file_process->update_message($message);
77  
78 my $cmd = ETLp::Utility::Command->new(time_out => $timeout);
79  
80 my ($output, $retcode) = $cmd->run($command);
81  
82 if ($retcode || $cmd->errstr) {
83 ETLpException->throw(error => "Error running:\n$message:\n" .
84 $cmd->errstr ."\n" . $retcode);
85 }
86  
87 $self->audit->item->update_message($message . "\n" . $output);
88 $aud_file_process->update_status('succeeded');
89 return $filename;
90 };
91 }
92  
93 =head1 LICENSE AND COPYRIGHT
94  
95 Copyright 2010 Redbone Systems Ltd
96  
97 This program is free software; you can redistribute it and/or modify it
98 under the terms of either: the GNU General Public License as published
99 by the Free Software Foundation; or the Artistic License.
100  
101 The terms are in the LICENSE file that accompanies this application