line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Lacuna::Task::Role::Notify; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1515
|
use 5.010; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
62
|
|
4
|
|
|
|
|
|
|
our $VERSION = $Games::Lacuna::Task::VERSION; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
450
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Email::Stuff; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'email' => ( |
11
|
|
|
|
|
|
|
is => 'rw', |
12
|
|
|
|
|
|
|
isa => 'Str', |
13
|
|
|
|
|
|
|
documentation => q[Notification e-mail address], |
14
|
|
|
|
|
|
|
required => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'email_send' => ( |
18
|
|
|
|
|
|
|
is => 'rw', |
19
|
|
|
|
|
|
|
isa => 'ArrayRef', |
20
|
|
|
|
|
|
|
default => sub { [] }, |
21
|
|
|
|
|
|
|
documentation => q[e-mail send methods], |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub notify { |
25
|
|
|
|
|
|
|
my ($self,$subject,$message) = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $email = Email::Stuff |
28
|
|
|
|
|
|
|
->from($self->email) |
29
|
|
|
|
|
|
|
->to($self->email) |
30
|
|
|
|
|
|
|
->subject($subject); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
if ($message =~ m/<html>/i) { |
33
|
|
|
|
|
|
|
$email->html_body($message); |
34
|
|
|
|
|
|
|
} else { |
35
|
|
|
|
|
|
|
$email->text_body($message); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$email->send( @{ $self->email_send } ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
no Moose::Role; |
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=encoding utf8 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Games::Lacuna::Role::Notify -Â Send email notifications |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SYNOPSIS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
package Games::Lacuna::Task::Action::MyTask; |
53
|
|
|
|
|
|
|
use Moose; |
54
|
|
|
|
|
|
|
extends qw(Games::Lacuna::Task::Action); |
55
|
|
|
|
|
|
|
with qw(Games::Lacuna::Task::Role::Notify); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub run { |
58
|
|
|
|
|
|
|
my ($self) = @_; |
59
|
|
|
|
|
|
|
$self->notify('Alarm!!','Something has happened'); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 ACCESSORS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 email |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Recipient email |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 email_send |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
MIME::Lite send configuration |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 METHODS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 notify |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Sends an email notification |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$self->log($subject,$message); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |