blib/lib/XML/TMX/Reader.pm

filter: Statementstmt 76.8% 163 / 212 Branchbran 57.4% 62 / 108 Conditioncond 58.0% 29 / 50 MC/DCmcdc 20.6% 6 / 29 Subroutinesub 78.1% 25 / 32 Podpod 100% 6 / 6 totaltotal 66.5% 291 / 437 CC 79 SCAR 35.5
CC
79
Cov
69%
for_tu
92.9
__ANON__
16.6
__ANON__
12.0
CRAP 34.7
« blib/lib/XML/TMX/FromPO.pm ↑ Summary blib/lib/XML/TMX/Writer.pm »
1 package XML::TMX::Reader;
2 6 $XML::TMX::Reader::VERSION = '0.39';
3 # ABSTRACT: Perl extension for reading TMX files
4  
5 6 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 6 ▶use XML::DT;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 ▶use XML::TMX::Writer;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 ▶use File::BOM qw( open_bom);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 6 our @ISA = 'Exporter';
15 6 our @EXPORT_OK = qw();
16  
17  
18 8 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
19 8 my ($class, $file) = @_;
20  
21 8 ▶ return undef unless -f $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $file 1 7 8
22 7 my $self = bless {
23 encoding => _guess_encoding($file),
24 filename => $file,
25 ignore_markup => 1,
26 } => $class;
27 7 $self->_parse_header;
28 7 return $self;
29 }
30  
31 7 ▶sub _guess_encoding {
Subroutine _guess_encoding: called CC=3 SCAR=11.0
32 7 my $file = shift;
33 7 my $encoding = 'UTF-8';
34 7 my $enc = open_bom (my $fh, $file, ":utf8"); # or die "can't open $file ($!)";
35 7 ▶ $encoding= $enc if $enc;
Branch: 1 branch
BranchTrueFalseTotal
if $enc 0 7 7
36 7 my $line = <$fh>;
37 7 ▶ if ($line =~ /encoding=['"]([^'"]+)['"]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /encoding=['"]([^'"]+)['"]/) 5 2 7
38 5 $encoding = $1;
39 }
40 #print STDERR "Debug: defuse.ENC= $enc; enc=$encoding\n";
41 7 close $fh;
42 7 return $encoding;
43 }
44  
45 16 ▶sub _enc2bin{ my $enc=shift;
Subroutine _enc2bin: called CC=2 SCAR=7.4
46 16 ▶ if($enc =~ /utf.*8/i){
Branch: 1 branch
BranchTrueFalseTotal
if ($enc =~ /utf.*8/i) { } 16 0 16
47 16 $enc = "utf8"
48 }
49 0 else {$enc = "encoding($enc)"}
50 16 return ":$enc";
51 }
52  
53 7 ▶sub _parse_header {
Subroutine _parse_header: called CC=1 SCAR=0.0
54 7 my $self = shift;
55  
56 7 my $header = "";
57 {
58 7 my $fh;
59 7 local $/ = "<body>";
60 7 open_bom($fh, $self->{filename},_enc2bin($self->{encoding})) ;# or die "$!";
61 #print STDERR "Debug2: defuse.ENC= $!- ; enc=$self->{encoding}\n";
62 7 $header = <$fh>;
63 7 close $fh;
64 }
65  
66 7 $header =~ s/^.*(<header)/$1/s;
67 7 $header =~ s/(<\/header>).*$/$1/s;
68  
69 7 $header =~ s!(<header[^/]+/>).*$!$1!s;
70  
71 dtstring($header => (
72 7 ▶ 'header' => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
73 7 $self->{header}{$_} = $v{$_} for (keys %v);
74 },
75 16 ▶ 'prop' => sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
76 16 ▶ $v{type} ||= "_";
Condition50%1/2
$XML::TMX::Reader::v{"type"} ||= "_"
l!l
160
MC/DC0%0/1
$XML::TMX::Reader::v{"type"} ||= "_"
$XML::TMX::Reader::v{"type"}
Truth table50%1/2
A
A= $XML::TMX::Reader::v{"type"}
Aresult
11
00
77 16 push @{$self->{header}{-prop}{$v{type}}}, $c;
78 },
79 16 ▶ 'note' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
80 16 push @{$self->{header}{-note}}, $c;
81 },
82 7 ));
83 }
84  
85  
86 0 ▶sub ignore_markup {
Subroutine ignore_markup: not called CC=2 SCAR=17.9
Pod documented
87 0 my ($self, $opt) = @_;
88 0 ▶ $opt = 1 unless defined $opt;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opt 0 0 0
89 0 $self->{ignore_markup} = $opt;
90 }
91  
92  
93 2 ▶sub languages {
Subroutine languages: called CC=1 SCAR=0.0
Pod documented
94 2 my $self = shift;
95 2 my %languages = ();
96 $self->for_tu({proc_tu => 100},
97 13 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
98 13 my $tu = shift;
99 13 for ( keys %$tu ) {
100 52 ▶ $languages{$_}++ unless m/^-/;
Branch: 1 branch
BranchTrueFalseTotal
unless /^-/ 26 26 52
101 }
102 2 } );
103 2 return keys %languages;
104 }
105  
106  
107 12 ▶sub _merge_notes {
Subroutine _merge_notes: called CC=4 SCAR=13.9
108 12 my ($orig, $new) = @_;
109  
110 12 ▶ $orig //= [];
Condition100%2/2
$orig //= []
l!l
75
MC/DC100%1/1
$orig //= []
$orig
Truth table100%2/2
A
A= $orig
Aresult
11
00
111 12 ▶ $orig = [$orig] unless ref $orig eq "ARRAY";
Branch: 1 branch
BranchTrueFalseTotal
unless ref $orig eq "ARRAY" 5 7 12
112 12 ▶ $new = [$new] unless ref $new eq "ARRAY";
Branch: 1 branch
BranchTrueFalseTotal
unless ref $new eq "ARRAY" 8 4 12
113  
114 12 push @$orig => grep { my $x = $_; !grep { $x eq $_} @$orig } @$new;
115  
116 12 return $orig;
117 }
118  
119 5 ▶sub _merge_props {
Subroutine _merge_props: called CC=6 SCAR=19.6
120 5 my ($orig, $new) = @_;
121 5 ▶ die "-prop should be hash" if $orig and ref $orig ne "HASH";
Branch: 1 branch
BranchTrueFalseTotal
if $orig and ref $orig ne "HASH" 0 5 5
Condition66%2/3
$orig and ref $orig ne "HASH"
!ll&&!rl&&r
140
MC/DC0%0/2
$orig and ref $orig ne "HASH"
$orig ref $orig ne "HASH"
Truth table66%2/3
A and B
A= $origB= ref $orig ne "HASH"
ABresult
0X0
100
111
122 5 ▶ die "-prop should be hash" if $new and ref $new ne "HASH";
Branch: 1 branch
BranchTrueFalseTotal
if $new and ref $new ne "HASH" 0 5 5
Condition33%1/3
$new and ref $new ne "HASH"
!ll&&!rl&&r
050
MC/DC0%0/2
$new and ref $new ne "HASH"
$new ref $new ne "HASH"
Truth table33%1/3
A and B
A= $newB= ref $new ne "HASH"
ABresult
0X0
100
111
123  
124 5 for my $key (keys %$new) {
125 6 $orig->{$key} = _merge_notes($orig->{$key}, $new->{$key});
126 }
127 5 return $orig;
128 }
129  
130 4 ▶sub _compute_header {
Subroutine _compute_header: called CC=3 SCAR=12.3
131 4 my ($current, $conf) = @_;
132 4 my %header = %$current;
133 4 ▶ if (exists($conf->{-note})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $conf->{"-note"}) 0 4 4
134 0 $header{-note} = _merge_notes($header{-note}, $conf->{-note});
135 }
136 4 ▶ if (exists($conf->{-prop})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $conf->{"-prop"}) 0 4 4
137 0 $header{-prop} = _merge_props($header{-prop}, $conf->{-prop});
138 }
139 4 return \%header;
140 }
141  
142 9 ▶sub for_tu {
Subroutine for_tu: called CC=36 SCAR=45.3
Pod documented
143 9 my $self = shift;
144 9 my $conf = { -header => 1 };
145 9 my $i = 0;
146  
147 9 ▶ ref($_[0]) eq "HASH" and $conf = {%$conf , %{shift(@_)}};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq "HASH" and $conf = {%$conf, %{shift @_;}} 6 3 9
148  
149 9 my $code = shift;
150 9 ▶ die "invalid processor" unless ref($code) eq "CODE";
Branch: 1 branch
BranchTrueFalseTotal
unless ref $code eq "CODE" 0 9 9
151  
152 9 local $/;
153  
154 9 my $outputingTMX = 0;
155 9 my $tmx;
156 my $data;
157 9 my $gen=0;
158 my %h = (
159 -type => { tu => 'SEQ', tuv => 'SEQ' },
160 59 ▶ tu => sub {
Subroutine __ANON__: called CC=13 SCAR=28.1
161 59 my $tu;
162 59 for my $va (@$c) {
163 306 ▶ if ($va->[0] eq "-prop") {
Branch: 2 branches
BranchTrueFalseTotal
if ($va->[0] eq '-prop') { } 87 219 306
elsif ($va->[0] eq '-note') { } 101 118 219
164 87 push @{$tu->{$va->[0]}{$va->[1]}}, $va->[2]
165 } elsif ($va->[0] eq "-note") {
166 101 push @{$tu->{$va->[0]}}, $va->[1]
167 } else {
168 118 $tu->{$va->[0]} = $va->[1]
169 }
170 }
171 59 my ($ans, $v) = $code->($tu, \%v);
172  
173 # Check if the user wants to create a TMX and
174 # forgot to say us
175 59 ▶ if (!$outputingTMX && $ans && ref($ans) eq "HASH") {
Branch: 1 branch
BranchTrueFalseTotal
if (not $outputingTMX and $ans and ref $ans eq "HASH") 0 59 59
Condition83%5/6
not $outputingTMX and $ans and ref $ans eq "HASH"
!ll&&!rl&&r
42170
not $outputingTMX and $ans
!ll&&!rl&&r
261617
MC/DC0%0/3
not $outputingTMX and $ans and ref $ans eq "HASH"
not $outputingTMX $ans ref $ans eq "HASH"
Truth table75%3/4
not(A) and B and C
A= not $outputingTMXB= $ansC= ref $ans eq "HASH"
ABCresult
0XX0
10X0
1100
1111
176 0 $outputingTMX = 1;
177 0 $tmx = XML::TMX::Writer->new();
178 0 ▶ if ($conf->{-header}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"-header"}) 0 0 0
179 0 my $header = _compute_header($self->{header}, $conf);
180 0 $tmx->start_tmx(encoding => $self->{encoding}, %$header);
181 }
182 }
183 # Add the translation unit
184 59 ▶ if ($ans && ref($ans) eq "HASH") {
Branch: 1 branch
BranchTrueFalseTotal
if ($ans and ref $ans eq "HASH") 20 39 59
Condition100%3/3
$ans and ref $ans eq "HASH"
!ll&&!rl&&r
221720
MC/DC100%2/2
$ans and ref $ans eq "HASH"
$ans ref $ans eq "HASH"
Truth table100%3/3
A and B
A= $ansB= ref $ans eq "HASH"
ABresult
0X0
100
111
185 20 $gen++;
186 20 ▶ %v = %$v if ($v && ref($v) eq "HASH");
Branch: 1 branch
BranchTrueFalseTotal
if $v and ref $v eq "HASH" 0 20 20
Condition33%1/3
$v and ref $v eq "HASH"
!ll&&!rl&&r
2000
MC/DC0%0/2
$v and ref $v eq "HASH"
$v ref $v eq "HASH"
Truth table33%1/3
A and B
A= $vB= ref $v eq "HASH"
ABresult
0X0
100
111
187  
188 20 my %ans = (%v, %$ans);
189 20 ▶ $ans{"-n"}=$i if $conf->{n} ;
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"n"} 0 20 20
190 20 $tmx->add_tu(-verbatim => $conf->{-verbatim}, %ans);
191 }
192 },
193  
194 118 ▶ tuv => sub {
Subroutine __ANON__: called CC=7 SCAR=20.8
195 118 my $tuv;
196 118 for my $v (@$c) {
197 154 ▶ if ($v->[0] eq "-prop") {
Branch: 3 branches
BranchTrueFalseTotal
if ($v->[0] eq '-prop') { } 18 136 154
elsif ($v->[0] eq '-note') { } 18 118 136
elsif ($v->[0] eq '-cdata') { } 0 118 118
198 18 push @{$tuv->{$v->[0]}{$v->[1]}}, $v->[2]
199 } elsif ($v->[0] eq "-note") {
200 18 push @{$tuv->{$v->[0]}}, $v->[1]
201 } elsif ($v->[0] eq "-cdata") {
202 0 $tuv->{-iscdata} = 1;
203 0 $tuv->{-seg} = $v->[1];
204 } else {
205 118 $tuv->{-seg} = $v->[0];
206 }
207 }
208 118 ▶ [ $v{lang} || $v{'xml:lang'} || "_" => $tuv ]
Condition40%2/5
$XML::TMX::Reader::v{'lang'} || $XML::TMX::Reader::v{'xml:lang'} || '_'
l!l
1180
$XML::TMX::Reader::v{"lang"} or $XML::TMX::Reader::v{"xml:lang"}
l!l&&r!l&&!r
01180
MC/DC0%0/2
$XML::TMX::Reader::v{'lang'} || $XML::TMX::Reader::v{'xml:lang'} || '_'
$XML::TMX::Reader::v{"lang"} $XML::TMX::Reader::v{"xml:lang"}
Truth table33%1/3
A or B
A= $XML::TMX::Reader::v{"lang"}B= $XML::TMX::Reader::v{"xml:lang"}
ABresult
1X1
011
000
209 },
210 105 ▶ prop => sub { ["-prop", $v{type} || "_", $c] },
Subroutine __ANON__: called CC=2 SCAR=7.6
Condition50%1/2
$XML::TMX::Reader::v{'type'} || '_'
l!l
1050
MC/DC0%0/1
$XML::TMX::Reader::v{'type'} || '_'
$XML::TMX::Reader::v{'type'}
Truth table50%1/2
A
A= $XML::TMX::Reader::v{'type'}
Aresult
11
00
211 119 ▶ note => sub { ["-note" , $c] },
Subroutine __ANON__: called CC=1 SCAR=0.0
212 118 ▶ seg => sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
213 118 ▶ return ($v{iscdata}) ? [ -cdata => $c ] : [ $c ]
Branch: 1 branch
BranchTrueFalseTotal
$XML::TMX::Reader::v{'iscdata'} ? : 0 118 118
214 },
215 0 ▶ -cdata => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
216 0 father->{'iscdata'} = 1; $c },
217 0 ▶ hi => sub { $self->{ignore_markup}?$c:toxml },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$self->{'ignore_markup'} ? : 0 0 0
218 0 ▶ ph => sub { $self->{ignore_markup}?$c:toxml },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$self->{'ignore_markup'} ? : 0 0 0
219 9 );
220  
221  
222 9 $/ = "\n";
223  
224 9 $h{-outputenc} = $h{-inputenc} = $self->{encoding};
225  
226 9 my $resto = "";
227 ## Go through the header...
228 9 my $fh;
229 9 open_bom($fh, $self->{filename},_enc2bin($self->{encoding})) ;# or die "$!";
230 #print STDERR "Debug2: defuse.ENC= $! ; enc=" ,_enc2bin($self->{encoding}),"\n";
231 9 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 87 0 87
232 87 ▶ next if /^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
if /^\s*$/ 12 75 87
233 75 ▶ last if /<body\b/;
Branch: 1 branch
BranchTrueFalseTotal
if /<body\b/ 9 66 75
234 }
235  
236 9 ▶ if (m!(.*?)(<body.*?>)(.*)!s) {
Branch: 1 branch
BranchTrueFalseTotal
if (/(.*?)(<body.*?>)(.*)/s) 9 0 9
237 9 $resto = $3;
238 }
239  
240  
241 # If we have an output filename, user wants to output a TMX
242 9 ▶ $conf->{-output} = $conf->{output} if defined($conf->{output});
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"output"} 3 6 9
243 9 ▶ if (defined($conf->{-output})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conf->{"-output"}) 4 5 9
244 4 $outputingTMX = 1;
245 4 $tmx = XML::TMX::Writer->new();
246 4 ▶ if ($conf->{-header}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"-header"}) 4 0 4
247 4 my $header = _compute_header($self->{header}, $conf);
248 $tmx->start_tmx(encoding => $self->{encoding},
249 -output => $conf->{-output},
250 4 %$header);
251 }
252 }
253  
254 9 $/ = "</tu>";
255 9 ▶ $conf->{-verbose}++ if $conf->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"verbose"} 0 9 9
256 9 ▶ print STDERR "." if $conf->{-verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"-verbose"} 0 9 9
257 9 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 68 0 68
258 68 ▶ ($_ = $resto . $_ and $resto = "" ) if $resto;
Branch: 1 branch
BranchTrueFalseTotal
if $resto 9 59 68
Condition50%3/6
$resto && (($_ = $resto . $_) && ($resto = ''))
!ll&&!rl&&r
5990
$_ = $resto . $_ and $resto = ""
!ll&&!rl&&r
090
MC/DC0%0/3
$resto && (($_ = $resto . $_) && ($resto = ''))
$resto $_ = $resto . $_ $resto = ""
Truth table0%0/4
A && B and C
A= $restoB= $_ = $resto . $_C= $resto = ""
ABCresult
0XX0
10X0
1100
1111
259 68 ▶ last if /<\/body>/;
Branch: 1 branch
BranchTrueFalseTotal
if m[</body>] 8 60 68
260 60 $i++;
261 60 ▶ print STDERR "\r$i" if $conf->{-verbose} && !($i % 10);
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"-verbose"} and not $i % 10 0 60 60
Condition33%1/3
$conf->{"-verbose"} and not $i % 10
!ll&&!rl&&r
6000
MC/DC0%0/2
$conf->{"-verbose"} and not $i % 10
$conf->{"-verbose"} not $i % 10
Truth table33%1/3
A and not(B)
A= $conf->{"-verbose"}B= not $i % 10
ABresult
0X0
100
111
262 60 ▶ last if defined $conf->{proc_tu} && $i > $conf->{proc_tu} ;
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"proc_tu"} and $i > $conf->{"proc_tu"} 1 59 60
Condition100%3/3
defined $conf->{"proc_tu"} and $i > $conf->{"proc_tu"}
!ll&&!rl&&r
40191
MC/DC100%2/2
defined $conf->{"proc_tu"} and $i > $conf->{"proc_tu"}
defined $conf->{"proc_tu"} $i > $conf->{"proc_tu"}
Truth table100%3/3
A and B
A= defined $conf->{"proc_tu"}B= $i > $conf->{"proc_tu"}
ABresult
0X0
100
111
263 59 ▶ last if defined $conf->{gen_tu} && $gen > $conf->{gen_tu};
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"gen_tu"} and $gen > $conf->{"gen_tu"} 0 59 59
Condition66%2/3
defined $conf->{"gen_tu"} and $gen > $conf->{"gen_tu"}
!ll&&!rl&&r
5360
MC/DC0%0/2
defined $conf->{"gen_tu"} and $gen > $conf->{"gen_tu"}
defined $conf->{"gen_tu"} $gen > $conf->{"gen_tu"}
Truth table66%2/3
A and B
A= defined $conf->{"gen_tu"}B= $gen > $conf->{"gen_tu"}
ABresult
0X0
100
111
264 # next if defined $conf->{patt} && !m/$conf->{patt}/ ;
265  
266 59 ▶ if (defined $conf->{patt}){ ## FIXME untested
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conf->{"patt"}) 0 59 59
267 0 ▶ if(ref($conf->{patt})){ ## EN=>/cat/ PT=>/gato/
Branch: 1 branch
BranchTrueFalseTotal
if (ref $conf->{'patt'}) { } 0 0 0
268 0 my $ok = 1;
269 0 my $textli = "";
270 0 for my $li (keys %{$conf->{patt}}){
271 0 my $patli= $conf->{patt}{$li};
272 0 ▶ if (m!lang=["']$li['"](.*?)</tuv>!is ) { $textli = $1 };
Branch: 1 branch
BranchTrueFalseTotal
if (m[lang=["']${li}['"](.*?)</tuv>]is) 0 0 0
273 0 ▶ $ok &&= ($textli =~ /$patli/)
Condition0%0/3
$ok &&= $textli =~ /$patli/
!ll&&!rl&&r
000
MC/DC0%0/2
$ok &&= $textli =~ /$patli/
$ok $textli =~ /$patli/
Truth table0%0/3
A &&= B
A= $okB= $textli =~ /$patli/
ABresult
0X0
100
111
274 }
275 0 ▶ next unless $ok
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 0 0
276 }
277 else { ## /cat.*/
278 0 ▶ next if not m/$conf->{patt}/ ;
Branch: 1 branch
BranchTrueFalseTotal
unless /$conf->{"patt"}/ 0 0 0
279 }
280 }
281 ####
282 # This can't be done. Not sure why it was being done.
283 # So, please, unless you know the implications for tagged crpora
284 # do not uncomment it.
285 # s/\>\s+/>/;
286 59 undef($data);
287 59 ▶ if ($conf->{'-raw'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{'-raw'}) { } 0 59 59
288 0 my $ans = $code->($_);
289 0 ▶ if ($conf->{-output}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"-output"}) 0 0 0
290 0 ▶ $ans->{"-n"}=$i if $conf->{n} ;
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"n"} 0 0 0
291 0 $tmx->add_tu(-raw => $ans);
292 }
293 } else {
294 59 eval { dtstring($_, %h) } ; ## dont die in invalid XML
295 59 ▶ warn $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 59 59
296 }
297 }
298 9 ▶ print STDERR "\r$i\n" if $conf->{-verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"-verbose"} 0 9 9
299 9 close $fh;
300  
301  
302 9 ▶ $tmx->end_tmx if $conf->{-header} && $outputingTMX;
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"-header"} and $outputingTMX 4 5 9
Condition66%2/3
$conf->{"-header"} and $outputingTMX
!ll&&!rl&&r
054
MC/DC50%1/2
$conf->{"-header"} and $outputingTMX
$conf->{"-header"} $outputingTMX
Truth table66%2/3
A and B
A= $conf->{"-header"}B= $outputingTMX
ABresult
0X0
100
111
303 }
304  
305  
306 0 ▶sub to_html {
Subroutine to_html: not called CC=1 SCAR=6.9
Pod documented
307 0 my $self = shift;
308 0 my %opt = @_;
309 0 my @ls=$self->languages;
310 0 my $html="<table><tr>". join("\n",map{"<td>$_</td>"} @ls) ."</tr>\n";
311 0 ▶ $self->for_tu(sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
312 0 my ($langs, $opts) = @_;
313 0 my $ret = ""; # "<table>";
314 0 for (@ls) {
315 0 ▶ if( defined $langs->{$_}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $langs->{$_}) { } 0 0 0
316 0 $ret .= "\n\t<td l='$_'>$langs->{$_}{-seg}</td>"
317 }
318 else {
319 0 $ret .= "\n\t<td l='$_'></td>"
320 }
321 }
322  
323 #if ($opt{icons}) {
324 # $ret .= "<img src=\"/icons/flags/".lc($_).".png\" alt=\"$_\"/>"
325 # } else {
326 # $ret .= "$_"
327 # }
328 # $ret .= "</td><td>$langs->{$_}{-seg}</td></tr>\n"
329 0 $html.= "<tr>$ret\n</tr>\n";
330 0 return ""
331 }
332 0 );
333 0 return $html;
334 }
335  
336 0 ▶sub for_tu2 {
Subroutine for_tu2: not called CC=1 SCAR=6.9
Pod documented
337 0 warn "Please update your code to use 'for_tu'\n";
338 0 &for_tu;
339 }
340  
341  
342 6 1;
343  
344 __END__
« blib/lib/XML/TMX/FromPO.pm ↑ Summary blib/lib/XML/TMX/Writer.pm »