File Coverage

lib/Rex/Cron/FreeBSD.pm
Criterion Covered Total %
statement 17 30 56.6
branch 0 4 0.0
condition 0 3 0.0
subroutine 6 8 75.0
pod 0 2 0.0
total 23 47 48.9


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Cron::FreeBSD;
6              
7 1     1   14 use v5.12.5;
  1         5  
8 1     1   10 use warnings;
  1         8  
  1         40  
9              
10             our $VERSION = '1.14.3'; # VERSION
11              
12 1     1   15 use Rex::Cron::Base;
  1         2  
  1         11  
13 1     1   39 use base qw(Rex::Cron::Base);
  1         2  
  1         94  
14              
15 1     1   8 use Rex::Helper::Run;
  1         2  
  1         72  
16 1     1   6 use Rex::Helper::Path;
  1         3  
  1         285  
17              
18             sub new {
19 0     0 0   my $that = shift;
20 0   0       my $proto = ref($that) || $that;
21 0           my $self = $proto->SUPER::new(@_);
22              
23 0           bless( $self, $proto );
24              
25 0           return $self;
26             }
27              
28             sub read_user_cron {
29 0     0 0   my ( $self, $user ) = @_;
30 0 0         $user = undef if $user eq $self->_whoami;
31              
32 0           my $tmp_file = get_tmp_file;
33              
34 0           my $command = '( crontab -l';
35 0 0         $command .= " -u $user" if defined $user;
36 0           $command .= " >$tmp_file ) >& /dev/null ; cat $tmp_file ; rm $tmp_file";
37              
38 0           my @lines = i_run $command;
39 0           $self->parse_cron(@lines);
40             }
41              
42             1;