File/Slurp/Remote/SmartOpen.pm

filter: Statementstmt 42.0% 21 / 50 Branchbran 0.0% 0 / 30 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 25.4% 26 / 102 CC 19 SCAR 57.1
CC
19
Cov
24%
smartopen
380.0
BEGIN
1.0
BEGIN
1.0
CRAP 301.0
↑ Summary File/Slurp/Remote/BrokenDNS.pm »
1  
2 package File::Slurp::Remote::SmartOpen;
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 require Exporter;
7 1 ▶use File::Slurp::Remote::BrokenDNS qw($myfqdn %fqdnify);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Tie::Function::Examples qw(%q_shell);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our @EXPORT = qw(smartopen);
12 1 our @ISA = qw(Exporter);
13 1 our $ssh = "ssh -o StrictHostKeyChecking=no -o BatchMode=yes -o PasswordAuthentication=no";
14 1 our $VERSION = 0.47;
15  
16 sub smartopen($\$$)
17 0 ▶{
Subroutine smartopen: not called CC=19 SCAR=59.4
Pod undocumented
18 0 my ($file, $fdref, $mode) = @_;
19  
20 0 my $unzip = '';
21 0 my $zip = '';
22 0 ▶ if ($file =~ /\.gz$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($file =~ /\.gz$/) { } 0 0 0
elsif ($file =~ /\.bz2$/) { } 0 0 0
23 0 $unzip = "zcat";
24 0 $zip = "gzip";
25 } elsif ($file =~ /\.bz2$/) {
26 0 $unzip = "bzcat";
27 0 $zip = "bzip2";
28 }
29  
30 0 my $pid;
31  
32 0 my $fd = $$fdref;
33  
34 0 ▶ if ($file =~ s/(.+):// && $fqdnify{$1} ne $myfqdn) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ s/(.+):// and $File::Slurp::Remote::SmartOpen::fqdnify{$1} ne $File::Slurp::Remote::SmartOpen::myfqdn) { } 0 0 0
Condition0%0/3
$file =~ s/(.+):// and $File::Slurp::Remote::SmartOpen::fqdnify{$1} ne $File::Slurp::Remote::SmartOpen::myfqdn
!ll&&!rl&&r
000
MC/DC0%0/2
$file =~ s/(.+):// and $File::Slurp::Remote::SmartOpen::fqdnify{$1} ne $File::Slurp::Remote::SmartOpen::myfqdn
$file =~ s/(.+):// $File::Slurp::Remote::SmartOpen::fqdnify{$1} ne $File::Slurp::Remote::SmartOpen::myfqdn
Truth table0%0/3
A and B
A= $file =~ s/(.+)://B= $File::Slurp::Remote::SmartOpen::fqdnify{$1} ne $File::Slurp::Remote::SmartOpen::myfqdn
ABresult
0X0
100
111
35 0 my $host = $1;
36 0 ▶ $unzip = "|$unzip" if $unzip;
Branch: 1 branch
BranchTrueFalseTotal
if $unzip 0 0 0
37 0 ▶ $zip = "$zip|" if $zip;
Branch: 1 branch
BranchTrueFalseTotal
if $zip 0 0 0
38 0 ▶ if ($mode && $mode eq 'w') {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode and $mode eq 'w') { } 0 0 0
Condition0%0/3
$mode and $mode eq "w"
!ll&&!rl&&r
000
MC/DC0%0/2
$mode and $mode eq "w"
$mode $mode eq "w"
Truth table0%0/3
A and B
A= $modeB= $mode eq "w"
ABresult
0X0
100
111
39 0 my $cat = $q_shell{"cat > $q_shell{$file}"};
40 0 ▶ $pid = open $fd, "|$zip $ssh $q_shell{$host} $cat"
Branch: 1 branch
BranchTrueFalseTotal
$pid = open($fd, "|$zip $File::Slurp::Remote::SmartOpen::ssh $File::Slurp::Remote::SmartOpen::q_shell{$host} $cat") or confess("open |$zip $File::Slurp::Remote::SmartOpen::ssh $File::Slurp::Remote::SmartOpen::q_shell{$host} ${cat}: $!") 0 0 0
41 or confess "open |$zip $ssh $q_shell{$host} $cat: $!";
42 } else {
43 0 ▶ $pid = open $fd, "$ssh -n $q_shell{$host} cat $q_shell{$file} $unzip|"
Branch: 1 branch
BranchTrueFalseTotal
$pid = open($fd, "$File::Slurp::Remote::SmartOpen::ssh -n $File::Slurp::Remote::SmartOpen::q_shell{$host} cat $File::Slurp::Remote::SmartOpen::q_shell{$file} $unzip|") or confess("open $File::Slurp::Remote::SmartOpen::ssh $File::Slurp::Remote::SmartOpen::q_shell{$host} cat $File::Slurp::Remote::SmartOpen::q_shell{$file} $unzip|: $!") 0 0 0
44 or confess "open $ssh $q_shell{$host} cat $q_shell{$file} $unzip|: $!";
45 }
46 } else {
47 0 ▶ if ($mode && $mode eq 'w') {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode and $mode eq 'w') { } 0 0 0
Condition0%0/3
$mode and $mode eq "w"
!ll&&!rl&&r
000
MC/DC0%0/2
$mode and $mode eq "w"
$mode $mode eq "w"
Truth table0%0/3
A and B
A= $modeB= $mode eq "w"
ABresult
0X0
100
111
48 0 ▶ if ($zip) {
Branch: 1 branch
BranchTrueFalseTotal
if ($zip) { } 0 0 0
49 0 ▶ $pid = open $fd, "|$zip > $q_shell{$file}"
Branch: 1 branch
BranchTrueFalseTotal
$pid = open($fd, "|$zip > $File::Slurp::Remote::SmartOpen::q_shell{$file}") or die "open |$zip > $File::Slurp::Remote::SmartOpen::q_shell{$file}: $!" 0 0 0
50 or die "open |$zip > $q_shell{$file}: $!";
51 } else {
52 0 ▶ open $fd, ">", $file
Branch: 1 branch
BranchTrueFalseTotal
open $fd, ">", $file or die "open >${file}: $!" 0 0 0
53 or die "open >$file: $!";
54 0 $pid = "0butTrue";
55 }
56 } else {
57 0 ▶ if ($unzip) {
Branch: 1 branch
BranchTrueFalseTotal
if ($unzip) { } 0 0 0
58 0 ▶ $pid = open $fd, "$unzip < $q_shell{$file}|"
Branch: 1 branch
BranchTrueFalseTotal
$pid = open($fd, "$unzip < $File::Slurp::Remote::SmartOpen::q_shell{$file}|") or die "open $unzip < $File::Slurp::Remote::SmartOpen::q_shell{$file}|: $!" 0 0 0
59 or die "open $unzip < $q_shell{$file}|: $!";
60 } else {
61 0 ▶ open $fd, "<", $file
Branch: 1 branch
BranchTrueFalseTotal
open $fd, "<", $file or die "open <${file}: $!" 0 0 0
62 or die "open <$file: $!";
63 0 $pid = "0buttrue";
64 }
65 }
66 }
67 0 $$fdref = $fd;
68 0 return $pid;
69 }
70  
71 1 1;
72  
73 __END__
↑ Summary File/Slurp/Remote/BrokenDNS.pm »