Events.pm

filter: Statementstmt 70.9% 22 / 31 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 100% 1 / 1 totaltotal 71.4% 30 / 42 CC 1 SCAR 2.6
CC
1
Cov
71%
register
2.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.3
« Events/Listener.pm ↑ Summary
1 package Mojolicious::Plugin::Events;
2 2 ▶use Mojo::Base 'Mojolicious::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use Mojolicious::Plugin::Events::Dispatcher;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Mojolicious::Plugin::Events::Listeners;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 2 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 0 ▶sub register {
Subroutine register: not called CC=1 SCAR=6.9
Pod documented
49 0 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 ▶ $app->helper(listeners => sub { $listeners });
Subroutine __ANON__: not called CC=1 SCAR=6.9
55  
56 0 my $events = Mojolicious::Plugin::Events::Dispatcher->new(app => $app);
57 0 weaken $events->{ app };
58  
59 0 ▶ $app->helper(events => sub { $events });
Subroutine __ANON__: not called CC=1 SCAR=6.9
60 }
61  
62 =head1 AUTHOR
63  
64 Adrian Crisan, C<< <adrian.crisan88 at gmail.com> >>
65  
66 =head1 BUGS
67  
68 Please report any bugs or feature requests to C<bug-mojolicious-plugin-events at rt.cpan.org>, or through
69 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mojolicious-Plugin-Events>. 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<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Mojolicious-Plugin-Events>
89  
90 =item * AnnoCPAN: Annotated CPAN documentation
91  
92 L<http://annocpan.org/dist/Mojolicious-Plugin-Events>
93  
94 =item * CPAN Ratings
95  
96 L<http://cpanratings.perl.org/d/Mojolicious-Plugin-Events>
97  
98 =item * Search CPAN
99  
100 L<http://search.cpan.org/dist/Mojolicious-Plugin-Events/>
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<http://www.perlfoundation.org/artistic_license_2_0>
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 2 1; # End of Mojolicious::Plugin::Events
« Events/Listener.pm ↑ Summary