12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 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;
|