| 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 | ||