File Coverage

blib/lib/Dancer2/Plugin/Emailesque.pm
Criterion Covered Total %
statement 15 17 88.2
branch n/a
condition n/a
subroutine 5 6 83.3
pod n/a
total 20 23 86.9


line stmt bran cond sub pod time code
1             package Dancer2::Plugin::Emailesque;
2              
3 1     1   24514 use 5.006;
  1         3  
  1         73  
4 1     1   6 use strict;
  1         2  
  1         29  
5 1     1   4 use warnings FATAL => 'all';
  1         5  
  1         44  
6              
7 1     1   677 use Dancer2::Plugin;
  1         317225  
  1         8  
8 1     1   2672 use Emailesque ('!email');
  1         291024  
  1         416  
9              
10             =head1 NAME
11              
12             Dancer2::Plugin::Emailesque - Simple Emailesque support for Dancer2
13              
14             =head1 VERSION
15              
16             Version 0.02
17              
18             =cut
19              
20             our $VERSION = '0.02';
21              
22             =head1 SYNOPSIS
23              
24             Configure your global mailer settings in your config file:
25              
26             plugins:
27             Emailesque:
28             from: me@gmail.com
29             # for gmail...
30             ssl: 1
31             driver: smtp
32             host: smtp.googlemail.com
33             port: 465
34             user: account@gmail.com
35             pass: TheMightyPass
36              
37             In your module
38              
39             use Dancer2::Plugin::Emailesque;
40              
41             And when you need to mail someone:
42              
43             email { to => $email_recipient,
44             subject => "Your daily mail",
45             message => "The mail contents" };
46              
47             For further configuration or email construction check Emailesque
48             documentation.
49              
50             =cut
51              
52             my $emailesque;
53              
54             sub _create_emailesque {
55 0     0     my $settings = plugin_setting;
56 0           $emailesque = Emailesque->new( $settings );
57             }
58              
59             on_plugin_import {
60             _create_emailesque unless $emailesque;
61             };
62              
63             register email => sub {
64             my $dsl = shift;
65             my $options = shift || {};
66              
67             _create_emailesque unless $emailesque;
68              
69             $emailesque->send($options);
70             };
71              
72             register_plugin;
73              
74             =head1 AUTHOR
75              
76             Alberto Simoes, C<< >>
77              
78             =head1 BUGS
79              
80             To report any bugs or feature requests access https://github.com/ambs/Dancer2-Plugin-Emailesque
81              
82             =head1 ACKNOWLEDGEMENTS
83              
84             IronCamel for the first Dancer::Plugin::Email module, AlNewKirk for Emailesque.
85              
86             =head1 LICENSE AND COPYRIGHT
87              
88             This program is free software; you can redistribute it and/or modify it
89             under the terms of the the Artistic License (2.0). You may obtain a
90             copy of the full license at:
91              
92             L
93              
94             Any use, modification, and distribution of the Standard or Modified
95             Versions is governed by this Artistic License. By using, modifying or
96             distributing the Package, you accept this license. Do not use, modify,
97             or distribute the Package, if you do not accept this license.
98              
99             If your Modified Version has been derived from a Modified Version made
100             by someone other than you, you are nevertheless required to ensure that
101             your Modified Version complies with the requirements of this license.
102              
103             This license does not grant you the right to use any trademark, service
104             mark, tradename, or logo of the Copyright Holder.
105              
106             This license includes the non-exclusive, worldwide, free-of-charge
107             patent license to make, have made, use, offer to sell, sell, import and
108             otherwise transfer the Package with respect to any patent claims
109             licensable by the Copyright Holder that are necessarily infringed by the
110             Package. If you institute patent litigation (including a cross-claim or
111             counterclaim) against any party alleging that the Package constitutes
112             direct or contributory patent infringement, then this Artistic License
113             to you shall terminate on the date that such litigation is filed.
114              
115             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
116             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
117             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
118             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
119             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
120             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
121             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
122             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
123              
124              
125             =cut
126              
127             1; # End of Dancer2::Plugin::Emailesque