File Coverage

blib/lib/Rex/JobControl/Mojolicious/Plugin/Project.pm
Criterion Covered Total %
statement 20 26 76.9
branch 0 2 0.0
condition n/a
subroutine 7 8 87.5
pod 1 1 100.0
total 28 37 75.6


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::Project;
8             $Rex::JobControl::Mojolicious::Plugin::Project::VERSION = '0.18.0';
9 1     1   841 use strict;
  1         2  
  1         29  
10 1     1   5 use warnings;
  1         1  
  1         20  
11              
12 1     1   3 use Mojolicious::Plugin;
  1         1  
  1         10  
13 1     1   40 use Digest::MD5 'md5_hex';
  1         1  
  1         128  
14 1     1   394 use Rex::JobControl::Helper::Project;
  1         30  
  1         30  
15              
16 1     1   5 use base 'Mojolicious::Plugin';
  1         1  
  1         211  
17              
18             sub register {
19 1     1 1 41 my ( $plugin, $app ) = @_;
20              
21             $app->helper(
22             project => sub {
23 0     0     my ( $self, $directory ) = @_;
24              
25 0           my $name = $directory;
26              
27 0 0         if ( $directory !~ m/^[a-f0-9]{32}$/ ) {
28              
29             # no md5sum, compat. code
30 0           $directory = md5_hex($directory);
31             }
32              
33 0           my $u = Rex::JobControl::Helper::Project->new(
34             directory => $directory,
35             name => $name,
36             app => $app
37             );
38 0           return $u;
39             }
40 1         9 );
41             }
42              
43             1;