Browse Source

Refactored according to new naming convention

Alois Mahdal (@azzgoat) 12 years ago
parent
commit
48cfc48ce7

+ 2
- 2
lib/SugarTrail/Repo.pm View File

7
 use warnings;
7
 use warnings;
8
 use Carp;
8
 use Carp;
9
 use helper;
9
 use helper;
10
-use SugarTrail::STM;
10
+use SugarTrail::Template::Master;
11
 
11
 
12
 # initialize repo
12
 # initialize repo
13
 sub new {
13
 sub new {
24
     my $self = shift;
24
     my $self = shift;
25
     my $args = { @_ };
25
     my $args = { @_ };
26
 
26
 
27
-    my $stm = SugarTrail::STM->new();
27
+    my $stm = SugarTrail::Template::Master->new();
28
     $stm->{text} = $self->load_text(stm => $args->{stm})
28
     $stm->{text} = $self->load_text(stm => $args->{stm})
29
         or return;
29
         or return;
30
     $stm->{stm} = $args->{stm};
30
     $stm->{stm} = $args->{stm};

lib/SugarTrail/CondBlock.pm → lib/SugarTrail/Template/CondBlock.pm View File

1
-package SugarTrail::CondBlock;
1
+package SugarTrail::Template::CondBlock;
2
 # condition block
2
 # condition block
3
 # init()
3
 # init()
4
 # parse(string)
4
 # parse(string)

lib/SugarTrail/STM.pm → lib/SugarTrail/Template/Master.pm View File

1
-package SugarTrail::STM;
2
-# STM holder
1
+package SugarTrail::Template::Master;
2
+# Master template holder
3
 # new()
3
 # new()
4
 # parse_headers()
4
 # parse_headers()
5
 
5
 
8
 use strict;
8
 use strict;
9
 use warnings;
9
 use warnings;
10
 use Carp;
10
 use Carp;
11
-use SugarTrail::STS;
11
+use SugarTrail::Template::Slave;
12
 
12
 
13
 sub new {
13
 sub new {
14
     my $class = shift;
14
     my $class = shift;
53
     return scalar @{ $self->{steps} };
53
     return scalar @{ $self->{steps} };
54
 }
54
 }
55
 
55
 
56
-sub generate_sts {
56
+sub generate_slave {
57
     my $self = shift;
57
     my $self = shift;
58
     my $args = shift;
58
     my $args = shift;
59
 
59
 
60
-    my $sts = SugarTrail::STS->new($args);
60
+    my $slave = SugarTrail::Template::Slave->new($args);
61
 
61
 
62
     my @lines;
62
     my @lines;
63
 
63
 
70
         }
70
         }
71
     }
71
     }
72
 
72
 
73
-    $sts->{meta}->{'Stm'} = $self->{stm};
74
-    $sts->{meta}->{'Stm Revision'} = $self->get_current_revision();
75
-    $sts->{meta}->{'Params'} = mkmymime($args);
73
+    $slave->{meta}->{'Stm'} = $self->{stm};
74
+    $slave->{meta}->{'Stm Revision'} = $self->get_current_revision();
75
+    $slave->{meta}->{'Params'} = mkmymime($args);
76
 
76
 
77
-    $sts->{lines} = \@lines;
78
-    return $sts;
77
+    $slave->{lines} = \@lines;
78
+    return $slave;
79
 }
79
 }
80
 
80
 
81
 # skel: matches if cond has m
81
 # skel: matches if cond has m

lib/SugarTrail/STS.pm → lib/SugarTrail/Template/Slave.pm View File

1
-package SugarTrail::STS;
1
+package SugarTrail::Template::Slave;
2
 # STS holder
2
 # STS holder
3
 # new()
3
 # new()
4
 
4
 

+ 3
- 3
t/Cond.t View File

3
 use lib 'lib';
3
 use lib 'lib';
4
 use helper;
4
 use helper;
5
 
5
 
6
-BEGIN { use_ok( 'SugarTrail::CondBlock' ); }
7
-require_ok( 'SugarTrail::CondBlock' );
6
+BEGIN { use_ok( 'SugarTrail::Template::CondBlock' ); }
7
+require_ok( 'SugarTrail::Template::CondBlock' );
8
 
8
 
9
-my $cb = SugarTrail::CondBlock->init();
9
+my $cb = SugarTrail::Template::CondBlock->init();
10
 ok($cb, "cb is true");
10
 ok($cb, "cb is true");
11
 
11
 
12
 $cb->parse('os=@w7a,wxx;proto==imap;ver>=2012;');
12
 $cb->parse('os=@w7a,wxx;proto==imap;ver>=2012;');

+ 5
- 5
t/Repo.t View File

10
 ok($repo,           "repo is true");
10
 ok($repo,           "repo is true");
11
 
11
 
12
 my $stm = $repo->load_stm(stm=>'/release/rc.stm');
12
 my $stm = $repo->load_stm(stm=>'/release/rc.stm');
13
-ok($stm,            "stm is true");
13
+ok($stm,            "master is true");
14
 
14
 
15
 ok($stm->parse_headers(), "parse_headers() returns 6");
15
 ok($stm->parse_headers(), "parse_headers() returns 6");
16
 ok($stm->parse_headers(), "parse_headers() still returns 6");
16
 ok($stm->parse_headers(), "parse_headers() still returns 6");
17
 is($stm->parse_body(), 13, "parse_body() returns 13");
17
 is($stm->parse_body(), 13, "parse_body() returns 13");
18
 is($stm->parse_body(), 13, "parse_body() still returns 13");
18
 is($stm->parse_body(), 13, "parse_body() still returns 13");
19
 
19
 
20
-&helper::dmupp(stm=>$stm);
20
+&helper::dmupp(master=>$stm);
21
 
21
 
22
-my $sts = $stm->generate_sts({ proto => "imap", os => "wxx" });
23
-ok($sts,            "sts is true");
24
-&helper::dmupp(sts=>$sts);
22
+my $sts = $stm->generate_slave({ proto => "imap", os => "wxx" });
23
+ok($sts,            "slave is true");
24
+&helper::dmupp(slave=>$sts);
25
 
25
 
26
 done_testing();
26
 done_testing();