line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::MLST::Validate::Executable; |
2
|
|
|
|
|
|
|
$Bio::MLST::Validate::Executable::VERSION = '2.1.1630910'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Validates the executable is available in the path before running it. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
19
|
|
|
19
|
|
182892
|
use Moose; |
|
19
|
|
|
|
|
532365
|
|
|
19
|
|
|
|
|
128
|
|
7
|
19
|
|
|
19
|
|
136759
|
use File::Which; |
|
19
|
|
|
|
|
18519
|
|
|
19
|
|
|
|
|
4994
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub does_executable_exist |
10
|
|
|
|
|
|
|
{ |
11
|
36
|
|
|
36
|
1
|
76
|
my($self, $executable) = @_; |
12
|
36
|
100
|
100
|
|
|
1047
|
if (defined $executable and -x $executable) { |
|
|
100
|
|
|
|
|
|
13
|
10
|
|
|
|
|
40
|
return 1; |
14
|
|
|
|
|
|
|
} elsif ( which($executable) ) { |
15
|
2
|
|
|
|
|
262
|
return 1; |
16
|
|
|
|
|
|
|
} else { |
17
|
24
|
|
|
|
|
4573
|
return 0; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub preferred_executable |
22
|
|
|
|
|
|
|
{ |
23
|
17
|
|
|
17
|
0
|
4892
|
my($self, $executable, $defaults) = @_; |
24
|
17
|
100
|
|
|
|
47
|
if ($self->does_executable_exist($executable)) { |
25
|
7
|
|
|
|
|
47
|
return $executable; |
26
|
|
|
|
|
|
|
} |
27
|
10
|
100
|
|
|
|
29
|
if (defined $executable) { |
28
|
5
|
|
|
|
|
99
|
warn "Could not find executable '".$executable."', attempting to use defaults\n"; |
29
|
|
|
|
|
|
|
} |
30
|
10
|
|
|
|
|
46
|
for my $default (@{$defaults}) { |
|
10
|
|
|
|
|
31
|
|
31
|
11
|
100
|
|
|
|
30
|
if ($self->does_executable_exist($default)) { |
32
|
5
|
|
|
|
|
41
|
return $default; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
5
|
|
|
|
|
10
|
die "Could not find any usable default executables in '".join(", ", @{$defaults})."'\n"; |
|
5
|
|
|
|
|
66
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
19
|
|
|
19
|
|
138
|
no Moose; |
|
19
|
|
|
|
|
42
|
|
|
19
|
|
|
|
|
155
|
|
39
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=pod |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=encoding UTF-8 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Bio::MLST::Validate::Executable - Validates the executable is available in the path before running it. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 VERSION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
version 2.1.1630910 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SYNOPSIS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Validates the executable is available in the path before running it. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
use Bio::MLST::Validate::Executable; |
61
|
|
|
|
|
|
|
Bio::MLST::Validate::Executable |
62
|
|
|
|
|
|
|
->new() |
63
|
|
|
|
|
|
|
->does_executable_exist('abc'); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 METHODS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 does_executable_exist |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Check to see if an executable is available in the current users PATH. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 AUTHOR |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Andrew J. Page <ap13@sanger.ac.uk> |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This software is Copyright (c) 2012 by Wellcome Trust Sanger Institute. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This is free software, licensed under: |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |