line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# vim: set ts=2 sw=2 tw=0: |
5
|
|
|
|
|
|
|
# vim: set expandtab: |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Rex::JobControl::Helper::Project::Formular; |
8
|
|
|
|
|
|
|
$Rex::JobControl::Helper::Project::Formular::VERSION = '0.18.0'; |
9
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
10
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
4
|
use File::Spec; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
13
|
1
|
|
|
1
|
|
4
|
use File::Path; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
14
|
1
|
|
|
1
|
|
4
|
use YAML; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
15
|
1
|
|
|
1
|
|
4
|
use Rex::JobControl::Helper::Chdir; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
16
|
1
|
|
|
1
|
|
5
|
use Rex::JobControl::Helper::Project::Job; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
17
|
1
|
|
|
1
|
|
5
|
use Data::Dumper; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
587
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
0
|
|
|
0
|
0
|
|
my $that = shift; |
21
|
0
|
|
0
|
|
|
|
my $proto = ref($that) || $that; |
22
|
0
|
|
|
|
|
|
my $self = {@_}; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
bless( $self, $proto ); |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
$self->load; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
0
|
0
|
|
sub name { (shift)->{formular_configuration}->{name} } |
32
|
0
|
|
|
0
|
0
|
|
sub description { (shift)->{formular_configuration}->{description} } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub job { |
35
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
36
|
0
|
|
|
|
|
|
$self->project->get_job( $self->{formular_configuration}->{job} ); |
37
|
|
|
|
|
|
|
} |
38
|
0
|
0
|
|
0
|
0
|
|
sub public { (shift)->{formular_configuration}->{public} ? "yes" : "no" } |
39
|
0
|
|
|
0
|
0
|
|
sub servers { (shift)->{formular_configuration}->{servers} } |
40
|
0
|
|
|
0
|
0
|
|
sub project { (shift)->{project} } |
41
|
0
|
|
|
0
|
0
|
|
sub directory { (shift)->{directory} } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub load { |
44
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
if ( -f $self->_config_file() ) { |
47
|
0
|
|
|
|
|
|
$self->{formular_configuration} = YAML::LoadFile( $self->_config_file ); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $steps_file = File::Spec->catfile( |
50
|
|
|
|
|
|
|
$self->project->project_path(), "formulars", |
51
|
|
|
|
|
|
|
$self->{directory}, "steps.yml" |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
$self->{steps} = YAML::LoadFile($steps_file); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _config_file { |
59
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
60
|
0
|
|
|
|
|
|
return File::Spec->catfile( $self->project->project_path(), |
61
|
|
|
|
|
|
|
"formulars", $self->{directory}, "formular.conf.yml" ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub steps { |
65
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
66
|
0
|
|
0
|
|
|
|
return $self->{steps}->{formulars} || []; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub formulars { |
70
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
71
|
0
|
|
|
|
|
|
return $self->{steps}->{formulars}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub create { |
75
|
0
|
|
|
0
|
0
|
|
my ( $self, %data ) = @_; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $form_path = File::Spec->catdir( $self->project->project_path, |
78
|
|
|
|
|
|
|
"formulars", $self->{directory} ); |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
$self->project->app->log->debug( |
81
|
|
|
|
|
|
|
"Creating new formular $self->{directory} in $form_path."); |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
File::Path::make_path($form_path); |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my $steps = $data{steps}; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
delete $data{directory}; |
88
|
0
|
|
|
|
|
|
delete $data{steps}; |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my $form_configuration = {%data}; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
YAML::DumpFile( "$form_path/formular.conf.yml", $form_configuration ); |
93
|
0
|
|
|
|
|
|
YAML::DumpFile( "$form_path/steps.yml", $steps ); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub update { |
97
|
0
|
|
|
0
|
0
|
|
my ( $self, %data ) = @_; |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
my $form_path = File::Spec->catdir( $self->project->project_path, |
100
|
|
|
|
|
|
|
"formulars", $self->{directory} ); |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
$self->project->app->log->debug( |
103
|
|
|
|
|
|
|
"Updating formular $self->{directory} in $form_path."); |
104
|
|
|
|
|
|
|
|
105
|
0
|
0
|
|
|
|
|
if ( exists $data{steps} ) { |
106
|
0
|
|
|
|
|
|
YAML::DumpFile( "$form_path/steps.yml", $data{steps} ); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
delete $data{directory}; |
110
|
0
|
|
|
|
|
|
delete $data{steps}; |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
my $form_configuration = {%data}; |
113
|
0
|
|
|
|
|
|
YAML::DumpFile( "$form_path/formular.conf.yml", $form_configuration ); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub remove { |
117
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
118
|
0
|
|
|
|
|
|
my $formular_path = File::Spec->catdir( $self->project->project_path, |
119
|
|
|
|
|
|
|
"formulars", $self->{directory} ); |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
File::Path::remove_tree($formular_path); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |