File Coverage

blib/lib/Dancer/Plugin/reCAPTCHA.pm
Criterion Covered Total %
statement 9 16 56.2
branch 0 2 0.0
condition n/a
subroutine 3 5 60.0
pod n/a
total 12 23 52.1


line stmt bran cond sub pod time code
1             package Dancer::Plugin::reCAPTCHA;
2             # ABSTRACT: Easily integrate reCAPTCHA into your Dancer applications
3             {
4             $Dancer::Plugin::reCAPTCHA::VERSION = '0.90';
5             }
6              
7              
8 1     1   103948 use Dancer ':syntax';
  1         174632  
  1         5  
9 1     1   612 use Dancer::Plugin;
  1         1106  
  1         54  
10 1     1   6 use Captcha::reCAPTCHA::V2;
  1         2  
  1         154  
11              
12             my $rc = Captcha::reCAPTCHA::V2->new;
13              
14              
15             register recaptcha_display => sub {
16 0     0     my $conf = plugin_setting();
17 0 0         my %options = map { $_ => $conf->$_ if defined $conf->$_ } (qw[ theme type size ]);
  0            
18             return $rc->html(
19             $conf->{ public_key },
20 0           { %options }
21             );
22             };
23              
24              
25             register recaptcha_check => sub {
26 0     0     my ( $response ) = @_;
27 0           my $conf = plugin_setting();
28             return $rc->verify(
29             $conf->{ private_key },
30 0           $response,
31             request->remote_address,
32             );
33             };
34              
35              
36             register_plugin;
37             1;
38              
39             __END__