blib/lib/Tapper/Action.pm

filter: Statementstmt 91.9% 57 / 62 Branchbran 66.6% 8 / 12 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 88.2% 15 / 17 Podpod 100% 2 / 2 totaltotal 86.7% 85 / 98 CC 8 SCAR 9.0
CC
8
Cov
87%
__ANON__
5.2
get_messages
4.0
__ANON__
2.0
CRAP 2.5
« blib/lib/Tapper/Action/Plugin/resume/OSRC.pm ↑ Summary blib/lib/Tapper/Action/Daemon.pm »
1 package Tapper::Action;
2 # git description: v4.1.1-14-g65e3f23
3  
4 9 our $AUTHORITY = 'cpan:TAPPER';
5 # ABSTRACT: Tapper - Daemon and plugins to handle MCP actions
6 9 $Tapper::Action::VERSION = '5.0.0';
7 9 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 9 ▶use Tapper::Model 'model';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 9 ▶use Tapper::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 9 ▶use YAML::Syck 'Load';
Subroutine BEGIN: called CC=1 SCAR=0.0
15 9 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 9 ▶use Class::Load ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 9 extends 'Tapper::Base';
19  
20 2 ▶has cfg => (is => 'rw', default => sub { Tapper::Config->subconfig} );
Subroutine __ANON__: called CC=1 SCAR=0.0
21  
22  
23 sub get_messages
24 3 ▶{
Subroutine get_messages: called CC=4 SCAR=14.0
Pod documented
25 3 my ($self) = @_;
26  
27 3 my $messages;
28 3 while () {
29 23 $messages = model('TestrunDB')->resultset('Message')->search({type => 'action'});
30 23 ▶ last if ($messages and $messages->count);
Branch: 1 branch
BranchTrueFalseTotal
if $messages and $messages->count 2 21 23
Condition66%2/3
$messages and $messages->count
!ll&&!rl&&r
0212
MC/DC50%1/2
$messages and $messages->count
$messages $messages->count
Truth table66%2/3
A and B
A= $messagesB= $messages->count
ABresult
0X0
100
111
31 21 ▶ sleep $self->cfg->{times}{action_poll_intervall} || 1;
Branch: 1 branch
BranchTrueFalseTotal
sleep $self->cfg->{"times"}{"action_poll_intervall"} or '???' 20 0 20
32 }
33 2 return $messages;
34 }
35  
36  
37 sub loop
38 2 ▶{
Subroutine loop: called CC=1 SCAR=0.2
Pod documented
39 2 my ($self) = @_;
40  
41 # my $x=model('TestrunDB')->resultset('Host');
42 2 ▶ try {
Subroutine __ANON__: called CC=5 SCAR=16.4
43 ACTION:
44 2 ▶ while (my $messages = $self->get_messages) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $messages = $self->get_messages) 2 0 2
45 2 ▶ while (my $message = $messages->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $message = $messages->next) 2 1 3
46 2 ▶ if (my $action = $message->message->{action}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $action = $message->message->{"action"}) 2 0 2
47 2 my $plugin = $self->cfg->{action}{$action}{plugin};
48 2 my $plugin_options = $self->cfg->{action}{$action}{plugin_options};
49 2 my $plugin_class = "Tapper::Action::Plugin::${action}::${plugin}";
50 2 load_class($plugin_class);
51  
52 2 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 2 2
53 0 $self->log->error( "Could not load $plugin_class: $@" );
54 } else {
55 2 ▶ try{
Subroutine __ANON__: called CC=1 SCAR=0.0
56 9 ▶ no strict 'refs'; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
57 2 $self->log->info("Call ${plugin_class}::execute()");
58 2 &{"${plugin_class}::execute"}($self, $message->message, $plugin_options);
59 0 ▶ } catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
60 0 $self->log->error("Error occured: $_");
61 }
62 2 }
63 }
64 1 $message->delete;
65 }
66 }
67 0 ▶ } catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
68 0 say STDERR "Caught exception $_";
69 0 $self->log->error("Caugth exception: $_");
70 2 };
71 0 return;
72 }
73  
74 9 1; # End of Tapper::Action
75  
76 __END__
« blib/lib/Tapper/Action/Plugin/resume/OSRC.pm ↑ Summary blib/lib/Tapper/Action/Daemon.pm »