File Coverage

blib/lib/App/Spoor/CpanelHookFile.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 14 14 100.0


line stmt bran cond sub pod time code
1             package App::Spoor::CpanelHookFile;
2              
3 1     1   12 use v5.10;
  1         3  
4 1     1   5 use strict;
  1         2  
  1         20  
5 1     1   4 use warnings;
  1         2  
  1         99  
6              
7             =head1 NAME
8              
9             App::Spoor::CpanelHookFile
10              
11             =head1 VERSION
12              
13             Version 0.01
14              
15             =cut
16              
17             our $VERSION = '0.01';
18              
19              
20             =head1 SYNOPSIS
21              
22             Contains the contents used for populating the file that makes use of the CPanel standarized hook.
23              
24             =head1 SUBROUTINES/METHODS
25              
26             =head2 contents
27              
28             Returns the contents of SpoorForwardHook.
29              
30             =cut
31              
32             sub contents {
33 9     9 1 2092 my $contents = <<'END_MESSAGE';
34             package SpoorForwardHook;
35              
36             use strict;
37             use warnings;
38              
39             use JSON;
40             use Cpanel::Logger;
41              
42             my $logger = Cpanel::Logger->new();
43              
44             sub describe {
45             my $uapi_add = {
46             'category' => 'Cpanel',
47             'event' => 'UAPI::Email::add_forwarder',
48             'stage' => 'post',
49             'hook' => 'SpoorForwardHook::write_forward_added',
50             'exectype' => 'module'
51             };
52              
53             my $uapi_delete = {
54             'category' => 'Cpanel',
55             'event' => 'UAPI::Email::delete_forwarder',
56             'stage' => 'post',
57             'hook' => 'SpoorForwardHook::write_forward_removed',
58             'exectype' => 'module'
59             };
60              
61             return [ $uapi_add, $uapi_delete ];
62             }
63              
64             sub write_forward_added {
65             my ( $context, $data ) = @_;
66              
67             my %message = (
68             message => to_json($data),
69             service => 'spoor_forward_added',
70             output => 1,
71             backtrace => 0,
72             level => 'info'
73             );
74              
75             $logger->logger(\%message);
76             return 0, 'Hook up successful';
77             }
78              
79             sub write_forward_removed {
80             my ( $context, $data ) = @_;
81              
82             my %message = (
83             message => to_json($data),
84             service => 'spoor_forward_removed',
85             output => 1,
86             backtrace => 0,
87             level => 'info'
88             );
89              
90             $logger->logger(\%message);
91             return 0, 'Hook up successful';
92             }
93              
94             1;
95             END_MESSAGE
96             }
97              
98             =head1 AUTHOR
99              
100             Rory McKinley, C<< <rorymckinley at capefox.co> >>
101              
102             =head1 BUGS
103              
104             Please report any bugs or feature requests to C<bug-. at rt.cpan.org>, or through
105             the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=.>. I will be notified, and then you'll
106             automatically be notified of progress on your bug as I make changes.
107              
108              
109             =head1 SUPPORT
110              
111             You can find documentation for this module with the perldoc command.
112              
113             perldoc App::Spoor::CpanelHookFile
114              
115              
116             You can also look for information at:
117              
118             =over 4
119              
120             =item * RT: CPAN's request tracker (report bugs here)
121              
122             L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=.>
123              
124             =item * AnnoCPAN: Annotated CPAN documentation
125              
126             L<http://annocpan.org/dist/.>
127              
128             =item * CPAN Ratings
129              
130             L<https://cpanratings.perl.org/d/.>
131              
132             =item * Search CPAN
133              
134             L<https://metacpan.org/release/.>
135              
136             =back
137              
138             =head1 LICENSE AND COPYRIGHT
139              
140             Copyright 2019 Rory McKinley.
141              
142             This program is free software; you can redistribute it and/or modify it
143             under the terms of the the Artistic License (2.0). You may obtain a
144             copy of the full license at:
145              
146             L<http://www.perlfoundation.org/artistic_license_2_0>
147              
148             Any use, modification, and distribution of the Standard or Modified
149             Versions is governed by this Artistic License. By using, modifying or
150             distributing the Package, you accept this license. Do not use, modify,
151             or distribute the Package, if you do not accept this license.
152              
153             If your Modified Version has been derived from a Modified Version made
154             by someone other than you, you are nevertheless required to ensure that
155             your Modified Version complies with the requirements of this license.
156              
157             This license does not grant you the right to use any trademark, service
158             mark, tradename, or logo of the Copyright Holder.
159              
160             This license includes the non-exclusive, worldwide, free-of-charge
161             patent license to make, have made, use, offer to sell, sell, import and
162             otherwise transfer the Package with respect to any patent claims
163             licensable by the Copyright Holder that are necessarily infringed by the
164             Package. If you institute patent litigation (including a cross-claim or
165             counterclaim) against any party alleging that the Package constitutes
166             direct or contributory patent infringement, then this Artistic License
167             to you shall terminate on the date that such litigation is filed.
168              
169             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
170             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
171             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
172             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
173             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
174             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
175             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
176             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
177              
178              
179             =cut
180              
181             1; # End of App::Spoor::CpanelHookFile