line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Events; |
2
|
1
|
|
|
1
|
|
55250
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
161861
|
|
|
1
|
|
|
|
|
10
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1093
|
use 5.006; |
|
1
|
|
|
|
|
5
|
|
5
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
39
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Scalar::Util qw(weaken); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
361
|
use Mojolicious::Plugin::Events::Dispatcher; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
11
|
1
|
|
|
1
|
|
425
|
use Mojolicious::Plugin::Events::Listeners; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Mojolicious::Plugin::Events - A plugin for dispatching and handling sync/async events |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 0.02 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.3.1'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Quick summary of what the module does. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Perhaps a little code snippet. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use Mojolicious::Plugin::Events; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# register the plugin |
35
|
|
|
|
|
|
|
$app->plugin('Events' => ['namespaces' => 'MyApp::Listeners']); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# dispatch event |
38
|
|
|
|
|
|
|
$app->events->dispatch(say => 'Hello, World!'); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 register |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Register the plugin |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub register { |
49
|
0
|
|
|
0
|
1
|
|
my ($self, $app, $config) = (@_); |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $listeners = Mojolicious::Plugin::Events::Listeners->new(app => $app, namespaces => $config->{ namespaces }); |
52
|
0
|
|
|
|
|
|
weaken $listeners->{ app }; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
0
|
|
|
$app->helper(listeners => sub { $listeners }); |
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $events = Mojolicious::Plugin::Events::Dispatcher->new(app => $app); |
57
|
0
|
|
|
|
|
|
weaken $events->{ app }; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
0
|
|
|
$app->helper(events => sub { $events }); |
|
0
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 AUTHOR |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Adrian Crisan, C<< >> |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 BUGS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
69
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
70
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 SUPPORT |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
perldoc Mojolicious::Plugin::Events |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
You can also look for information at: |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=over 4 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
L |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
L |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item * CPAN Ratings |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
L |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item * Search CPAN |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
L |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=back |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Copyright 2018 Adrian Crisan. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
113
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
114
|
|
|
|
|
|
|
copy of the full license at: |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
L |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
119
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
120
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
121
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
124
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
125
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
128
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
131
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
132
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
133
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
134
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
135
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
136
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
137
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
140
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
141
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
142
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
143
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
144
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
145
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
146
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
1; # End of Mojolicious::Plugin::Events |