lib/Serge/Engine/Processor.pm

filter: Statementstmt 30.9% 13 / 42 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 3 totaltotal 26.5% 17 / 64 SCAR 35.8
CC
8
Cov
24%
run
42.0
new
12.0
dry_run
2.0
CRAP 36.0
« lib/Serge/Sync/Plugin/TranslationService/zing.pm ↑ Summary lib/Serge/Engine/Plugin/parse_master.pm »
1 package Serge::Engine::Processor;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Serge::Engine::Job;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 sub new {
8 0 ▶ my ($class, $engine, $config) = @_;
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
9  
10 0 ▶ die "engine object not provided" unless $engine;
Branch: 1 branch
BranchTrueFalseTotal
unless $engine 0 0 0
11 0 ▶ die "config object not provided" unless $config;
Branch: 1 branch
BranchTrueFalseTotal
unless $config 0 0 0
12  
13 0 my $self = {
14 engine => $engine,
15 config => $config,
16 };
17 0 bless $self, $class;
18  
19 0 return $self;
20 }
21  
22 sub run {
23 0 ▶ my ($self, $dry_run) = @_;
Subroutine run: not called CC=6 SCAR=37.4
Pod undocumented
24  
25 0 $self->{total_jobs} = 0;
26 0 $self->{skipped_jobs} = 0;
27 0 $self->{failed_jobs} = 0;
28  
29 0 foreach my $job_data (@{$self->{config}->{data}->{jobs}}) {
30 0 $self->{total_jobs}++;
31  
32 0 my $job;
33  
34 0 eval {
35 # create a job object — this will validate the job description,
36 # load plugins, validate their data and die if there's any error
37 0 $job = Serge::Engine::Job->new($job_data, $self->{engine}, $self->{config}->{base_dir});
38 0 ▶ print "Job definition is OK\n" if $dry_run;
Branch: 1 branch
BranchTrueFalseTotal
if $dry_run 0 0 0
39 };
40  
41 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
42 0 print "Job '$job_data->{id}' will be skipped: $@\n";
43 0 $self->{skipped_jobs}++;
44 0 next;
45 }
46  
47 0 eval {
48 0 ▶ $self->{engine}->process_job($job) unless $dry_run;
Branch: 1 branch
BranchTrueFalseTotal
unless $dry_run 0 0 0
49 };
50  
51 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
52 0 print "Exception occurred while processing job '$job_data->{id}': $@\n";
53 0 $self->{failed_jobs}++;
54 0 next;
55 }
56 }
57 }
58  
59 sub dry_run {
60 0 ▶ my $self = shift;
Subroutine dry_run: not called CC=1 SCAR=6.9
Pod undocumented
61  
62 0 $self->run(1);
63 }
64  
65 1 1;
« lib/Serge/Sync/Plugin/TranslationService/zing.pm ↑ Summary lib/Serge/Engine/Plugin/parse_master.pm »