use Storable qw/lock_store lock_retrieve/;
use YAML;
-our $VERSION = '0.04';
+our $VERSION = '0.05';
__PACKAGE__->mk_classdata( '_events' => [] );
__PACKAGE__->mk_accessors('_event_state');
}
my $conf = $class->config->{scheduler};
-
+
my $event = {
trigger => $args{trigger},
event => $args{event},
# replace keywords that Set::Crontab doesn't support
$args{at} = _prepare_cron( $args{at} );
-
+
# parse the cron entry into a DateTime::Set
my $set;
eval { $set = DateTime::Event::Cron->from_cron( $args{at} ) };
$c->_events( [] );
my $yaml = YAML::LoadFile( $c->config->{scheduler}->{yaml_file} );
-
+
foreach my $event ( @{$yaml} ) {
$c->schedule( %{$event} );
}
thu => 4,
fri => 5,
sat => 6,
-
+ );
+
+ my %replace_at = (
'yearly' => '0 0 1 1 *',
'annually' => '0 0 1 1 *',
'monthly' => '0 0 1 * *',
'midnight' => '0 0 * * *',
'hourly' => '0 * * * *',
);
+
+ if ( $cron =~ /^\@/ ) {
+ $cron =~ s/^\@//;
+ return $replace_at{ $cron };
+ }
for my $name ( keys %replace ) {
my $value = $replace{$name};
-
- if ( $cron =~ /^\@$name/ ) {
- $cron = $value;
- last;
- }
- else {
- $cron =~ s/$name/$value/i;
- last unless $cron =~ /\w/;
- }
+ $cron =~ s/$name/$value/i;
+ last unless $cron =~ /\w/;
}
-
return $cron;
}