|
@@ -11,7 +11,45 @@ sub new {
|
11
|
11
|
my $args = shift;
|
12
|
12
|
my $self = {};
|
13
|
13
|
$self->{args} = $args;
|
|
14
|
+ $self->{steps} = [];
|
14
|
15
|
return bless $self, $class;
|
15
|
16
|
}
|
16
|
17
|
|
|
18
|
+sub source {
|
|
19
|
+ my $self = shift;
|
|
20
|
+ return sprintf "%s\n\n%s%s", $self->head, $self->warnings, $self->body;
|
|
21
|
+}
|
|
22
|
+
|
|
23
|
+sub head {
|
|
24
|
+ my $self = shift;
|
|
25
|
+ my @head;
|
|
26
|
+ push @head, sprintf "%s: %s", $_, $self->{meta}->{$_} foreach keys %{$self->{meta}};
|
|
27
|
+ return join "\n", @head;
|
|
28
|
+}
|
|
29
|
+
|
|
30
|
+sub body {
|
|
31
|
+ my $self = shift;
|
|
32
|
+ my @source;
|
|
33
|
+ push @source, $_->{line} foreach @{$self->{steps}};
|
|
34
|
+ return join "\n", @source;
|
|
35
|
+}
|
|
36
|
+
|
|
37
|
+sub warnings {
|
|
38
|
+ my $self = shift;
|
|
39
|
+ my @warnings;
|
|
40
|
+ foreach my $step (@{$self->{steps}}) {
|
|
41
|
+ push @warnings, $_ foreach @{$step->{warnings}};
|
|
42
|
+ }
|
|
43
|
+ my $warnings;
|
|
44
|
+ if (@warnings) {
|
|
45
|
+ $warnings .= "---\n# SUGAR-TRAIL WARNINGS #\n\n";
|
|
46
|
+ foreach (@warnings) {
|
|
47
|
+ $warnings .= "> warning: $_\n";
|
|
48
|
+ }
|
|
49
|
+ $warnings .= "---\n\n";
|
|
50
|
+ }
|
|
51
|
+ return $warnings;
|
|
52
|
+}
|
|
53
|
+
|
|
54
|
+
|
17
|
55
|
1;
|