File Coverage

blib/lib/Bot/ChatBots/Role/WebPoller.pm
Criterion Covered Total %
statement 27 35 77.1
branch n/a
condition n/a
subroutine 9 11 81.8
pod 1 1 100.0
total 37 47 78.7


line stmt bran cond sub pod time code
1             package Bot::ChatBots::Role::WebPoller;
2 1     1   1073 use strict;
  1         2  
  1         25  
3 1     1   4 use warnings;
  1         1  
  1         35  
4             { our $VERSION = '0.009'; }
5              
6 1     1   5 use Ouch;
  1         2  
  1         5  
7 1     1   786 use IO::Socket::SSL ();
  1         66659  
  1         30  
8 1     1   550 use Mojo::UserAgent;
  1         147550  
  1         10  
9 1     1   46 use Log::Any qw< $log >;
  1         3  
  1         11  
10 1     1   276 use Try::Tiny;
  1         2  
  1         49  
11              
12 1     1   5 use Moo::Role;
  1         2  
  1         12  
13 1     1   1021 use namespace::clean;
  1         8935  
  1         9  
14              
15             with 'Bot::ChatBots::Role::Poller';
16              
17             has ua => (is => 'ro', default => sub { return Mojo::UserAgent->new });
18             has tx_args => (is => 'ro', required => 1);
19              
20             sub poll {
21 0     0 1   my ($self, $on_data, $args) = @_;
22 0           my $ua = $self->ua;
23 0           my $tx = $ua->build_tx(@{$self->tx_args});
  0            
24             my $cb = sub {
25 0     0     my ($ua, $tx) = @_;
26 0           return $on_data->({tx => $tx, ua => $ua});
27 0           };
28 0           return $ua->start($tx, $cb);
29             }
30              
31             1;