Handler.pm

filter: Statementstmt 90.4% 19 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 92.8% 26 / 28 CC 1 SCAR 0.4
CC
1
Cov
90%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« BuildInfo.pm ↑ Summary Handler/Buildd.pm »
1 package PkgForge::Handler; # -*-perl-*-
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # $Id: Handler.pm.in 21263 2012-07-03 14:26:32Z squinney@INF.ED.AC.UK $
6 # $Source:$
7 # $Revision: 21263 $
8 # $HeadURL: https://svn.lcfg.org/svn/source/tags/PkgForge-Server/PkgForge_Server_1_1_10/lib/PkgForge/Handler.pm.in $
9 # $Date: 2012-07-03 15:26:32 +0100 (Tue, 03 Jul 2012) $
10  
11 our $VERSION = '1.1.10';
12  
13 1 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 Readonly my $CONFIGDIR => '/etc/pkgforge';
17 Readonly my $BASE_CONF => 'pkgforge.yml';
18 Readonly my $HANDLER_CONF => 'handlers.yml';
19  
20 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use MooseX::Types::Moose qw(Bool HashRef Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
22 0 ▶use PkgForge::Meta::Attribute::Trait::Directory;
Subroutine BEGIN: called CC=1 SCAR=2.6
23  
24 with 'MooseX::LogDispatch', 'PkgForge::ConfigFile', 'MooseX::Getopt';
25  
26 has '+configfile' => (
27 default => sub {
28 my $class = shift @_;
29  
30 my @files = (
31 File::Spec->catfile( $CONFIGDIR, $BASE_CONF ),
32 File::Spec->catfile( $CONFIGDIR, $HANDLER_CONF ),
33 );
34  
35 my $mod = ( split /::/, $class->meta->name )[-1];
36 my $mod_conf = lc($mod) . '.yml';
37  
38 push @files, File::Spec->catfile( $CONFIGDIR, $mod_conf );
39  
40 return \@files;
41 },
42 );
43  
44 has '+logger' => (
45 traits => ['NoGetopt'],
46 );
47  
48 has '+use_logger_singleton' => (
49 traits => ['NoGetopt'],
50 );
51  
52 # Logging Stuff
53  
54 has 'debug' => (
55 is => 'ro',
56 isa => Bool,
57 default => 0,
58 documentation => 'Log debug messages',
59 );
60  
61 has 'logconf' => (
62 is => 'ro',
63 isa => 'Maybe[Str]',
64 default => '/etc/pkgforge/log-default.cfg',
65 predicate => 'has_logconf',
66 documentation => 'The logging configuration file',
67 );
68  
69 has 'log_dispatch_conf' => (
70 traits => ['NoGetopt'],
71 is => 'ro',
72 lazy => 1,
73 default => sub {
74 my ($self) = @_;
75 if ( $self->has_logconf && -f $self->logconf ) {
76 return $self->logconf;
77 } else {
78 return {
79 class => 'Log::Dispatch::Screen',
80 min_level => $self->debug ? 'debug' : 'info',
81 stderr => 1,
82 format => '[%p] %m%n',
83 };
84 }
85 },
86 documentation => 'The configuration for Log::Dispatch',
87 );
88  
89 # Directories
90  
91 has 'logdir' => (
92 is => 'ro',
93 isa => Str,
94 default => '/var/log/pkgforge',
95 required => 1,
96 documentation => 'The default directory for log files',
97 );
98  
99 has 'incoming' => (
100 traits => ['PkgForge::Directory'],
101 is => 'ro',
102 isa => Str,
103 default => '/var/lib/pkgforge/incoming',
104 required => 1,
105 documentation => 'The directory for incoming build jobs',
106 );
107  
108 has 'accepted' => (
109 traits => ['PkgForge::Directory'],
110 is => 'ro',
111 isa => Str,
112 default => '/var/lib/pkgforge/accepted',
113 required => 1,
114 documentation => 'The directory for accepted build jobs',
115 );
116  
117 has 'tmpdir' => (
118 traits => ['PkgForge::Directory'],
119 is => 'ro',
120 isa => Str,
121 default => '/var/tmp/pkgforge',
122 required => 1,
123 documentation => 'A directory for temporary files',
124 );
125  
126 has 'results' => (
127 traits => ['PkgForge::Directory'],
128 is => 'ro',
129 isa => Str,
130 default => '/var/lib/pkgforge/results',
131 required => 1,
132 documentation => 'The directory for build job results',
133 );
134  
135 # Use this error log method as the logger eats $EVAL_ERROR if you are
136 # not careful.
137  
138 sub log_problem {
139 my ( $self, $msg, $error ) = @_;
140  
141 $self->logger->error($msg);
142 if ($error) {
143 $self->logger->error($error);
144 }
145  
146 return;
147 }
148  
149 no Moose;
150 __PACKAGE__->meta->make_immutable;
151  
152 1;
153 __END__
« BuildInfo.pm ↑ Summary Handler/Buildd.pm »