blib/lib/Net/FCP/Tiny.pm

filter: Statementstmt 40.5% 15 / 37 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 66.6% 6 / 9 Podpod 0.0% 0 / 3 totaltotal 30.4% 21 / 69 CC 8 SCAR 29.2
CC
8
Cov
29%
new
42.0
send_msg
12.0
array2hash
2.0
CRAP 18.5
↑ Summary
1 package Net::FCP::Tiny;
2 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 $Net::FCP::Tiny::AUTHORITY = 'cpan:AVAR';
4 }
5 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 $Net::FCP::Tiny::VERSION = '0.03';
7 }
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use IO::Socket::INET;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 0 ▶sub new {
Subroutine new: not called CC=6 SCAR=37.4
Pod undocumented
14 0 my ($pkg, %args) = @_;
15  
16 0 ▶ $args{name} ||= __PACKAGE__;
Condition0%0/2
$args{"name"} ||= __PACKAGE__
l!l
00
MC/DC0%0/1
$args{"name"} ||= __PACKAGE__
$args{"name"}
Truth table0%0/2
A
A= $args{"name"}
Aresult
11
00
17 0 ▶ $args{host} ||= 'localhost';
Condition0%0/2
$args{"host"} ||= "localhost"
l!l
00
MC/DC0%0/1
$args{"host"} ||= "localhost"
$args{"host"}
Truth table0%0/2
A
A= $args{"host"}
Aresult
11
00
18 0 ▶ $args{port} ||= 9481;
Condition0%0/2
$args{"port"} ||= 9481
l!l
00
MC/DC0%0/1
$args{"port"} ||= 9481
$args{"port"}
Truth table0%0/2
A
A= $args{"port"}
Aresult
11
00
19  
20 $args{sock} ||= IO::Socket::INET->new(
21 PeerAddr => $args{host},
22 PeerPort => $args{port},
23 0 ▶ Proto => 'tcp',
Condition0%0/3
$args{"sock"} ||= "IO::Socket::INET"->new("PeerAddr", $args{"host"}, "PeerPort", $args{"port"}, "Proto", "tcp", "Blocking", 1)
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"sock"} ||= "IO::Socket::INET"->new("PeerAddr", $args{"host"}, "PeerPort", $args{"port"}, "Proto", "tcp", "Blocking", 1)
$args{"sock"} "IO::Socket::INET"->new("PeerAddr", $args{"host"}, "PeerPort", $args{"port"}, "Proto", "tcp", "Blocking", 1)
Truth table0%0/3
A ||= B
A= $args{"sock"}B= "IO::Socket::INET"->new("PeerAddr", $args{"host"}, "PeerPort", $args{"port"}, "Proto", "tcp", "Blocking", 1)
ABresult
1X1
011
000
24 Blocking => 1,
25 );
26  
27 # Couldn't connect
28 0 ▶ return unless $args{sock};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"sock"} 0 0 0
29  
30 0 my $self = bless \%args => $pkg;
31  
32 0 my $helo = $self->send_msg(<<'END');
33 ClientHello
34 Name=$args{$name};
35 ExpectedVersion=2.0
36 EndMessage
37 END
38  
39 0 return $self;
40 }
41  
42 0 ▶sub send_msg {
Subroutine send_msg: not called CC=3 SCAR=24.8
Pod undocumented
43 0 my ($self, $msg) = @_;
44 0 my $sock = $self->{sock};
45 0 my @line;
46  
47 0 print $sock $msg;
48  
49 0 ▶ while (my $line = <$sock>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $sock)) 0 0 0
50 0 chomp $line;
51 0 ▶ last if $line eq 'EndMessage';
Branch: 1 branch
BranchTrueFalseTotal
if $line eq "EndMessage" 0 0 0
52 0 push @line => $line;
53 }
54  
55 0 return \@line;
56 }
57  
58 0 ▶sub array2hash {
Subroutine array2hash: not called CC=1 SCAR=6.9
Pod undocumented
59 0 my ($self, $lines) = @_;
60 return +{
61 map {
62 0 my ($k, $v) = split(/=/, $_, 2);
63 0 $k => $v;
64 } @$lines
65 };
66 }
67  
68 1 1;
69  
70 __END__
↑ Summary