bin/po2json

filter: Statementstmt 100% 30 / 30 Branchbran 100% 10 / 10 Conditioncond 100% 9 / 9 MC/DCmcdc 100% 5 / 5 Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 58 / 58 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« bin/locale-simple ↑ Summary
1 #!/usr/bin/env perl
2 # PODNAME: po2json
3 # ABSTRACT: Convert a PO file to the JSON data for Locale::Simple in the browser
4 12 our $VERSION = '0.200';
5  
6 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 12 ▶use File::Basename ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 12 ▶use Locale::Simple::PO2JSON qw( po2data data2json );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 12 my $usage = "Usage: po2json [-p] FILE.po > FILE.json\n"
13 . " -p indent the output and wrap it in the file name as domain\n";
14  
15 12 my $pretty = 0;
16 12 ▶if ( @ARGV and $ARGV[0] eq '-p' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@ARGV and $ARGV[0] eq "-p") 3 9 12
Condition100%3/3
@ARGV and $ARGV[0] eq "-p"
!ll&&!rl&&r
183
MC/DC100%2/2
@ARGV and $ARGV[0] eq "-p"
@ARGV $ARGV[0] eq "-p"
Truth table100%3/3
A and B
A= @ARGVB= $ARGV[0] eq "-p"
ABresult
0X0
100
111
17 3 shift @ARGV;
18 3 $pretty = 1;
19 }
20 # Deprecated: one line on STDERR, STDOUT stays the clean JSON. Only -p has an
21 # exact replacement; the plain form has none, the notice says what differs.
22 12 ▶my $instead = $pretty
Branch: 1 branch
BranchTrueFalseTotal
$pretty ? : 3 9 12
23 ? 'locale-simple po2json --pretty FILE.po'
24 : 'locale-simple po2json FILE.po (no exact equivalent: it wraps the data as { "FILE": ... })';
25 12 print STDERR 'po2json is deprecated, use: ' . $instead . "\n";
26 12 ▶if ( !@ARGV or $ARGV[0] =~ /^(?:-h|--help)$/ or @ARGV > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @ARGV or $ARGV[0] =~ /^(?:-h|--help)$/ or @ARGV > 1) 6 6 12
Condition100%6/6
not @ARGV or $ARGV[0] =~ /^(?:-h|--help)$/ or @ARGV > 1
l!l&&r!l&&!r
516
not @ARGV or $ARGV[0] =~ /^(?:-h|--help)$/
l!l&&r!l&&!r
147
MC/DC100%3/3
not @ARGV or $ARGV[0] =~ /^(?:-h|--help)$/ or @ARGV > 1
not @ARGV $ARGV[0] =~ /^(?:-h|--help)$/ @ARGV > 1
Truth table100%4/4
not(A) or B or C
A= not @ARGVB= $ARGV[0] =~ /^(?:-h|--help)$/C= @ARGV > 1
ABCresult
1XX1
01X1
0011
0000
27 6 print STDERR $usage;
28 6 exit 1;
29 }
30  
31 6 my ($file) = @ARGV;
32 6 my $json = eval {
33 6 ▶ $pretty
Branch: 1 branch
BranchTrueFalseTotal
$pretty ? : 2 4 6
34 ? data2json( po2data( $file, domain => File::Basename::basename( $file, '.po', '.pot' ) ), pretty => 1 )
35 : data2json( po2data($file) );
36 };
37 6 ▶if ( !defined $json ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $json) 2 4 6
38 2 print STDERR $@;
39 2 exit 1;
40 }
41 4 print $json, "\n";
42  
43 __END__
« bin/locale-simple ↑ Summary