File Coverage

lib/Rex/Cron.pm
Criterion Covered Total %
statement 11 24 45.8
branch 0 6 0.0
condition 0 3 0.0
subroutine 4 6 66.6
pod 0 1 0.0
total 15 40 37.5


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Cron;
6              
7 32     32   415 use v5.12.5;
  32         130  
8 32     32   162 use warnings;
  32         48  
  32         1700  
9              
10             our $VERSION = '1.14.2.3'; # TRIAL VERSION
11              
12 32     32   378 use Rex::Commands::Gather;
  32         88  
  32         253  
13 32     32   633 use List::Util qw'first';
  32         98  
  32         9656  
14              
15             sub create {
16 0     0 0   my ($class) = @_;
17              
18 0           my $type = "Linux";
19 0 0         if ( operating_system_is("SunOS") ) {
20 0           $type = "SunOS";
21             }
22              
23 0           my $exec = Rex::Interface::Exec->create;
24              
25             # here we're using first and not any, because in older perl versions
26             # there is no any() function in List::Util.
27 0 0 0       if ( operating_system_is( "FreeBSD", "OpenBSD", "NetBSD" )
28 0     0     && first { $exec->shell->name eq $_ } (qw/csh ksh tcsh/) )
29             {
30 0           $type = "FreeBSD";
31             }
32              
33 0           my $klass = "Rex::Cron::$type";
34 0           eval "use $klass;";
35 0 0         if ($@) {
36 0           die("Error creating cron class: $klass\n$@");
37             }
38              
39 0           return $klass->new;
40             }
41              
42             1;