lib/Unicorn/Manager/Types.pm

filter: Statementstmt 85.7% 12 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 89.4% 17 / 19 CC 1 SCAR 0.6
CC
1
Cov
86%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« script/ucd.pl ↑ Summary lib/Unicorn/Manager/CLI/Proc.pm »
1 package Unicorn::Manager::Types;
2  
3 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 0 ▶use Net::Interface;
Subroutine BEGIN: called CC=1 SCAR=2.6
8  
9 sub hashref {
10 return sub {
11 die "Failed type constraint. Should be a HashRef but is a " . ref( $_[0] )
12 if ref( $_[0] ) ne 'HASH';
13 }
14 }
15  
16 sub local_address {
17 return sub {
18 my $param = shift;
19  
20 my @addresses = map {
21 map { Net::Interface::inet_ntoa($_) } $_->address;
22 } Net::Interface->interfaces;
23  
24 if ( $param =~ /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ ) {
25 return 1 if grep { $_ eq $param } @addresses;
26 die "Can not listen on $param. No interface with this address.";
27 }
28 else {
29 if ( my $packed = gethostbyname $param ) {
30 my $address = Socket::inet_ntoa $packed;
31 return 1 if grep { $_ eq $address } @addresses;
32 }
33 die "Can not listen on $param. Hostname not resolvable.";
34 }
35  
36 }
37 }
38  
39 1;
40  
41 __END__
« script/ucd.pl ↑ Summary lib/Unicorn/Manager/CLI/Proc.pm »