Jifty/Plugin/SetupWizard.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 48 CC 4 SCAR 18.3
CC
4
Cov
0%
init
12.0
add_step
6.0
prereq_plugins
2.0
CRAP 6.2
1 package Jifty::Plugin::SetupWizard;
2 use strict;
3 use warnings;
4 use base 'Jifty::Plugin';
5  
6 __PACKAGE__->mk_accessors(qw(steps));
7  
8 sub prereq_plugins { 'Config' }
9  
10 sub init {
11 my $self = shift;
12 return if $self->_pre_init;
13  
14 my %opt = @_;
15  
16 if ($opt{steps}) {
17 $self->steps($opt{steps});
18 }
19 else {
20 $self->steps([
21 {
22 template => 'welcome',
23 header => 'Welcome',
24 hide_button => 1,
25 },
26 # Not sure this is worth doing quite yet.
27 # {
28 # template => 'language',
29 # header => 'Choose a Language',
30 # },
31 {
32 template => 'database',
33 header => 'Database',
34 },
35 {
36 template => 'web',
37 header => 'Web',
38 },
39 {
40 template => 'finalize',
41 header => 'Finalize',
42 hide_button => 1,
43 },
44 ]);
45 }
46  
47 for my $step (@{ $opt{add_steps} || [] }) {
48 $self->add_step(%$step);
49 }
50 }
51  
52 sub add_step {
53 my $self = shift;
54 my %step = @_;
55  
56 # Keep finalize at the end
57 if ($self->steps->[-1]->{template} eq 'finalize') {
58 splice @{ $self->steps }, -1, 0, \%step;
59 }
60 else {
61 push @{ $self->steps }, \%step;
62 }
63 }
64  
65 1;
66  
67 __END__