| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Instance::Apache::Config; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
14
|
use Moo; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
29
|
|
|
4
|
4
|
|
|
4
|
|
872
|
use List::Util qw/ pairs /; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
207
|
|
|
5
|
4
|
|
|
4
|
|
13
|
use IO::All; |
|
|
4
|
|
|
|
|
3
|
|
|
|
4
|
|
|
|
|
16
|
|
|
6
|
4
|
|
|
4
|
|
1573
|
use namespace::clean; |
|
|
4
|
|
|
|
|
29898
|
|
|
|
4
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Test::Instance::Apache::Config - Create Apache Config File |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use FindBin qw/ $Bin /; |
|
15
|
|
|
|
|
|
|
use Test::Instance::Apache::Config; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $config_manager = Test::Instance::Apache::Config->new( |
|
18
|
|
|
|
|
|
|
filename => "$Bin/conf/httpd.conf", |
|
19
|
|
|
|
|
|
|
config => [ |
|
20
|
|
|
|
|
|
|
PidFile => "$Bin/httpd.pid", |
|
21
|
|
|
|
|
|
|
Include => "$Bin/mods_enabled/*.load", |
|
22
|
|
|
|
|
|
|
Include => "$Bin/mods_enabled/*.conf", |
|
23
|
|
|
|
|
|
|
], |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$config_manager->write_config; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Test::Instance::Apache allows you to spin up a complete Apache instance for |
|
31
|
|
|
|
|
|
|
testing. This is useful when developing various plugins for Apache, or if your |
|
32
|
|
|
|
|
|
|
application is tightly integrated to the webserver. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 Attributes |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
These are the attributes available to set on a new object. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head3 filename |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
The target filename to write the new config file to. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has filename => ( is => 'ro', required => 1 ); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head3 config |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
The arrayref to use to create the configuration file |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has config => ( |
|
53
|
|
|
|
|
|
|
is => 'ro', |
|
54
|
|
|
|
|
|
|
default => sub { return [] }, |
|
55
|
|
|
|
|
|
|
); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
has _config_string => ( |
|
58
|
|
|
|
|
|
|
is => 'lazy', |
|
59
|
|
|
|
|
|
|
builder => sub { |
|
60
|
2
|
|
|
2
|
|
920
|
my $self = shift; |
|
61
|
2
|
|
|
|
|
10
|
return $self->_gen_string( $self->config ); |
|
62
|
|
|
|
|
|
|
}, |
|
63
|
|
|
|
|
|
|
); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _gen_string { |
|
66
|
4
|
|
|
4
|
|
5
|
my ( $self, $data, $level ) = @_; |
|
67
|
|
|
|
|
|
|
|
|
68
|
4
|
|
100
|
|
|
19
|
$level ||= 0; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
return join '', map { |
|
71
|
4
|
|
|
|
|
42
|
my ($key, $value) = @$_; |
|
|
14
|
|
|
|
|
21
|
|
|
72
|
14
|
100
|
|
|
|
84
|
(ref($value) eq 'ARRAY' |
|
73
|
|
|
|
|
|
|
? join('', |
|
74
|
|
|
|
|
|
|
(sprintf "<%s>\n", $key), |
|
75
|
|
|
|
|
|
|
$self->_gen_string($value, $level + 1), |
|
76
|
|
|
|
|
|
|
(sprintf "%s>\n", split( ' ', $key )) |
|
77
|
|
|
|
|
|
|
) |
|
78
|
|
|
|
|
|
|
: (' ' x $level).$key.' '.$value."\n" |
|
79
|
|
|
|
|
|
|
) |
|
80
|
|
|
|
|
|
|
} pairs @$data; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 Methods |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head3 write_config |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Write the config to the target filename. |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub write_config { |
|
92
|
2
|
|
|
2
|
1
|
1597
|
my $self = shift; |
|
93
|
|
|
|
|
|
|
|
|
94
|
2
|
|
|
|
|
13
|
io( $self->filename )->print( $self->_config_string ); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 AUTHOR |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Tom Bloor Et.bloor@shadowcat.co.ukE |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Copyright 2016 Tom Bloor |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 LICENCE |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
108
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=over |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * L |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * L |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=back |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |