File Coverage

lib/Bio/Roary/JobRunner/Local.pm
Criterion Covered Total %
statement 21 27 77.7
branch 1 2 50.0
condition n/a
subroutine 5 7 71.4
pod 0 2 0.0
total 27 38 71.0


line stmt bran cond sub pod time code
1             package Bio::Roary::JobRunner::Local;
2             $Bio::Roary::JobRunner::Local::VERSION = '3.10.2';
3             # ABSTRACT: Execute a set of commands locally
4              
5              
6 13     13   75 use Moose;
  13         24  
  13         104  
7 13     13   87312 use Log::Log4perl qw(:easy);
  13         28  
  13         112  
8              
9             has 'commands_to_run' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
10             has 'logger' => ( is => 'ro', lazy => 1, builder => '_build_logger');
11             has 'verbose' => ( is => 'rw', isa => 'Bool', default => 0 );
12             has 'memory_in_mb' => ( is => 'rw', isa => 'Int', default => '200' );
13              
14             sub run {
15 37     37 0 91 my ($self) = @_;
16              
17 37         79 for my $command_to_run ( @{ $self->commands_to_run } ) {
  37         974  
18 34         2429 $self->logger->info($command_to_run);
19 34         11341632 system($command_to_run );
20             }
21 37         767 1;
22             }
23              
24              
25             sub _construct_dependancy_params
26             {
27 0     0   0 my ($self) = @_;
28 0         0 return '';
29             }
30              
31             sub submit_dependancy_job {
32 0     0 0 0 my ( $self,$command_to_run) = @_;
33 0         0 $self->logger->info($command_to_run);
34 0         0 system($command_to_run );
35             }
36              
37             sub _build_logger
38             {
39 21     21   51 my ($self) = @_;
40 21         46 my $level = $ERROR;
41 21 50       523 if($self->verbose)
42             {
43 0         0 $level = $DEBUG;
44             }
45 21         197 Log::Log4perl->easy_init($level);
46 21         79153 my $logger = get_logger();
47 21         1871 return $logger;
48             }
49              
50 13     13   13113 no Moose;
  13         28  
  13         72  
51             __PACKAGE__->meta->make_immutable;
52              
53             1;
54              
55             __END__
56              
57             =pod
58              
59             =encoding UTF-8
60              
61             =head1 NAME
62              
63             Bio::Roary::JobRunner::Local - Execute a set of commands locally
64              
65             =head1 VERSION
66              
67             version 3.10.2
68              
69             =head1 SYNOPSIS
70              
71             Execute a set of commands locally
72             use Bio::Roary::JobRunner::Local;
73            
74             my $obj = Bio::Roary::JobRunner::Local->new(
75             commands_to_run => ['ls', 'echo "abc"'],
76             );
77             $obj->run();
78              
79             =head1 AUTHOR
80              
81             Andrew J. Page <ap13@sanger.ac.uk>
82              
83             =head1 COPYRIGHT AND LICENSE
84              
85             This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
86              
87             This is free software, licensed under:
88              
89             The GNU General Public License, Version 3, June 2007
90              
91             =cut