File Coverage

blib/lib/App/MaMGal/CommandChecker.pm
Criterion Covered Total %
statement 18 18 100.0
branch 5 6 83.3
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 29 32 90.6


line stmt bran cond sub pod time code
1             # mamgal - a program for creating static image galleries
2             # Copyright 2009-2008 Marcin Owsiany
3             # See the README file for license information
4             # A class for checking existance of commands, basically a wrapper for
5             # "which(1)"
6             package App::MaMGal::CommandChecker;
7 1     1   2526 use strict;
  1         1  
  1         34  
8 1     1   5 use warnings;
  1         2  
  1         32  
9 1     1   4 use base 'App::MaMGal::Base';
  1         1  
  1         534  
10 1     1   5 use Carp;
  1         1  
  1         131  
11              
12             sub init
13             {
14 4     4 0 7 my $self = shift;
15 4 50       17 croak "No arguments allowed" if @_;
16             }
17              
18             sub is_available
19             {
20 5     5 0 8218 my $self = shift;
21 5 100       52 my $command = shift or croak 'One argument required';
22 4 100       23 croak 'Just one argument allowed' if @_;
23 3         28288 system("which $command >/dev/null 2>&1") == 0;
24             }
25              
26             1;