| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 | package SugarTrail::Template::Slave;
# STS holder
# new()
use strict;
use warnings;
use Carp;
sub new {
    my $class = shift;
    my $args = shift;
    my $self = {};
    $self->{args} = $args;
    $self->{steps} = [];
    return bless $self, $class;
}
sub source {
    my $self = shift;
    return sprintf "%s\n%s%s", $self->head, $self->warnings, $self->body;
}
sub head {
    my $self = shift;
    my @head;
    push @head, sprintf "%s: %s\n", $_, $self->{meta}->{$_}
        foreach keys %{$self->{meta}};
    return join "", @head;
}
sub body {
    my $self = shift;
    my @source;
    push @source, $_->{line} . "\n" foreach @{$self->{steps}};
    return join "", @source;
}
sub warnings {
    my $self = shift;
    my @warnings;
    foreach my $step (@{$self->{steps}}) {
        push @warnings, $_ foreach @{$step->{warnings}};
    }
    return \@warnings;
}
1;
 |