Queue/Job.pm

filter: Statementstmt 78.2% 36 / 46 Branchbran 33.3% 2 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 14 / 20 Podpod 0.0% 0 / 15 totaltotal 59.7% 52 / 87 CC 5 SCAR 7.8
CC
5
Cov
73%
copy
6.0
processing
6.0
finished
2.1
CRAP 2.2
« Queue/SocketPair.pm ↑ Summary Queue/Direct.pm »
1 package Eixo::Queue::Job;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Eixo::Base::Clase;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Data::UUID;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 my $UUID_INSTANCE;
10  
11 BEGIN{
12 3 ▶ $UUID_INSTANCE = Data::UUID->new;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 }
14  
15 4 ▶sub WAITING { 'WAITING' }
Subroutine WAITING: called CC=1 SCAR=0.0
Pod undocumented
16 0 ▶sub PROCESSING { 'PROCESSING' }
Subroutine PROCESSING: not called CC=1 SCAR=6.9
Pod undocumented
17 2 ▶sub FINISHED { 'FINISHED' }
Subroutine FINISHED: called CC=1 SCAR=0.0
Pod undocumented
18 0 ▶sub ERROR { 'ERROR' }
Subroutine ERROR: not called CC=1 SCAR=6.9
Pod undocumented
19  
20  
21 sub ID{
22  
23 5 ▶ $UUID_INSTANCE->create_str;
Subroutine ID: called CC=1 SCAR=0.0
Pod undocumented
24 }
25  
26 3 my %NO_SERIALIZE = (
27 #id => 1
28 );
29  
30  
31 3 has(
32  
33 id=> undef,
34  
35 queue=>undef,
36  
37 status=>WAITING,
38  
39 creation_timestamp=>time,
40  
41 start_timestamp => undef,
42
43 termination_timestamp => undef,
44  
45 args=>undef,
46  
47 results=>undef,
48  
49 );
50  
51  
52 sub initialize {
53 4 ▶ my ($self,@args) = @_;
Subroutine initialize: called CC=1 SCAR=0.0
Pod undocumented
54  
55 4 $self->{id} = &ID;
56 4 $self->{args} = {};
57 4 $self->{results} = {};
58  
59 4 $self->SUPER::initialize(@args);
60
61 }
62  
63 sub to_hash {
64  
65 return {
66  
67 map {
68 8024 $_ => $_[0]->{$_}
69 }
70 grep{
71 8024 !$NO_SERIALIZE{$_}
72 }
73 1003 ▶ keys(%{ $_[0] })
Subroutine to_hash: called CC=1 SCAR=0.0
Pod undocumented
74
75 }
76 }
77  
78 sub TO_JSON {
79 1001 ▶ $_[0]->to_hash
Subroutine TO_JSON: called CC=1 SCAR=0.0
Pod undocumented
80 }
81  
82 sub copy{
83 0 ▶ my ($self, $j) = @_;
Subroutine copy: not called CC=2 SCAR=17.9
Pod undocumented
84  
85 0 $self->{$_} = $j->{$_} foreach(keys(%$j));
86 }
87  
88 sub processing{
89
90 0 ▶ $_[0]->start_timestamp(time) && $_[0]->status(PROCESSING)
Subroutine processing: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->start_timestamp(time) and $_[0]->status(PROCESSING()) 0 0 0
91 }
92  
93 sub finished{
94  
95 1 ▶ $_[0]->termination_timestamp(time) && $_[0]->status(FINISHED)
Subroutine finished: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->termination_timestamp(time) and $_[0]->status(FINISHED()) 1 0 1
96  
97 }
98  
99  
100 sub serialize{
101 1001 ▶ my ($self) = @_;
Subroutine serialize: called CC=1 SCAR=0.0
Pod undocumented
102  
103 1001 JSON->new->convert_blessed->utf8(0)->encode( $self )
104 }
105  
106 sub unserialize{
107 1001 ▶ my ($package, $data) = @_;
Subroutine unserialize: called CC=2 SCAR=7.6
Pod undocumented
108  
109 1001 ▶ if(ref($package)){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $package) 0 1001 1001
110 0 $package = ref($package);
111 }
112  
113 1001 bless(JSON->new->utf8->decode($data), $package);
114 }
115  
116 sub setArg{
117 0 ▶ my ($self, $key, $value) = @_;
Subroutine setArg: not called CC=1 SCAR=6.9
Pod undocumented
118  
119 0 $self->args->{$key} = $value;
120 }
121  
122 sub setResult{
123 0 ▶ my ($self, $key, $value) = @_;
Subroutine setResult: not called CC=1 SCAR=6.9
Pod undocumented
124  
125 0 $self->results->{$key} = $value;
126 }
127  
128  
129  
130 3 1;
« Queue/SocketPair.pm ↑ Summary Queue/Direct.pm »