| 1 | package Eixo::Queue::Job; | ||||||||||
| 2 | |||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use Eixo::Base::Clase; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 4 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 4 | ▶ | use Data::UUID; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 4 | ▶ | use Eixo::Queue::JobCifrador; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 4 | my $UUID_INSTANCE; | |||||||||
| 12 | |||||||||||
| 13 | 4 | ▶ | BEGIN{ | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 4 | $UUID_INSTANCE = Data::UUID->new; | |||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | 5 | ▶ | sub WAITING { 'WAITING' } | ||||||||
|
Subroutine
WAITING: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 18 | 0 | ▶ | sub PROCESSING { 'PROCESSING' } | ||||||||
|
Subroutine
PROCESSING: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 19 | 2 | ▶ | sub FINISHED { 'FINISHED' } | ||||||||
|
Subroutine
FINISHED: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 20 | 0 | ▶ | sub ERROR { 'ERROR' } | ||||||||
|
Subroutine
ERROR: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 21 | |||||||||||
| 22 | |||||||||||
| 23 | 8 | ▶ | sub ID{ | ||||||||
|
Subroutine
ID: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 24 | |||||||||||
| 25 | 8 | $UUID_INSTANCE->create_str; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 4 | my %NO_SERIALIZE = ( | |||||||||
| 29 | #id => 1 | ||||||||||
| 30 | ); | ||||||||||
| 31 | |||||||||||
| 32 | |||||||||||
| 33 | 4 | has( | |||||||||
| 34 | |||||||||||
| 35 | id=> undef, | ||||||||||
| 36 | |||||||||||
| 37 | queue=>undef, | ||||||||||
| 38 | |||||||||||
| 39 | status=>WAITING, | ||||||||||
| 40 | |||||||||||
| 41 | creation_timestamp=>time, | ||||||||||
| 42 | |||||||||||
| 43 | start_timestamp => undef, | ||||||||||
| 44 | |||||||||||
| 45 | termination_timestamp => undef, | ||||||||||
| 46 | |||||||||||
| 47 | args=>undef, | ||||||||||
| 48 | |||||||||||
| 49 | results=>undef, | ||||||||||
| 50 | |||||||||||
| 51 | ); | ||||||||||
| 52 | |||||||||||
| 53 | |||||||||||
| 54 | 7 | ▶ | sub initialize { | ||||||||
|
Subroutine
initialize: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 55 | 7 | my ($self,@args) = @_; | |||||||||
| 56 | |||||||||||
| 57 | 7 | $self->{id} = &ID; | |||||||||
| 58 | 7 | $self->{args} = {}; | |||||||||
| 59 | 7 | $self->{results} = {}; | |||||||||
| 60 | |||||||||||
| 61 | 7 | $self->SUPER::initialize(@args); | |||||||||
| 62 | |||||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 1004 | ▶ | sub to_hash { | ||||||||
|
Subroutine
to_hash: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 66 | |||||||||||
| 67 | return { | ||||||||||
| 68 | |||||||||||
| 69 | map { | ||||||||||
| 70 | 8032 | $_ => $_[0]->{$_} | |||||||||
| 71 | } | ||||||||||
| 72 | grep{ | ||||||||||
| 73 | 8032 | !$NO_SERIALIZE{$_} | |||||||||
| 74 | } | ||||||||||
| 75 | 1004 | keys(%{ $_[0] }) | |||||||||
| 76 | |||||||||||
| 77 | } | ||||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | 1001 | ▶ | sub TO_JSON { | ||||||||
|
Subroutine
TO_JSON: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 81 | 1001 | $_[0]->to_hash | |||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | 0 | ▶ | sub copy{ | ||||||||
|
Subroutine
copy: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 85 | 0 | my ($self, $j) = @_; | |||||||||
| 86 | |||||||||||
| 87 | 0 | $self->{$_} = $j->{$_} foreach(keys(%$j)); | |||||||||
| 88 | } | ||||||||||
| 89 | |||||||||||
| 90 | 0 | ▶ | sub processing{ | ||||||||
|
Subroutine
processing: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 91 | |||||||||||
| 92 | 0 | ▶ | $_[0]->start_timestamp(time) && $_[0]->status(PROCESSING) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | 1 | ▶ | sub finished{ | ||||||||
|
Subroutine
finished: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||
| 96 | |||||||||||
| 97 | 1 | ▶ | $_[0]->termination_timestamp(time) && $_[0]->status(FINISHED) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 98 | |||||||||||
| 99 | } | ||||||||||
| 100 | |||||||||||
| 101 | |||||||||||
| 102 | 1001 | ▶ | sub serialize{ | ||||||||
|
Subroutine
serialize: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 103 | 1001 | my ($self) = @_; | |||||||||
| 104 | |||||||||||
| 105 | 1001 | JSON->new->convert_blessed->encode( $self ) | |||||||||
| 106 | } | ||||||||||
| 107 | |||||||||||
| 108 | 1001 | ▶ | sub unserialize{ | ||||||||
|
Subroutine
unserialize: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||
| 109 | 1001 | my ($package, $data) = @_; | |||||||||
| 110 | |||||||||||
| 111 | 1001 | ▶ | if(ref($package)){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 112 | 0 | $package = ref($package); | |||||||||
| 113 | } | ||||||||||
| 114 | |||||||||||
| 115 | 1001 | bless(JSON->new->decode($data), $package); | |||||||||
| 116 | } | ||||||||||
| 117 | |||||||||||
| 118 | 0 | ▶ | sub setArg{ | ||||||||
|
Subroutine
setArg: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 119 | 0 | my ($self, $key, $value) = @_; | |||||||||
| 120 | |||||||||||
| 121 | 0 | $self->args->{$key} = $value; | |||||||||
| 122 | } | ||||||||||
| 123 | |||||||||||
| 124 | 0 | ▶ | sub setResult{ | ||||||||
|
Subroutine
setResult: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 125 | 0 | my ($self, $key, $value) = @_; | |||||||||
| 126 | |||||||||||
| 127 | 0 | $self->results->{$key} = $value; | |||||||||
| 128 | } | ||||||||||
| 129 | |||||||||||
| 130 | 0 | ▶ | sub removeResult{ | ||||||||
|
Subroutine
removeResult: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 131 | 0 | my ($self, $key) = @_; | |||||||||
| 132 | |||||||||||
| 133 | 0 | delete($self->results->{$key}); | |||||||||
| 134 | } | ||||||||||
| 135 | 1 | ▶ | sub cifrar :Sig(self, s){ | ||||||||
|
Subroutine
cifrar: called CC=1 SCAR=0.0
| |||||||||||
| 136 | 1 | Eixo::Queue::JobCifrador->new->cifrar(@_); | |||||||||
| 137 | 4 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 138 | |||||||||||
| 139 | 1 | ▶ | sub descifrar :Sig(self, s, s){ | ||||||||
|
Subroutine
descifrar: called CC=1 SCAR=0.0
| |||||||||||
| 140 | 1 | Eixo::Queue::JobCifrador->new->descifrar(@_); | |||||||||
| 141 | 4 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 142 | |||||||||||
| 143 | |||||||||||
| 144 | 4 | 1; | |||||||||