| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Schedule::Activity::Message; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
6867
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
136
|
|
|
4
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
128
|
|
|
5
|
2
|
|
|
2
|
|
714
|
use Ref::Util qw/is_arrayref is_hashref is_ref/; |
|
|
2
|
|
|
|
|
3261
|
|
|
|
2
|
|
|
|
|
3120
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION='0.3.0'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my %property=map {$_=>undef} qw/message attributes names note/; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
|
12
|
200627
|
|
|
200627
|
0
|
1058387
|
my ($ref,%opt)=@_; |
|
13
|
200627
|
|
33
|
|
|
645588
|
my $class=is_ref($ref)||$ref; |
|
14
|
|
|
|
|
|
|
my %self=( |
|
15
|
|
|
|
|
|
|
attributes=>$opt{attributes}//{}, |
|
16
|
|
|
|
|
|
|
msg =>[], |
|
17
|
|
|
|
|
|
|
names =>$opt{names}//{}, |
|
18
|
200627
|
|
100
|
|
|
1161257
|
); |
|
|
|
|
100
|
|
|
|
|
|
19
|
200627
|
100
|
|
|
|
803306
|
if(is_hashref($opt{message})) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
20
|
14218
|
100
|
33
|
|
|
32069
|
if(is_arrayref($opt{message}{alternates})) { |
|
|
|
50
|
|
|
|
|
|
|
21
|
14216
|
|
|
|
|
35906
|
@{$self{msg}}=grep |
|
22
|
|
|
|
|
|
|
{is_hashref($_) && ( |
|
23
|
|
|
|
|
|
|
(!is_ref($$_{message}) && defined($$_{message})) |
|
24
|
14257
|
50
|
66
|
|
|
93122
|
|| (!is_ref($$_{name}) && defined($$_{name})) |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
25
|
14216
|
|
|
|
|
23882
|
)} @{$opt{message}{alternates}} |
|
|
14216
|
|
|
|
|
32822
|
|
|
26
|
|
|
|
|
|
|
} |
|
27
|
2
|
|
|
|
|
17
|
elsif(defined($opt{message}{name})&&!is_ref($opt{message}{name})) { @{$self{msg}}=({name=>$opt{message}{name}}) } |
|
|
2
|
|
|
|
|
7
|
|
|
28
|
|
|
|
|
|
|
} |
|
29
|
33
|
50
|
|
|
|
56
|
elsif(is_arrayref($opt{message})) { @{$self{msg}}=grep {!is_ref($_) && defined($_)} @{$opt{message}} } |
|
|
33
|
|
|
|
|
93
|
|
|
|
71
|
|
|
|
|
244
|
|
|
|
33
|
|
|
|
|
72
|
|
|
30
|
186376
|
50
|
|
|
|
410222
|
elsif(!is_ref($opt{message})) { @{$self{msg}}=grep {!is_ref($_) && defined($_)} $opt{message} } |
|
|
186376
|
|
|
|
|
535077
|
|
|
|
186376
|
|
|
|
|
734401
|
|
|
31
|
200627
|
|
|
|
|
971787
|
return bless(\%self,$class); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub unwrap { |
|
35
|
373755
|
|
|
373755
|
0
|
866043
|
my ($self,$msg)=@_; |
|
36
|
373755
|
100
|
|
|
|
804652
|
if(!defined($msg)) { return ('',$self) } |
|
|
152550
|
|
|
|
|
567022
|
|
|
37
|
221205
|
|
|
|
|
394598
|
my $names=$$self{names}; |
|
38
|
221205
|
100
|
|
|
|
472430
|
if(!is_ref($msg)) { |
|
39
|
206981
|
100
|
|
|
|
427244
|
if(!defined($$names{$msg})) { return ($msg,$self) } |
|
|
206923
|
|
|
|
|
694201
|
|
|
40
|
58
|
|
|
|
|
100
|
return __PACKAGE__->new(%{$$names{$msg}},names=>{})->random(); |
|
|
58
|
|
|
|
|
255
|
|
|
41
|
|
|
|
|
|
|
} |
|
42
|
14224
|
50
|
|
|
|
30972
|
if(is_hashref($msg)) { |
|
43
|
14224
|
|
66
|
|
|
46609
|
my $name=$$msg{name}//$$msg{message}; |
|
44
|
14224
|
100
|
|
|
|
30017
|
if(!defined($$names{$name})) { return ($$msg{message},$msg) } |
|
|
14220
|
|
|
|
|
58181
|
|
|
45
|
4
|
|
|
|
|
8
|
return __PACKAGE__->new(%{$$names{$name}},names=>{})->random(); |
|
|
4
|
|
|
|
|
15
|
|
|
46
|
|
|
|
|
|
|
} |
|
47
|
0
|
|
|
|
|
0
|
return ('',$msg); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
3
|
|
|
3
|
0
|
16
|
sub primary { my ($self)=@_; return $self->unwrap($$self{msg}[0]) } |
|
|
3
|
|
|
|
|
8
|
|
|
51
|
373752
|
|
|
373752
|
1
|
663520
|
sub random { my ($self)=@_; return $self->unwrap($$self{msg}[ int(rand(1+$#{$$self{msg}})) ]) } |
|
|
373752
|
|
|
|
|
719133
|
|
|
|
373752
|
|
|
|
|
1387718
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub attributesFromConf { |
|
54
|
411
|
|
|
411
|
1
|
835
|
my ($conf)=@_; |
|
55
|
411
|
100
|
|
|
|
881
|
if(!is_hashref($conf)) { return } |
|
|
396
|
|
|
|
|
868
|
|
|
56
|
15
|
|
|
|
|
17
|
my @res; |
|
57
|
15
|
100
|
|
|
|
42
|
if(is_hashref($$conf{attributes})) { |
|
58
|
2
|
|
|
|
|
3
|
while(my ($k,$v)=each %{$$conf{attributes}}) { push @res,[$k,$v] } } |
|
|
3
|
|
|
|
|
7
|
|
|
|
5
|
|
|
|
|
17
|
|
|
59
|
15
|
100
|
|
|
|
36
|
if(is_arrayref($$conf{alternates})) { |
|
60
|
11
|
|
|
|
|
14
|
foreach my $message (grep {is_hashref($_)} @{$$conf{alternates}}) { |
|
|
12
|
|
|
|
|
23
|
|
|
|
11
|
|
|
|
|
18
|
|
|
61
|
12
|
50
|
|
|
|
24
|
if(is_hashref($$message{attributes})) { |
|
62
|
12
|
|
|
|
|
12
|
while(my ($k,$v)=each %{$$message{attributes}}) { push @res,[$k,$v] } } } } |
|
|
16
|
|
|
|
|
32
|
|
|
|
28
|
|
|
|
|
63
|
|
|
63
|
15
|
|
|
|
|
37
|
return @res; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub validate { |
|
67
|
435
|
|
|
435
|
0
|
8054
|
my ($msg,%opt)=@_; |
|
68
|
435
|
100
|
|
|
|
913
|
if(!is_ref($msg)) { return } |
|
|
391
|
|
|
|
|
884
|
|
|
69
|
44
|
100
|
|
|
|
88
|
if(is_arrayref($msg)) { return map {validate($_,%opt)} grep {is_hashref($_)} @$msg } |
|
|
11
|
|
|
|
|
27
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
25
|
|
|
|
|
47
|
|
|
70
|
33
|
|
|
|
|
45
|
my @res; |
|
71
|
33
|
50
|
|
|
|
61
|
if(is_hashref($msg)) { |
|
72
|
33
|
100
|
|
|
|
68
|
if(exists($$msg{name})) { |
|
73
|
5
|
50
|
|
|
|
26
|
if(!defined($$msg{name})) { push @res,'Message undefined name' } |
|
|
0
|
100
|
|
|
|
0
|
|
|
74
|
2
|
|
|
|
|
11
|
elsif(!defined($opt{names}{$$msg{name}})) { push @res,"Message undefined name: $$msg{name}" } |
|
75
|
|
|
|
|
|
|
} |
|
76
|
33
|
100
|
|
|
|
88
|
if(is_arrayref($$msg{alternates})) { push @res,map {validate($_,%opt)} @{$$msg{alternates}} } |
|
|
14
|
|
|
|
|
23
|
|
|
|
16
|
|
|
|
|
36
|
|
|
|
14
|
|
|
|
|
30
|
|
|
77
|
|
|
|
|
|
|
} |
|
78
|
33
|
|
|
|
|
99
|
return @res; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |