lib/Serge/Sync/Plugin/TranslationService/zing.pm

filter: Statementstmt 27.0% 10 / 37 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 33.3% 3 / 9 Podpod 0.0% 0 / 6 totaltotal 20.0% 13 / 65 SCAR 37.0
CC
8
Cov
20%
validate_data
20.0
run_manage_py
12.0
pull_ts
6.0
CRAP 40.3
« lib/Serge/Sync/Plugin/TranslationService/pootle.pm ↑ Summary lib/Serge/Engine/Processor.pm »
1 package Serge::Sync::Plugin::TranslationService::zing;
2 1 ▶use parent Serge::Sync::Plugin::Base::TranslationService, Serge::Interface::SysCmdRunner;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Serge::Util qw(subst_macros);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub name {
9 0 ▶ return 'Zing translation server (https://evernote.github.io/zing/) synchronization plugin';
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
10 }
11  
12 sub init {
13 0 ▶ my $self = shift;
Subroutine init: not called CC=1 SCAR=6.9
Pod undocumented
14  
15 0 $self->SUPER::init(@_);
16  
17 0 $self->{optimizations} = 1; # set to undef to disable optimizations
18  
19 0 $self->merge_schema({
20 project_id => 'STRING',
21 executable => 'STRING',
22 });
23 }
24  
25 sub validate_data {
26 0 ▶ my ($self) = @_;
Subroutine validate_data: not called CC=4 SCAR=30.0
Pod undocumented
27  
28 0 $self->SUPER::validate_data;
29  
30 0 $self->{data}->{project_id} = subst_macros($self->{data}->{project_id});
31 0 $self->{data}->{executable} = subst_macros($self->{data}->{executable});
32  
33 0 ▶ $self->{data}->{executable} = $ENV{ZING_EXECUTABLE} || 'zing' unless defined $self->{data}->{executable};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"data"}{"executable"} 0 0 0
Condition0%0/2
$ENV{'ZING_EXECUTABLE'} || 'zing'
l!l
00
MC/DC0%0/1
$ENV{'ZING_EXECUTABLE'} || 'zing'
$ENV{'ZING_EXECUTABLE'}
Truth table0%0/2
A
A= $ENV{'ZING_EXECUTABLE'}
Aresult
11
00
34 0 ▶ die "'project_id' not defined" unless defined $self->{data}->{project_id};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"data"}{"project_id"} 0 0 0
35 }
36  
37 sub run_manage_py {
38 0 ▶ my ($self, $action, $langs, $capture) = @_;
Subroutine run_manage_py: not called CC=3 SCAR=24.8
Pod undocumented
39  
40 0 my $command = $action.' --project='.$self->{data}->{project_id};
41  
42 0 ▶ if ($langs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($langs) 0 0 0
43 0 foreach my $lang (sort @$langs) {
44 0 $lang =~ s/-(\w+)$/'_'.uc($1)/e; # convert e.g. 'pt-br' to 'pt_BR'
45 0 $command .= " --language=$lang";
46 }
47 }
48  
49 0 $command = $self->{data}->{executable}.' '.$command;
50 0 print "Running '$command'...\n";
51 0 return $self->run_cmd($command, $capture);
52 }
53  
54 sub pull_ts {
55 0 ▶ my ($self, $langs) = @_;
Subroutine pull_ts: not called CC=2 SCAR=17.9
Pod undocumented
56  
57 0 ▶ my $force = $self->{optimizations} ? '' : ' --overwrite';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'optimizations'} ? : 0 0 0
58  
59 0 return $self->run_manage_py('sync_stores --skip-missing'.$force, $langs);
60 }
61  
62 sub push_ts {
63 0 ▶ my ($self, $langs) = @_;
Subroutine push_ts: not called CC=2 SCAR=17.9
Pod undocumented
64  
65 0 ▶ my $force = $self->{optimizations} ? '' : ' --force';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'optimizations'} ? : 0 0 0
66  
67 0 $self->run_manage_py('update_stores'.$force, $langs);
68 }
69  
70 1 1;
« lib/Serge/Sync/Plugin/TranslationService/pootle.pm ↑ Summary lib/Serge/Engine/Processor.pm »