Pluggable/Plugin/JobsFromXMLTemplate.pm

filter: Statementstmt 66.6% 4 / 6 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 75.0% 6 / 8 CC 1 SCAR 1.4
CC
1
Cov
67%
BEGIN
1.3
BEGIN
1.0
CRAP 1.1
« Pluggable/Plugin/JobsFromData.pm ↑ Summary Pluggable/Plugin/JobsFromXML.pm »
1 package Schedule::Pluggable::Plugin::JobsFromXMLTemplate;
2 1 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use XML::Simple;
Subroutine BEGIN: called CC=1 SCAR=2.6
4 use Template;
5 use Carp qw/ croak /;
6  
7 sub get_job_config {
8 my $self = shift;
9 my $params = shift;
10 my $jobs = undef;
11 if ($params->{Jobs}) {
12 if (-f $params->{Jobs}) {
13 my $tt = new Template({EVAL_PERL => 1});
14 my $processed;
15 $tt->process($params->{Jobs}, $self, \$processed);
16 $jobs = XMLin($processed, KeyAttr=>{ name => 'name1'});
17 }
18 else {
19 croak("Xml input file $params->{Jobs} does not exist");
20 }
21 }
22 else {
23 croak("Mandator Parameter Xml input file Jobs missing for JobsFromXML");
24 }
25 return $jobs->{Job};
26 }
27 1;
28 __END__
29  
30 =head1 NAME
31  
32 Schedule::Pluggable::Plugin::JobsFromXMLTemplate - Plugin Role for Schedule::Pluggable to obtain Job configuration from a Template toolkit XML file
33  
34 =head1 METHODS
35  
36 =over
37  
38 =item get_job_config
39  
40 get_job_config is the only method in this plugin and is returns the job config from and XML file
41 It expects a mandatory hashref which has a key Jobs containing the name of a file which contains the xml job configuration.
42 As the name suggests, the file is also processed by Template::Toolkit
43  
44  
45 =back
46  
47 =cut
« Pluggable/Plugin/JobsFromData.pm ↑ Summary Pluggable/Plugin/JobsFromXML.pm »