|
@@ -8,6 +8,7 @@ package SugarTrail::STM;
|
8
|
8
|
use strict;
|
9
|
9
|
use warnings;
|
10
|
10
|
use Carp;
|
|
11
|
+use SugarTrail::STS;
|
11
|
12
|
|
12
|
13
|
sub new {
|
13
|
14
|
my $class = shift;
|
|
@@ -52,6 +53,27 @@ sub parse_body {
|
52
|
53
|
return scalar @{ $self->{steps} };
|
53
|
54
|
}
|
54
|
55
|
|
|
56
|
+sub generate_sts {
|
|
57
|
+ my $self = shift;
|
|
58
|
+ my $args = shift;
|
|
59
|
+
|
|
60
|
+ my $sts = SugarTrail::STS->new($args);
|
|
61
|
+
|
|
62
|
+ my @lines;
|
|
63
|
+
|
|
64
|
+ STEP: foreach (@{ $self->{steps} }) {
|
|
65
|
+ unless ($_->{cond}) {
|
|
66
|
+ push @lines, $_->{line};
|
|
67
|
+ next STEP;
|
|
68
|
+ } else {
|
|
69
|
+ push @lines, $_->{line} if &matches($_->{cond}, $args);
|
|
70
|
+ }
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ $sts->{lines} = \@lines;
|
|
74
|
+ return $sts;
|
|
75
|
+}
|
|
76
|
+
|
55
|
77
|
# skel: matches if cond has m
|
56
|
78
|
sub matches {
|
57
|
79
|
my $cond = shift;
|