blib/lib/Net/AIML.pm

filter: Statementstmt 60.5% 23 / 38 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 100% 2 / 2 totaltotal 58.1% 32 / 55 CC 4 SCAR 20.0
CC
4
Cov
52%
tell
20.0
new
2.0
BEGIN
1.0
CRAP 7.4
↑ Summary
1 package Net::AIML;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '0.0.5';
6  
7  
8 1 ▶use HTTP::Request::Common qw(POST);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use LWP::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use XML::Smart;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use constant BOTURL => 'http://www.pandorabots.com/pandora/talk-xml';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
16 0 my $class = shift;
17 0 return bless {@_}, $class;
18 }
19  
20 0 ▶sub tell {
Subroutine tell: not called CC=4 SCAR=30.0
Pod documented
21 0 my ( $self, $input, $custid ) = @_;
22 0 my $ua = LWP::UserAgent->new();
23 0 $ua->env_proxy();
24 my $req = POST BOTURL,
25 0 [ botid => $self->{botid}, custid => $custid, input => $input ];
26 0 my $res = $ua->request($req);
27 0 ▶ if ( ! $res->is_success ) { return "sorry, I'm having connection problems"; }
Branch: 1 branch
BranchTrueFalseTotal
unless ($res->is_success) 0 0 0
28 0 my $xs = XML::Smart->new( $res->content ); # or whatever
29 0 my $error = qq[$xs->{result}{status}];
30 0 ▶ if ($error) { warn $error; return; }
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
31 return wantarray
32 0 ▶ ? ( qq[$xs->{result}{that}], qq[$xs->{result}{custid}] )
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
33 : qq[$xs->{result}{that}];
34 }
35  
36 1 1;
37 __END__
↑ Summary