Plagger/Rule/DateTimeCron.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 34 CC 2 SCAR 11.5
CC
2
Cov
0%
init
6.0
dispatch
2.0
BEGIN
2.0
CRAP 3.1
1 package Plagger::Rule::DateTimeCron;
2 use strict;
3 use base qw( Plagger::Rule );
4  
5 use Plagger::Date;
6 use DateTime::Event::Cron;
7  
8 sub init {
9 my $self = shift;
10 my $now = Plagger::Date->now;
11 $now->set_second(0);
12 $self->{cron_valid} = 1;
13 eval {
14 Plagger->context->log(debug => "crontab $self->{crontab} set");
15 my $cron = DateTime::Event::Cron->new_from_cron( cron => $self->{crontab} );
16 $self->{cron_valid} = $cron->valid($now);
17 };
18 Plagger->context->error("Can't parse crontab : $@") if $@;
19 }
20  
21 sub dispatch {
22 my($self, $args) = @_;
23 $self->{cron_valid};
24 }
25  
26 1;
27 __END__