| 1 | package Schedule::Pluggable::Plugin::JobsFromXML; | ||
| 2 | 1 | ▶ | use Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use Data::Dumper; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use XML::Simple; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 5 | use Carp qw/ croak /; | ||
| 6 | |||
| 7 | |||
| 8 | sub get_job_config { | ||
| 9 | my $self = shift; | ||
| 10 | my $params = shift; | ||
| 11 | my $jobs = undef; | ||
| 12 | if ($params->{Jobs}) { | ||
| 13 | if (-f $params->{Jobs}) { | ||
| 14 | $jobs = XMLin($params->{Jobs}, KeyAttr=>{ name => 'name1'}); | ||
| 15 | } | ||
| 16 | else { | ||
| 17 | croak("Xml input file $params->{Jobs} does not exist"); | ||
| 18 | } | ||
| 19 | } | ||
| 20 | else { | ||
| 21 | croak("Mandator Parameter Jobs with name of XMLFile missing for JobsFromXML"); | ||
| 22 | } | ||
| 23 | return $jobs->{Job}; | ||
| 24 | } | ||
| 25 | 1; | ||
| 26 | __END__ | ||
| 27 | |||
| 28 | =head1 NAME | ||
| 29 | |||
| 30 | Schedule::Pluggable::Plugin::JobsFromXML - Plugin Role for Schedule::Pluggable to obtain Job configuration from a file containing XML | ||
| 31 | |||
| 32 | =head1 METHODS | ||
| 33 | |||
| 34 | =over | ||
| 35 | |||
| 36 | =item get_job_config | ||
| 37 | |||
| 38 | get_job_config is the only method in this plugin and is returns the job config from and XML file | ||
| 39 | It expects a mandatory hashref which has a key Jobs containing the name of a file which contains the xml jon configuration | ||
| 40 | |||
| 41 | =back | ||
| 42 | |||
| 43 | =cut | ||