blib/lib/MooseX/Types/NetAddr/IP.pm

filter: Statementstmt 100% 40 / 40 Branchbran 100% 2 / 2 Conditioncond 83.3% 5 / 6 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 100% 13 / 13 Podpod 0.0% 0 / 1 totaltotal 95.3% 62 / 65 CC 5 SCAR 4.7
CC
5
Cov
98%
createAddress
3.0
__ANON__
2.1
__ANON__
2.0
CRAP 1.6
↑ Summary
1 package MooseX::Types::NetAddr::IP;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '0.07';
7  
8 1 ▶use Module::Runtime qw/use_module/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use MooseX::Types::Moose qw/Str ArrayRef/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use MooseX::Types -declare => [qw( NetAddrIP NetAddrIPv4 NetAddrIPv6 )];
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 class_type 'NetAddr::IP';
14  
15 1 subtype NetAddrIP, as 'NetAddr::IP'; # can be either IPv4 or IPv6
16 1 subtype NetAddrIPv4, as 'NetAddr::IP'; # can be only IPv4
17 1 subtype NetAddrIPv6, as 'NetAddr::IP'; # can be only IPv6
18  
19 coerce NetAddrIP,
20 from Str,
21 2 ▶ via {
Subroutine __ANON__: called CC=2 SCAR=6.9
22 2 ▶ return use_module('NetAddr::IP')->new( $_ )
Condition100%2/2
&use_module('NetAddr::IP')->new($_) || die("'${_}' is not an IP address.\n")
l!l
11
MC/DC100%1/1
&use_module('NetAddr::IP')->new($_) || die("'${_}' is not an IP address.\n")
&use_module('NetAddr::IP')->new($_)
Truth table100%2/2
A
A= &use_module('NetAddr::IP')->new($_)
Aresult
11
00
23 || die "'$_' is not an IP address.\n";
24 1 };
25  
26 coerce NetAddrIP,
27 from ArrayRef[Str],
28 1 ▶ via {
Subroutine __ANON__: called CC=2 SCAR=7.6
29 1 ▶ return use_module('NetAddr::IP')->new( @$_ )
Condition50%1/2
&use_module('NetAddr::IP')->new(@$_) || die("'@${_}' is not an IP address.\n")
l!l
10
MC/DC0%0/1
&use_module('NetAddr::IP')->new(@$_) || die("'@${_}' is not an IP address.\n")
&use_module('NetAddr::IP')->new(@$_)
Truth table50%1/2
A
A= &use_module('NetAddr::IP')->new(@$_)
Aresult
11
00
30 || die "'@$_' is not an IP address.\n";
31 1 };
32  
33 13 ▶sub createAddress ($@) {
Subroutine createAddress: called CC=3 SCAR=11.0
Pod undocumented
34 13 my $version = shift;
35  
36 13 ▶ my $ipaddr = use_module('NetAddr::IP')->new( @_ )
Condition100%2/2
&use_module('NetAddr::IP')->new(@_) || die("'@{_}' is not an IPv$version address.\n")
l!l
112
MC/DC100%1/1
&use_module('NetAddr::IP')->new(@_) || die("'@{_}' is not an IPv$version address.\n")
&use_module('NetAddr::IP')->new(@_)
Truth table100%2/2
A
A= &use_module('NetAddr::IP')->new(@_)
Aresult
11
00
37 || die "'@_' is not an IPv$version address.\n";
38  
39 11 ▶ die "'@_' is not an IPv$version address."
Branch: 1 branch
BranchTrueFalseTotal
unless $ipaddr->version == $version 2 9 11
40 unless $ipaddr->version == $version;
41  
42 9 return $ipaddr;
43 }
44  
45 coerce NetAddrIPv4,
46 from Str,
47 4 ▶ via { createAddress 4 => $_ };
Subroutine __ANON__: called CC=1 SCAR=0.0
48  
49 coerce NetAddrIPv4,
50 from ArrayRef[Str],
51 1 ▶ via { createAddress 4 => @$_ };
Subroutine __ANON__: called CC=1 SCAR=0.0
52  
53 coerce NetAddrIPv6,
54 from Str,
55 7 ▶ via { createAddress 6 => $_ };
Subroutine __ANON__: called CC=1 SCAR=0.0
56  
57 coerce NetAddrIPv6,
58 from ArrayRef[Str],
59 1 ▶ via { createAddress 6 => @$_ };
Subroutine __ANON__: called CC=1 SCAR=0.0
60  
61 1 1;
62 __END__
↑ Summary