1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- 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}};
- }
- my $warnings = "";
- if (@warnings) {
- $warnings .= "---\n# SUGAR-TRAIL WARNINGS #\n\n";
- foreach (@warnings) {
- $warnings .= "> warning: $_\n";
- }
- $warnings .= "---\n\n";
- }
- return $warnings;
- }
-
-
- 1;
|