Branch Coverage

blib/lib/Treex/PML/IO.pm
Criterion Covered Total %
branch 55 276 19.9


line true false branch
59 0 0 if ($role eq 'IO' or $role eq 'Treex::PML::IO') { }
130 8 0 @_ > 0 ? :
161 0 0 if (ref $handler eq 'CODE' or ref $handler eq 'ARRAY') { }
162 0 0 if (exists $input_protocol_handler{$proto})
208 0 323 if (defined $fh and defined $encoding and $] >= 5.008)
212 0 0 if $@
233 95 321 if (&blessed($uri) and $uri->isa('URI'))
236 20 301 if ($uri =~ /^\s*([[:alnum:]][[:alnum:]]+):/) { }
269 134 330 unless $uri->scheme
270 464 0 if ($uri->scheme eq 'file')
288 0 215 if $^O eq 'VMS'
290 215 0 unless substr($cwd, -1, 1) eq '/'
303 691 349 if &blessed($url) and $url->isa('URI')
304 22 327 if ($uri eq $url || URI::Escape::uri_unescape($uri) eq $url and $url =~ m[^\s*[[:alnum:]]+://]) { }
322 0 28 unless &blessed($href) and $href->isa('URI')
339 0 0 unless $uri->scheme
340 0 0 if ($uri->scheme eq 'file')
354 20 353 $_[0] =~ /.gz~?$/ ? :
369 0 0 if $f1 eq $f2
370 0 0 &blessed($f1) && $f1->isa('URI') ? :
371 0 0 &blessed($f2) && $f2->isa('URI') ? :
372 0 0 if $u1 eq $u2
373 0 0 if $u1->canonical eq $u2->canonical
374 0 0 if (not ref $f1 || ref $f2 and $^O ne 'MSWin32' and -f $f1 and -f $f2)
390 0 0 if $f1 eq $f2
393 0 0 $d1 == $d2 && $i1 != 0 && $i1 == $i2 ? :
417 0 0 if (_is_gzip($file)) { }
418 0 0 if (-x $Treex::PML::IO::gzip and -x $Treex::PML::IO::zcat) { }
419 0 0 if ($rw eq 'w') { }
428 0 0 if ($rw eq 'w') { }
451 0 0 if (_is_gzip($file)) { }
452 0 0 if (-x $Treex::PML::IO::gzip)
454 0 0 if ($rw eq 'w') { }
455 0 0 unless $fh->writer("$Treex::PML::IO::gzip $Treex::PML::IO::gzip_opts > " . quote_filename($file))
457 0 0 unless $fh->reader("$Treex::PML::IO::zcat $Treex::PML::IO::zcat_opts < " . quote_filename($file))
460 0 0 unless ($fh)
461 0 0 unless eval { do { require IO::Zlib; $fh = 'IO::Zlib'->new } }
465 0 0 unless $fh->open($file, $rw . 'b')
469 0 0 unless $fh->open($file, $rw)
485 5 196 if (_is_gzip($file)) { }
489 0 5 if $@
490 0 5 unless $fh
491 5 0 if ($rw eq 'w') { }
492 0 5 if $Treex::PML::IO::Debug
496 0 0 unless eval { do { require IO::Zlib; $tmp = 'IO::Zlib'->new } } and $tmp
500 0 0 unless $tmp->open($file, 'rb')
512 0 196 unless $fh->open($file, $rw)
519 0 0 if (ref $callback eq 'CODE') { }
0 0 elsif (ref $callback eq 'ARRAY') { }
530 173 0 if ($proto eq 'file') { }
0 0 elsif ($proto eq 'ntred' or $proto =~ /$Treex::PML::IO::reject_proto/) { }
0 0 elsif (exists $input_protocol_handler{$proto}) { }
532 0 173 if $Treex::PML::IO::Debug
533 1 172 unless -e $file
534 0 172 unless -r $file
535 0 172 if -z $file
542 0 0 if ($new_proto ne $proto) { }
548 0 0 if ($^O eq 'MSWin32') { }
572 15 157 if (get_protocol($file) eq 'file' and _is_gzip($uri)) { }
577 0 15 unless $fh
579 0 15 unless eval { do { require IO::Zlib; $tmp = 'IO::Zlib'->new } } and $tmp
583 0 15 unless $tmp->open($file, 'rb')
591 0 15 if $unlink
601 0 0 if $Treex::PML::IO::Debug
602 0 0 if (system($cmd . ' > ' . $filename) == 0) { }
613 0 0 if ($status and $status->is_error and $status->code == 401)
618 0 0 if ($status->is_success) { }
631 0 0 _is_gzip($uri) ? :
636 0 0 if $Treex::PML::IO::Debug
637 0 0 if ($proto =~ /^https?|ftp|gopher|news/)
645 0 0 if $Treex::PML::IO::Debug
646 0 0 _is_gzip($uri) ? :
651 0 0 if $Treex::PML::IO::Debug
652 0 0 if ($proto =~ /^https?|ftp|gopher|news/)
656 0 0 if ($Treex::PML::IO::ssh and -x $Treex::PML::IO::ssh and $proto =~ /^(ssh|fish|sftp)$/)
657 0 0 if $Treex::PML::IO::Debug
658 0 0 if ($uri =~ m[^\s*(?:ssh|sftp|fish):(?://)?([^-/][^/]*)(/.*)$]) { }
660 0 0 if $Treex::PML::IO::Debug
668 0 0 if ($Treex::PML::IO::kioclient and -x $Treex::PML::IO::kioclient)
669 0 0 if $Treex::PML::IO::Debug
671 0 0 if ($proto eq 'ssh')
677 0 0 if ($Treex::PML::IO::curl and -x $Treex::PML::IO::curl and $proto =~ /^(?:https?|ftps?|gopher)$/)
687 0 0 if defined $user_pipe and not $user_pipe =~ /^\|/
690 0 0 if ($need_gzip) { }
691 0 0 if (-x $Treex::PML::IO::gzip) { }
699 0 0 if $Treex::PML::IO::Debug
711 0 0 if $Treex::PML::IO::Debug
712 0 0 if $proto eq 'http' or $proto eq 'https'
713 0 0 if ($Treex::PML::IO::ssh and -x $Treex::PML::IO::ssh and $proto =~ /^(ssh|fish|sftp)$/)
714 0 0 if $Treex::PML::IO::Debug
715 0 0 if ($uri =~ m[^\s*(?:ssh|sftp|fish):(?://)?([^-/][^/]*)(/.*)$]) { }
724 0 0 if ($Treex::PML::IO::kioclient and -x $Treex::PML::IO::kioclient)
725 0 0 if $Treex::PML::IO::Debug
727 0 0 if ($proto eq 'ssh')
733 0 0 if ($Treex::PML::IO::curl and -x $Treex::PML::IO::curl and $proto =~ /^(?:ftps?)$/)
756 31 0 if ($proto eq 'file') { }
0 0 elsif ($proto eq 'ntred' or $proto =~ /$Treex::PML::IO::reject_proto/) { }
758 0 31 if ($user_pipe) { }
766 0 0 if ($^O eq 'MSWin32') { }
782 0 0 $^O eq 'MSWin32' ? :
788 0 0 if ($proto eq 'file') { }
798 0 0 if ($proto eq 'file')
801 0 0 if $Treex::PML::IO::Debug
802 0 0 if ($Treex::PML::IO::ssh and -x $Treex::PML::IO::ssh and $proto =~ /^(ssh|fish|sftp)$/)
803 0 0 if $Treex::PML::IO::Debug
804 0 0 if ($uri =~ m[^\s*(?:ssh|sftp|fish):(?://)?([^-/][^/]*)(/.*)$]) { }
806 0 0 system("$Treex::PML::IO::ssh $Treex::PML::IO::ssh_opts " . quote_filename($host) . ' /bin/rm ' . quote_filename(quote_filename($file))) == 0 ? :
812 0 0 if ($Treex::PML::IO::kioclient and -x $Treex::PML::IO::kioclient)
814 0 0 if ($proto eq 'ssh')
817 0 0 system("$Treex::PML::IO::kioclient $Treex::PML::IO::kioclient_opts rm " . quote_filename($uri)) == 0 ? :
831 0 20 if $Treex::PML::IO::Debug
832 0 20 $^O eq 'MSWin32' ? :
840 0 0 if ($proto1 eq 'file' and $proto2 eq 'file') { }
842 0 0 unless -f $uri1
853 0 20 if ($proto ne $proto2)
856 20 0 if ($proto eq 'file')
858 0 20 unless -f $uri1
861 0 0 if $Treex::PML::IO::Debug
862 0 0 if ($Treex::PML::IO::ssh and -x $Treex::PML::IO::ssh and $proto =~ /^(ssh|fish|sftp)$/)
863 0 0 if $Treex::PML::IO::Debug
864 0 0 if ($uri1 =~ m[^\s*(?:ssh|sftp|fish):(?://)?([^-/][^/]*)(/.*)$]) { }
866 0 0 if ($uri2 =~ m[^\s*(?:ssh|sftp|fish):(?://)?([^-/][^/]*)(/.*)$] and $1 eq $host) { }
868 0 0 system("$Treex::PML::IO::ssh $Treex::PML::IO::ssh_opts " . quote_filename($host) . ' /bin/mv ' . quote_filename(quote_filename($file)) . ' ' . quote_filename(quote_filename($file2))) == 0 ? :
878 0 0 if ($Treex::PML::IO::kioclient and -x $Treex::PML::IO::kioclient)
880 0 0 if ($proto eq 'ssh')
884 0 0 system("$Treex::PML::IO::kioclient $Treex::PML::IO::kioclient_opts mv " . quote_filename($uri1) . ' ' . quote_filename($uri2)) == 0 ? :
909 170 31 if ($rw eq 'r') { }
31 0 elsif ($rw eq 'w') { }
930 5 196 if (ref $fh eq 'File::Temp')
932 5 0 if ($filename ne '')
933 0 5 if $Treex::PML::IO::Debug
937 0 5 unless $tmp->open($filename, 'wb')
946 0 201 if (&blessed($fh) and $fh->isa('IO::Zlib')) { }
952 0 201 if ($unlink)
975 0 122 if ($is_temporary and $local_file ne $uri)
976 0 0 unless (unlink $local_file)
1001 0 0 unless my $in = open_uri($src_uri)
1003 0 0 unless my $out = open_backend($target_uri, 'w')