| 1 | package Makerelease::Step::Include; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use Makerelease::Step; | ||
| 5 | use Makerelease::Step::Section; | ||
| 6 | use XML::Simple; | ||
| 7 | |||
| 8 | our $VERSION = '0.1'; | ||
| 9 | |||
| 10 | # includes are really just a special type of Section | ||
| 11 | our @ISA=qw(Makerelease::Step::Section); | ||
| 12 | |||
| 13 | # sub-includes don't skip on the dry-runs... only executing steps do. | ||
| 14 | sub possibly_skip_dryrun { | ||
| 15 | my ($self, $step, $parentstep, $counter) = @_; | ||
| 16 | return 0; | ||
| 17 | } | ||
| 18 | |||
| 19 | sub load_em_up { | ||
| 20 | my ($self, $step, $parentstep, $counter) = @_; | ||
| 21 | return if ($step->{'__loaded'}); | ||
| 22 | $step->{'__loaded'} = 1; | ||
| 23 | $step->{'file'} = $step->{'file'}[0] if (ref($step->{'file'}) eq 'ARRAY'); | ||
| 24 | my $substeps = XMLin($step->{'file'}, @main::XMLinopts); | ||
| 25 | $step->{'steps'} = $substeps->{'steps'}; | ||
| 26 | } | ||
| 27 | |||
| 28 | sub test { | ||
| 29 | my ($self, $step, $parentstep, $counter) = @_; | ||
| 30 | |||
| 31 | $step->{'file'} = $step->{'file'}[0] if (ref($step->{'file'}) eq 'ARRAY'); | ||
| 32 | |||
| 33 | if (!exists($step->{'file'})) { | ||
| 34 | print "Step $parentstep$counter is missing the file clause\n"; | ||
| 35 | return 1; | ||
| 36 | } | ||
| 37 | |||
| 38 | if (! -f $step->{'file'}) { | ||
| 39 | print "Step $parentstep$counter: couldn't find the \"$step->{'file'}\" file\n"; | ||
| 40 | return 1; | ||
| 41 | } | ||
| 42 | |||
| 43 | print "loading: $step->{'file'}\n"; | ||
| 44 | load_em_up(@_); | ||
| 45 | Makerelease::Step::Section::test(@_); | ||
| 46 | } | ||
| 47 | |||
| 48 | sub step { | ||
| 49 | my ($self, $step, $parentstep, $counter) = @_; | ||
| 50 | load_em_up(@_); | ||
| 51 | return Makerelease::Step::Section::step(@_); | ||
| 52 | } | ||
| 53 | |||
| 54 | sub print_toc_header { | ||
| 55 | my ($self, $step, $parentstep, $counter) = @_; | ||
| 56 | load_em_up(@_); | ||
| 57 | return Makerelease::Step::Section::print_toc_header(@_); | ||
| 58 | } | ||
| 59 | |||
| 60 | |||
| 61 | 1; | ||
| 62 |