|
@@ -16,6 +16,7 @@ sub new {
|
16
|
16
|
my $args = { @_ };
|
17
|
17
|
my $self = {};
|
18
|
18
|
$self->{args} = $args;
|
|
19
|
+ $self->{parsed} = 0;
|
19
|
20
|
return bless $self, $class;
|
20
|
21
|
}
|
21
|
22
|
|
|
@@ -24,10 +25,12 @@ sub parse {
|
24
|
25
|
my ($head, $body) = split "\n\n", $self->{text}, 2;
|
25
|
26
|
$self->{head} = $head;
|
26
|
27
|
$self->{body} = $body;
|
27
|
|
- return (
|
|
28
|
+ my @counts = (
|
28
|
29
|
$self->_parse_headers(),
|
29
|
30
|
$self->_parse_body()
|
30
|
31
|
);
|
|
32
|
+ $self->{parsed}++;
|
|
33
|
+ return @counts;
|
31
|
34
|
}
|
32
|
35
|
|
33
|
36
|
sub _parse_headers {
|
|
@@ -60,12 +63,12 @@ sub _parse_body {
|
60
|
63
|
sub generate_slave {
|
61
|
64
|
my $self = shift;
|
62
|
65
|
my $args = shift;
|
|
66
|
+ $self->parse() unless $self->{parsed};
|
63
|
67
|
|
64
|
68
|
#create an "empty" slave
|
65
|
69
|
my $slave = SugarTrail::Template::Slave->new($args);
|
66
|
70
|
|
67
|
71
|
my @slave_steps;
|
68
|
|
-
|
69
|
72
|
STEP: foreach my $master_step (@{ $self->{steps} }) {
|
70
|
73
|
my $accept = 1; # accept by default
|
71
|
74
|
my $slave_step = {
|