Repositorio/Server/Helper/Common.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 40 CC 1 SCAR 6.9
CC
1
Cov
0%
register
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4 # vim: set ts=2 sw=2 tw=0:
5 # vim: set expandtab:
6  
7 package Rex::Repositorio::Server::Helper::Common;
8  
9 use strict;
10 use warnings;
11  
12 our $VERSION = '1.2.1'; # VERSION
13  
14 use Mojo::Base 'Mojolicious::Plugin';
15 use Params::Validate qw(:all);
16 use File::Spec;
17 use JSON::XS;
18  
19 sub register {
20 my ( $self, $app ) = @_;
21  
22 $app->helper(
23 config => sub {
24 my $config = decode_json( $ENV{REPO_CONFIG} );
25 return $config;
26 },
27 );
28  
29 $app->helper(
30 repo => sub {
31 my $self = shift;
32 return {
33 %{ $self->config->{Repository}->{ $ENV{REPO_NAME} } },
34 name => $ENV{REPO_NAME}
35 };
36 },
37 );
38  
39 $app->helper(
40 get_repo_dir => sub {
41 my $self = shift;
42 my %option = validate(
43 @_,
44 {
45 repo => {
46 type => SCALAR
47 }
48 }
49 );
50  
51 return File::Spec->rel2abs( $self->config->{RepositoryRoot}
52 . "/head/"
53 . $self->config->{Repository}->{ $option{repo} }->{local} );
54 },
55 );
56 }
57  
58 1;