blib/lib/PerlIO/via/Babelfish.pm

filter: Statementstmt 83.3% 30 / 36 Branchbran 37.5% 3 / 8 Conditioncond 28.5% 2 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 3 totaltotal 62.1% 41 / 66 CC 9 SCAR 15.5
CC
9
Cov
69%
FILL
12.0
import
5.3
FLUSH
2.0
CRAP 4.7
↑ Summary
1 # $Id: Babelfish.pm,v 1.2 2003/09/03 15:11:03 cvspub Exp $
2 package PerlIO::via::Babelfish;
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 our $VERSION = '0.01';
5  
6 1 our $fish;
7 1 our @setting_keys = qw(source target proxy agent);
8 1 our %setting;
9  
10 1 ▶use WWW::Babelfish;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶sub import {
Subroutine import: called CC=5 SCAR=16.7
13 1 shift;
14 1 ▶ my $arg = ref($_[0]) ? $_[0] : {@_};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 1 1
15 1 foreach my $s ( @setting_keys ){
16 4 $setting{$s} = $arg->{$s};
17 }
18 1 ▶ $setting{agent} ||= 'Mozilla/8.0';
Condition50%1/2
$PerlIO::via::Babelfish::setting{"agent"} ||= "Mozilla/8.0"
l!l
01
MC/DC0%0/1
$PerlIO::via::Babelfish::setting{"agent"} ||= "Mozilla/8.0"
$PerlIO::via::Babelfish::setting{"agent"}
Truth table50%1/2
A
A= $PerlIO::via::Babelfish::setting{"agent"}
Aresult
11
00
19 1 ▶ $setting{proxy} ||= 'proxy.ntu.edu.tw:3128';
Condition50%1/2
$PerlIO::via::Babelfish::setting{"proxy"} ||= "proxy.ntu.edu.tw:3128"
l!l
01
MC/DC0%0/1
$PerlIO::via::Babelfish::setting{"proxy"} ||= "proxy.ntu.edu.tw:3128"
$PerlIO::via::Babelfish::setting{"proxy"}
Truth table50%1/2
A
A= $PerlIO::via::Babelfish::setting{"proxy"}
Aresult
11
00
20 $fish = new WWW::Babelfish(
21 'agent' => $setting{agent},
22 'proxy' => $setting{proxy},
23 1 );
24 }
25  
26 0 ▶sub unimport {
Subroutine unimport: not called CC=1 SCAR=6.9
27 0 undef $fish;
28 }
29  
30 1 ▶sub PUSHED {
Subroutine PUSHED: called CC=1 SCAR=0.0
Pod undocumented
31 1 my ($class,$mode,$fh) = @_;
32 1 my $buf = '';
33 1 return bless \$buf,$class;
34 }
35  
36 0 ▶sub FILL {
Subroutine FILL: not called CC=3 SCAR=24.8
Pod undocumented
37 0 my ($obj,$fh) = @_;
38 0 my $line = <$fh>;
39 0 ▶ if( ref($fish) and defined $line ){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $PerlIO::via::Babelfish::fish and defined $line) { } 0 0 0
Condition0%0/3
ref $PerlIO::via::Babelfish::fish and defined $line
!ll&&!rl&&r
000
MC/DC0%0/2
ref $PerlIO::via::Babelfish::fish and defined $line
ref $PerlIO::via::Babelfish::fish defined $line
Truth table0%0/3
A and B
A= ref $PerlIO::via::Babelfish::fishB= defined $line
ABresult
0X0
100
111
40 return $fish->translate(
41 'source' => $setting{source},
42 'destination' => $setting{target},
43 0 'text' => $line,
44 'delimiter' => '',
45 );
46 }
47 else{
48 0 return undef;
49 }
50 }
51  
52 1 ▶sub WRITE {
Subroutine WRITE: called CC=2 SCAR=7.0
53 1 my ($obj,$buf,$fh) = @_;
54 1 my $bt;
55 $$obj .= $bt = ref($fish) ?
56 $fish->translate(
57 'source' => $setting{source},
58 'destination' => $setting{target},
59 1 ▶ 'text' => $buf,
Branch: 1 branch
BranchTrueFalseTotal
ref $PerlIO::via::Babelfish::fish ? : 0 1 1
60 'delimiter' => '',
61 ) :
62 $buf;
63 1 $obj->FLUSH($fh);
64 1 return length($bt);
65 }
66  
67 3 ▶sub FLUSH {
Subroutine FLUSH: called CC=2 SCAR=7.0
Pod undocumented
68 3 my ($obj,$fh) = @_;
69 3 ▶ print $fh $$obj or return -1;
Branch: 1 branch
BranchTrueFalseTotal
print $fh $$obj or return -1 3 0 3
70 3 $$obj = '';
71 3 return 0;
72 }
73  
74  
75  
76  
77 1 1;
78 __END__
↑ Summary