| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Schedule::Easing; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5961
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
42
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
73
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION='0.1.4'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
7
|
use Carp qw/carp confess/; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
82
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
604
|
use Schedule::Easing::Block; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
41
|
|
|
11
|
1
|
|
|
1
|
|
508
|
use Schedule::Easing::MD5; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
43
|
|
|
12
|
1
|
|
|
1
|
|
585
|
use Schedule::Easing::Numeric; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
968
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
|
15
|
18
|
|
|
18
|
0
|
442908
|
my ($ref,%opt)=@_; |
|
16
|
18
|
|
33
|
|
|
121
|
my $class=ref($ref)||$ref; |
|
17
|
|
|
|
|
|
|
my %self=( |
|
18
|
|
|
|
|
|
|
schedule =>$opt{schedule}//[], |
|
19
|
18
|
|
50
|
|
|
131
|
warnExpired=>$opt{warnExpired}//0, |
|
|
|
|
100
|
|
|
|
|
|
20
|
|
|
|
|
|
|
); |
|
21
|
18
|
|
|
|
|
113
|
return bless(\%self,$class)->init(); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my %builder=( |
|
25
|
|
|
|
|
|
|
'block' =>'Schedule::Easing::Block', |
|
26
|
|
|
|
|
|
|
'md5' =>'Schedule::Easing::MD5', |
|
27
|
|
|
|
|
|
|
'numeric'=>'Schedule::Easing::Numeric', |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub init { |
|
31
|
18
|
|
|
18
|
0
|
40
|
my ($self)=@_; |
|
32
|
18
|
100
|
|
|
|
93
|
if(ref($$self{schedule}) ne 'ARRAY') { confess('Schedule must be an array') } |
|
|
1
|
|
|
|
|
483
|
|
|
33
|
17
|
|
|
|
|
33
|
foreach my $ease (@{$$self{schedule}}) { |
|
|
17
|
|
|
|
|
52
|
|
|
34
|
20
|
100
|
|
|
|
61
|
if(ref($ease) ne 'HASH') { confess('Schedule entry must be a hash') } |
|
|
1
|
|
|
|
|
369
|
|
|
35
|
19
|
50
|
|
|
|
87
|
if(my $builder=$builder{$$ease{type}}) { |
|
36
|
19
|
|
|
|
|
146
|
$ease=$builder->new(%$ease,_warnExpired=>$$self{warnExpired}); |
|
37
|
18
|
50
|
|
|
|
80
|
if($$ease{_err}) { $$self{_err}=1 } |
|
|
0
|
|
|
|
|
0
|
|
|
38
|
|
|
|
|
|
|
} |
|
39
|
0
|
|
|
|
|
0
|
else { confess("Unsupported entry type $$ease{type}") } |
|
40
|
|
|
|
|
|
|
} |
|
41
|
15
|
|
|
|
|
125
|
return $self; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub matches { |
|
45
|
16111
|
|
|
16111
|
0
|
339838
|
my ($self,%opt)=@_; |
|
46
|
16111
|
|
66
|
|
|
36336
|
$opt{ts}//=time(); |
|
47
|
16111
|
|
|
|
|
25875
|
my @res; |
|
48
|
16111
|
|
|
|
|
22692
|
foreach my $event (@{$opt{events}}) { |
|
|
16111
|
|
|
|
|
30219
|
|
|
49
|
192023
|
|
|
|
|
273441
|
my $message; |
|
50
|
192023
|
|
|
|
|
288676
|
my $eref=ref($event); |
|
51
|
192023
|
100
|
|
|
|
362627
|
if(!$eref) { $message=$event } |
|
|
192019
|
100
|
|
|
|
300331
|
|
|
|
|
50
|
|
|
|
|
|
|
52
|
2
|
|
|
|
|
5
|
elsif($eref eq 'HASH') { $message=$$event{message} } # UNTESTED |
|
53
|
2
|
|
|
|
|
5
|
elsif($eref eq 'ARRAY') { $message=$$event[0] } # UNTESTED |
|
54
|
0
|
|
|
|
|
0
|
else { carp("Invalid event structure ($eref)"); next } |
|
|
0
|
|
|
|
|
0
|
|
|
55
|
192023
|
|
|
|
|
276146
|
my $includes=1; |
|
56
|
192023
|
|
|
|
|
260413
|
foreach my $ease (@{$$self{schedule}}) { |
|
|
192023
|
|
|
|
|
364815
|
|
|
57
|
192038
|
100
|
|
|
|
455012
|
if(my %data=$ease->matches($message)) { |
|
58
|
192006
|
|
|
|
|
578399
|
$includes=$ease->includes($opt{ts},message=>$message,%data); |
|
59
|
192006
|
|
|
|
|
415219
|
last; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
} |
|
62
|
192023
|
100
|
|
|
|
500051
|
if($includes) { push @res,$event } |
|
|
95977
|
|
|
|
|
224921
|
|
|
63
|
|
|
|
|
|
|
} |
|
64
|
16111
|
|
|
|
|
66675
|
return @res; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub schedule { |
|
68
|
8016
|
|
|
8016
|
0
|
77942
|
my ($self,%opt)=@_; |
|
69
|
8016
|
|
|
|
|
12683
|
my @res; |
|
70
|
8016
|
|
|
|
|
11376
|
foreach my $event (@{$opt{events}}) { |
|
|
8016
|
|
|
|
|
15909
|
|
|
71
|
8016
|
|
|
|
|
11812
|
my $message; |
|
72
|
8016
|
|
|
|
|
13737
|
my $eref=ref($event); |
|
73
|
8016
|
50
|
|
|
|
15724
|
if(!$eref) { $message=$event } |
|
|
8016
|
0
|
|
|
|
12806
|
|
|
|
|
0
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
0
|
elsif($eref eq 'HASH') { $message=$$event{message} } # UNTESTED |
|
75
|
0
|
|
|
|
|
0
|
elsif($eref eq 'ARRAY') { $message=$$event[0] } # UNTESTED |
|
76
|
0
|
|
|
|
|
0
|
else { carp("Invalid event structure ($eref)"); next } |
|
|
0
|
|
|
|
|
0
|
|
|
77
|
8016
|
|
|
|
|
12542
|
my $scheduled=0; |
|
78
|
8016
|
|
|
|
|
11194
|
foreach my $ease (@{$$self{schedule}}) { |
|
|
8016
|
|
|
|
|
15326
|
|
|
79
|
8032
|
100
|
|
|
|
20636
|
if(my %data=$ease->matches($message)) { |
|
80
|
8008
|
|
|
|
|
25709
|
$scheduled=$ease->schedule(message=>$message,%data); |
|
81
|
8008
|
100
|
|
|
|
19113
|
if(defined($scheduled)) { |
|
82
|
8000
|
|
|
|
|
13243
|
my $intsched=int($scheduled); |
|
83
|
8000
|
100
|
|
|
|
17916
|
if($scheduled>$intsched) { $scheduled=1+$intsched } |
|
|
4441
|
|
|
|
|
7264
|
|
|
84
|
|
|
|
|
|
|
} |
|
85
|
8008
|
|
|
|
|
16308
|
last; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
} |
|
88
|
8016
|
|
|
|
|
27579
|
push @res,[$scheduled,$event]; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
8016
|
|
|
|
|
25756
|
return @res; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |