blib/lib/IO/Async/Resolver/DNS/NetDNSImpl.pm

filter: Statementstmt 88.0% 22 / 25 Branchbran 25.0% 1 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 78.5% 33 / 42 SCAR 14.3
CC
4
Cov
78%
_resolve
4.9
BEGIN
1.0
BEGIN
1.0
CRAP 4.2
« Build ↑ Summary blib/lib/IO/Async/Resolver/DNS/LibResolvImpl.pm »
1 # You may distribute under the terms of either the GNU General Public License
2 # or the Artistic License (the same terms as Perl itself)
3 #
4 # (C) Paul Evans, 2011-2013 -- leonerd@leonerd.org.uk
5  
6 package IO::Async::Resolver::DNS::NetDNSImpl;
7  
8 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 our $VERSION = '0.04';
12  
13 3 ▶use Net::DNS::Resolver;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 my $res;
16 sub _resolve
17 {
18 2 ▶ my ( $method, $dname, $class, $type ) = @_;
Subroutine _resolve: called CC=4 SCAR=16.0
19  
20 2 ▶ $res ||= Net::DNS::Resolver->new;
Condition66%2/3
$res ||= "Net::DNS::Resolver"->new
l!l&&r!l&&!r
110
MC/DC0%0/2
$res ||= "Net::DNS::Resolver"->new
$res "Net::DNS::Resolver"->new
Truth table66%2/3
A ||= B
A= $resB= "Net::DNS::Resolver"->new
ABresult
1X1
011
000
21  
22 2 my $pkt = $res->$method( $dname, $type, $class ); # !order
23 2 ▶ if( !$pkt ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pkt) 0 2 2
24 0 my $errorstring = $res->errorstring;
25 # Net::DNS::Resolver yields NOERROR for successful DNS queries that just
26 # didn't yield any records of the type we wanted. Rewrite that into
27 # NODATA instead
28 0 ▶ die "NODATA\n" if $errorstring eq "NOERROR";
Branch: 1 branch
BranchTrueFalseTotal
if $errorstring eq "NOERROR" 0 0 0
29 0 die "$errorstring\n";
30 }
31  
32 # placate Net::DNS::Packet bug
33 2 $pkt->answer; $pkt->authority; $pkt->additional;
34  
35 2 return $pkt->data;
36 }
37  
38  
39 1 ▶sub IO::Async::Resolver::DNS::res_query { _resolve( query => @_ ) }
Subroutine res_query: called CC=1 SCAR=0.0
Pod documented
40 1 ▶sub IO::Async::Resolver::DNS::res_search { _resolve( search => @_ ) }
Subroutine res_search: called CC=1 SCAR=0.0
Pod documented
41  
42 3 0x55AA;
« Build ↑ Summary blib/lib/IO/Async/Resolver/DNS/LibResolvImpl.pm »