Selaa lähdekoodia

Refactored according to new naming convention

Alois Mahdal (@azzgoat) 12 vuotta sitten
vanhempi
commit
48cfc48ce7

+ 2
- 2
lib/SugarTrail/Repo.pm Näytä tiedosto

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

lib/SugarTrail/CondBlock.pm → lib/SugarTrail/Template/CondBlock.pm Näytä tiedosto

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

lib/SugarTrail/STM.pm → lib/SugarTrail/Template/Master.pm Näytä tiedosto

@@ -1,5 +1,5 @@
1
-package SugarTrail::STM;
2
-# STM holder
1
+package SugarTrail::Template::Master;
2
+# Master template holder
3 3
 # new()
4 4
 # parse_headers()
5 5
 
@@ -8,7 +8,7 @@ package SugarTrail::STM;
8 8
 use strict;
9 9
 use warnings;
10 10
 use Carp;
11
-use SugarTrail::STS;
11
+use SugarTrail::Template::Slave;
12 12
 
13 13
 sub new {
14 14
     my $class = shift;
@@ -53,11 +53,11 @@ sub parse_body {
53 53
     return scalar @{ $self->{steps} };
54 54
 }
55 55
 
56
-sub generate_sts {
56
+sub generate_slave {
57 57
     my $self = shift;
58 58
     my $args = shift;
59 59
 
60
-    my $sts = SugarTrail::STS->new($args);
60
+    my $slave = SugarTrail::Template::Slave->new($args);
61 61
 
62 62
     my @lines;
63 63
 
@@ -70,12 +70,12 @@ sub generate_sts {
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 81
 # skel: matches if cond has m

lib/SugarTrail/STS.pm → lib/SugarTrail/Template/Slave.pm Näytä tiedosto

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

+ 3
- 3
t/Cond.t Näytä tiedosto

@@ -3,10 +3,10 @@ use Test::More;
3 3
 use lib 'lib';
4 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 10
 ok($cb, "cb is true");
11 11
 
12 12
 $cb->parse('os=@w7a,wxx;proto==imap;ver>=2012;');

+ 5
- 5
t/Repo.t Näytä tiedosto

@@ -10,17 +10,17 @@ my $repo = SugarTrail::Repo->new(root => './t/data/strepo', vcs => 'git');
10 10
 ok($repo,           "repo is true");
11 11
 
12 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 15
 ok($stm->parse_headers(), "parse_headers() returns 6");
16 16
 ok($stm->parse_headers(), "parse_headers() still returns 6");
17 17
 is($stm->parse_body(), 13, "parse_body() returns 13");
18 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 26
 done_testing();