File Coverage

blib/lib/Rex/JobControl/Mojolicious/Plugin/MinionJobs.pm
Criterion Covered Total %
statement 18 35 51.4
branch 0 4 0.0
condition n/a
subroutine 6 8 75.0
pod 1 1 100.0
total 25 48 52.0


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4             # vim: set ts=3 sw=3 tw=0:
5             # vim: set expandtab:
6              
7             package Rex::JobControl::Mojolicious::Plugin::MinionJobs;
8             $Rex::JobControl::Mojolicious::Plugin::MinionJobs::VERSION = '0.18.0';
9 1     1   879 use strict;
  1         2  
  1         30  
10 1     1   4 use warnings;
  1         2  
  1         21  
11              
12 1     1   3 use Mojolicious::Plugin;
  1         2  
  1         8  
13 1     1   16 use Rex::JobControl::Helper::Project;
  1         2  
  1         27  
14              
15 1     1   4 use base 'Mojolicious::Plugin';
  1         1  
  1         373  
16              
17             sub register {
18 1     1 1 30 my ( $plugin, $app ) = @_;
19              
20             $app->minion->add_task(
21             execute_rexfile => sub {
22              
23 0     0   0 my ( $job, $project_dir, $job_dir, $current_user, $cmdb, @server ) = @_;
24              
25 0         0 $job->app->log->debug("Project: $project_dir");
26 0         0 $job->app->log->debug("Job: $job_dir");
27 0         0 $job->app->log->debug("User: $current_user");
28              
29             eval {
30 0         0 my $pr = $job->app->project($project_dir);
31 0         0 my $job = $pr->get_job($job_dir);
32 0         0 $job->execute( $current_user, $cmdb, @server );
33 0         0 1;
34 0 0       0 } or do {
35 0         0 $job->app->log->debug("Error executing: $@");
36             };
37              
38             }
39 1         11 );
40              
41             $app->minion->add_task(
42             checkout_rexfile => sub {
43              
44 0     0     my ( $job, $project_dir, $rexfile_name, $rexfile_url,
45             $rexfile_description )
46             = @_;
47              
48 0           $job->app->log->debug("checkout_rexfile: got params: " . join(", ", @_));
49              
50             eval {
51 0           my $pr = $job->app->project($project_dir);
52 0           $pr->create_rexfile(
53             directory => $rexfile_name,
54             name => $rexfile_name,
55             url => $rexfile_url,
56             description => $rexfile_description,
57             );
58 0           1;
59 0 0         } or do {
60 0           $job->app->log->debug("Error checkout_rexfile: $@");
61             };
62              
63             }
64 1         243 );
65             }
66              
67             1;