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   2101 use strict;
  1         1  
  1         24  
8 1     1   4 use warnings;
  1         2  
  1         30  
9 1     1   4 use base 'App::MaMGal::Base';
  1         2  
  1         473  
10 1     1   5 use Carp;
  1         1  
  1         123  
11              
12             sub init
13             {
14 4     4 0 9 my $self = shift;
15 4 50       19 croak "No arguments allowed" if @_;
16             }
17              
18             sub is_available
19             {
20 5     5 0 4033 my $self = shift;
21 5 100       41 my $command = shift or croak 'One argument required';
22 4 100       22 croak 'Just one argument allowed' if @_;
23 3         28581 system("which $command >/dev/null 2>&1") == 0;
24             }
25              
26             1;