File Coverage

lib/Bio/Roary/JobRunner/Role.pm
Criterion Covered Total %
statement 28 29 96.5
branch 4 6 66.6
condition n/a
subroutine 6 6 100.0
pod n/a
total 38 41 92.6


line stmt bran cond sub pod time code
1             package Bio::Roary::JobRunner::Role;
2             $Bio::Roary::JobRunner::Role::VERSION = '3.10.2';
3             # ABSTRACT: A role to add job runner functionality
4              
5              
6 17     17   11505 use Moose::Role;
  17         65750  
  17         77  
7 17     17   94335 use Log::Log4perl qw(:easy);
  17         561254  
  17         241  
8 17     17   13159 use File::Spec;
  17         40  
  17         5220  
9              
10             has 'job_runner' => ( is => 'rw', isa => 'Str', default => 'Local' );
11             has '_job_runner_class' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build__job_runner_class' );
12             has 'memory_in_mb' => ( is => 'rw', isa => 'Int', default => '200' );
13             has '_queue' => ( is => 'rw', isa => 'Str', default => 'normal' );
14             has 'dont_wait' => ( is => 'rw', isa => 'Bool', default => 0 );
15             has 'cpus' => ( is => 'ro', isa => 'Int', default => 1 );
16             has 'logger' => ( is => 'ro', lazy => 1, builder => '_build_logger');
17             has 'verbose' => ( is => 'rw', isa => 'Bool', default => 0 );
18              
19             sub _build_logger
20             {
21 14     14   54 my ($self) = @_;
22 14         33 my $level = $ERROR;
23 14 50       358 if($self->verbose)
24             {
25 0         0 $level = $DEBUG;
26             }
27 14         151 Log::Log4perl->easy_init($level);
28 14         45234 my $logger = get_logger();
29 14         1240 return $logger;
30             }
31              
32             sub _build__job_runner_class {
33 37     37   95 my ($self) = @_;
34 37         952 my $job_runner_class = "Bio::Roary::JobRunner::" . $self->job_runner;
35 37         2751 eval "require $job_runner_class";
36 37         1080 return $job_runner_class;
37             }
38              
39             sub _find_exe {
40 6     6   12 my($self,$executables) = @_;
41            
42             # If there is an explicit full path passed in, just return.
43 6 100       22 if($executables->[0] =~ m!/!)
44             {
45 4         10 return $executables->[0];
46             }
47            
48 2         30 for my $dir (File::Spec->path) {
49 18         23 for my $exec (@{$executables})
  18         20  
50             {
51 36         166 my $exe = File::Spec->catfile($dir, $exec);
52 36 50       199 return $exe if -x $exe;
53             }
54             }
55 2         7 return $executables->[0];
56             }
57              
58              
59             1;
60              
61             __END__
62              
63             =pod
64              
65             =encoding UTF-8
66              
67             =head1 NAME
68              
69             Bio::Roary::JobRunner::Role - A role to add job runner functionality
70              
71             =head1 VERSION
72              
73             version 3.10.2
74              
75             =head1 SYNOPSIS
76              
77             A role to add job runner functionality
78             with 'Bio::Roary::JobRunner::Role';
79              
80             =head1 AUTHOR
81              
82             Andrew J. Page <ap13@sanger.ac.uk>
83              
84             =head1 COPYRIGHT AND LICENSE
85              
86             This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
87              
88             This is free software, licensed under:
89              
90             The GNU General Public License, Version 3, June 2007
91              
92             =cut