view release on metacpan or search on metacpan
lib/Apache/Config/Preproc.pm view on Meta::CPAN
}
if (@_) {
croak "Too many import parameters";
}
$class->SUPER::import();
}
sub new {
my $class = shift;
my $file = shift;
my $explist = Apache::Admin::Config::Tree::_get_arg(\@_, '-expand')
|| [ qw(include) ];
my $self = $class->SUPER::new($file, @_) or return;
bless $self, $class;
$self->{_filename} = $file;
$self->{_options} = \@_;
eval {
$self->_preproc($explist);
};
lib/Apache/Config/Preproc.pm view on Meta::CPAN
$_->begin_section($section) foreach (@$modlist);
OUTER:
for (my $i = 0;
defined(my $d = do {
local $SIG{__WARN__} = sub {
my $msg = shift;
warn "$msg" unless $msg =~ /uninitialized/;
};
$section->select(-which => $i) }); ) {
foreach my $mod (@$modlist) {
if ($mod->expand($d, \my @repl)) {
my $prev = $d;
foreach my $r (@repl) {
$prev = $section->add($r, -after => $prev);
}
$d->unlink;
next OUTER;
}
if ($d->type eq 'section') {
$self->_preproc_section_default($d, $modlist);
}
lib/Apache/Config/Preproc.pm view on Meta::CPAN
# the following implementation is used:
sub _preproc_section_optimized {
my ($self, $section, $modlist) = @_;
return unless @$modlist;
$_->begin_section($section) foreach (@$modlist);
OUTER:
for (my $i = 0; defined(my $d = $section->get_nth($i)); ) {
foreach my $mod (@$modlist) {
if ($mod->expand($d, \my @repl)) {
$section->replace_inplace($i, @repl);
next OUTER;
}
if ($d->type eq 'section') {
$self->_preproc_section_optimized($d, $modlist);
}
}
$i++;
}
$_->end_section($section) foreach (@$modlist);
lib/Apache/Config/Preproc.pm view on Meta::CPAN
=head1 NAME
Apache::Config::Preproc - Preprocess Apache configuration files
=head1 SYNOPSIS
use Apache::Config::Preproc;
$x = new Apache::Config::Preproc '/path/to/httpd.conf',
-expand => [ qw(include compact macro ifmodule ifdefine) ]
or die $Apache::Admin::Config::ERROR;
=head1 DESCRIPTION
B<Apache::Config::Preproc> reads and parses Apache configuration
file, expanding the syntactic constructs selected by the B<-expand> option.
In the simplest case, the argument to that option is a reference to the
list of names. Each name in the list identifies a module responsible for
processing specific Apache configuration keywords. For convenience, most
modules are named after the keyword they process, so that, e.g. B<include> is
responsible for inclusion of the files listed with B<Include> and
B<IncludeOptional> statements. The list of built-in module names follows:
=over 4
=item B<compact>
lib/Apache/Config/Preproc.pm view on Meta::CPAN
Expands the B<E<lt>MacroE<gt>> statements.
=back
See the section B<MODULES> for a detailed description of these modules.
More expansions can be easily implemented by supplying a corresponding
expansion module (see the section B<MODULE INTERNALS> below).
If the B<-expand> argument is not supplied, the following default is
used:
[ 'include' ]
The rest of methods is inherited from B<Apache::Admin::Config>.
=head1 IMPORT
The package provides two implementations of the main preprocessing
method. The default implementation uses only the documented methods
lib/Apache/Config/Preproc.pm view on Meta::CPAN
use Apache::Config::Preproc qw(:optimized);
See the source code for details.
=head1 CONSTRUCTOR
=head2 new
$obj = new Apache::Config::Preproc $file,
[-expand => $modlist],
[-indent => $integer], ['-create'], ['-no-comment-grouping'],
['-no-blank-grouping']
Reads the Apache configuration file from I<$file> and preprocesses it.
The I<$file> argument can be either the file name or file handle.
The keyword arguments are:
=over 4
=item B<-expand> =E<gt> I<$arrayref>
Define what expansions are to be performed. B<$arrayref> is a reference to
array of module names with optional arguments. To supply arguments,
use either a list reference where the first element is the module
name and rest of elements are arguments, or a hash reference with the name
of the module as key and a reference to the list of arguments as its value.
Consider, for example:
-expand => [ 'include', { ifmodule => { probe => 1 } } ]
-expand => [ 'include', [ 'ifmodule', { probe => 1 } ] ]
Both constructs load the B<include> module with no specific arguments,
and the B<ifmodule> module with the arguments B<probe =E<gt> 1>.
See the B<MODULES> section for a discussion of built-in modules and allowed
arguments.
A missing B<-expand> argument is equivalent to
-expand => [ 'include' ]
=back
Rest of arguments is the same as for the B<Apache::Admin::Config> constructor:
=over 4
=item B<-indent> =E<gt> I<$n>
Enables reindentation of the configuration content. The B<$n> argument
lib/Apache/Config/Preproc.pm view on Meta::CPAN
Returns the name of the configuration file.
=head2 options
Returns the list of options passed to the constructor when creating
the object.
=head1 MODULES
The preprocessing phases to be performed on the parsed configuration text are
defined by the B<-expand> argument. Internally, each name in its argument
list causes loading of a Perl module responsible for this particular phase.
Arguments to the constructor can be supplied using any of the following
constructs:
{ NAME => [ ARG, ...] }
or
[ NAME, ARG, ... ]
lib/Apache/Config/Preproc.pm view on Meta::CPAN
probe => 1
is a shorthand for
probe => [qw(/usr/sbin/httpd /usr/sbin/apache2)]
=back
=head2 ifdefine
Eliminates the B<Define> and B<UnDefine> statements and expands the
B<E<lt>IfDefineE<gt>> statements in the Apache configuration parse
tree. Optional arguments to the constructor are treated as the names
of symbols to define (similar to the B<httpd> B<-D> options). Example:
-expand => [ { ifdefine => [ qw(SSL FOREGROUND) ] } ]
=head2 locus
Attaches to each node in the parse tree a L<Text::Locus> object
which describes the location of the corresponding statement in the source
file. The location for each node can be accessed via the B<locus> method.
E.g. the following prints location and type of each statement:
$x = new Apache::Config::Preproc '/etc/httpd.conf',
-expand => [ qw(locus) ];
foreach ($x->select) {
print $_->locus
}
See L<Text::Locus> for a detailed discussion of the locus object and its
methods.
=head2 macro
Processes B<Macro> and B<Use> statements (see B<mod_macro>). B<Macro>
statements are removed. Each B<Use> statement is replaced by the expansion
of the macro named in its argument.
The constructor accepts the following arguments:
=over 4
=item B<keep =E<gt>> I<$listref>
List of macro names to exclude from expanding. Each B<E<lt>MacroE<gt>> and
B<Use> statement with a name from I<$listref> as its first argument will be
retained in the parse tree.
As a syntactic sugar, I<$listref> can also be a scalar value. This is
convenient when a single macro name is to be retained.
=back
=head1 MODULE INTERNALS
Each keyword I<phase> listed in the B<-expand> array causes loading of the
package B<Apache::Config::Preproc::I<phase>>. This package must inherit
from B<Apache::Config::Preproc::Expand> and overload at least the
B<expand> method. See the description of B<Apache::Config::Preproc::Expand>
for a detailed description.
=head1 EXAMPLE
my $obj = new Apache::Config::Preproc('/etc/httpd/httpd.conf',
-expand => [qw(compact include ifmodule macro)],
-indent => 4) or die $Apache::Admin::Config::ERROR;
print $obj->dump_raw
This snippet loads the Apache configuration from file
F</etc/httpd/httpd.conf>, performs all the built-in expansions, and prints
the result on standard output, using 4 character indent for each additional
level of nesting.
=head1 SEE ALSO
lib/Apache/Config/Preproc/Expand.pm view on Meta::CPAN
Invoked when all preprocessor expansions are finished for a section. The
section (an instance of B<Apache::Admin::Config::Tree> or a derived class) is
passed as the argument.
Default implementation is a no-op.
=cut
sub end_section {}
=head2 expand
$result = $obj->expand($node, \@items);
Expands the configuration tree node B<$node>, places the resulting
nodes to B<@items> and returns true. Returns false if no expansion
was done on the node.
=cut
sub expand {}
1;
lib/Apache/Config/Preproc/compact.pm view on Meta::CPAN
package Apache::Config::Preproc::compact;
use parent 'Apache::Config::Preproc::Expand';
use strict;
use warnings;
use Carp;
our $VERSION = '1.03';
sub expand {
my ($self, $d) = @_;
$d->type eq 'blank' || $d->type eq 'comment';
}
1;
__END__
=head1 NAME
Apache::Config::Preproc::compact - remove empty lines and comments
=head1 SYNOPSIS
$x = new Apache::Config::Preproc '/path/to/httpd.conf',
-expand => [ qw(compact) ];
=head1 DESCRIPTION
Removes empty and comment lines from the Apache configuration parse
tree.
=head1 SEE ALSO
L<Apache::Config::Preproc>
lib/Apache/Config/Preproc/ifdefine.pm view on Meta::CPAN
sub define {
my ($self,$id) = @_;
$self->{D}{$id} = 1;
}
sub undefine {
my ($self,$id) = @_;
delete $self->{D}{$id};
}
sub expand {
my ($self, $d, $repl) = @_;
if ($d->type eq 'section') {
if (lc($d->name) eq 'ifdefine') {
my $id = $d->value;
my $negate = $id =~ s/^!//;
my $res = $self->is_defined($id, $d);
$res = !$res if $negate;
if ($res) {
push @$repl, $d->select;
}
lib/Apache/Config/Preproc/ifdefine.pm view on Meta::CPAN
}
}
return 0;
}
1;
__END__
=head1 NAME
Apache::Config::Preproc::ifdefine - expand IfDefine sections
=head1 SYNOPSIS
$x = new Apache::Config::Preproc '/path/to/httpd.conf',
-expand => [ qw(ifdefine) ];
$x = new Apache::Config::Preproc '/path/to/httpd.conf',
-expand => [
{ ifdefine => [qw(SYM1 SYM2)] }
];
=head1 DESCRIPTION
Eliminates the B<Define> and B<UnDefine> statements and expands the
B<E<lt>IfDefineE<gt>> statements in the Apache configuration parse
tree. Optional arguments to the constructor are treated as the names
of symbols to define (similar to the B<httpd> B<-D> options).
=head1 SEE ALSO
L<Apache::Config::Preproc>
=cut
lib/Apache/Config/Preproc/ifmodule.pm view on Meta::CPAN
sub preloaded {
my $self = shift;
my $id = shift;
if (my $v = shift) {
$self->{preloaded}{$id} = $v;
}
return $self->{preloaded}{$id};
}
sub expand {
my ($self, $d, $repl) = @_;
if ($d->type eq 'section' && lc($d->name) eq 'ifmodule') {
my $id = $d->value;
my $negate = $id =~ s/^!//;
my $res = $self->module_loaded($id);
if ($negate) {
$res = !$res;
}
if ($res) {
push @$repl, $d->select;
lib/Apache/Config/Preproc/ifmodule.pm view on Meta::CPAN
}
close $nullin;
close $nullout;
}
1;
__END__
=head1 NAME
Apache::Config::Preproc::ifmodule - expand IfModule statements
=head1 SYNOPSIS
$x = new Apache::Config::Preproc '/path/to/httpd.conf',
-expand => [ qw(ifmodule) ];
$x = new Apache::Config::Preproc '/path/to/httpd.conf',
-expand => [
{ ifmodule => { probe => [ '/usr/sbin/httpd' ] } }
];
=head1 DESCRIPTION
Expands the B<E<lt>IfModuleE<gt>> statements in the Apache configuration parse
tree. If the statement's argument evaluates to true, it is replaced by the
statements inside it. Otherwise, it is removed. Nested statements are allowed.
The B<LoadModule> statements are examined in order to evaluate the argument.
lib/Apache/Config/Preproc/include.pm view on Meta::CPAN
sub context_push {
my ($self,$file,$dev,$ino) = @_;
push @{$self->{context}}, { file => $file, dev => $dev, ino => $ino };
}
sub context_pop {
my $self = shift;
pop @{$self->{context}};
}
sub expand {
my ($self, $d, $repl) = @_;
if ($d->type eq 'directive') {
if (lc($d->name) eq 'serverroot') {
$self->server_root($d->value);
} elsif ($d->name =~ /^include(optional)?$/i) {
my $optional = $1;
my $pat = $self->conf->dequote($d->value);
unless (File::Spec->file_name_is_absolute($pat)) {
lib/Apache/Config/Preproc/include.pm view on Meta::CPAN
my $path = abs_path($file);
return grep { $_->{file} eq $path } @{$self->{context}};
}
1;
__END__
=head1 NAME
Apache::Config::Preproc::include - expand Include statements
=head1 SYNOPSIS
$x = new Apache::Config::Preproc '/path/to/httpd.conf',
-expand => [ qw(include) ];
$x = new Apache::Config::Preproc '/path/to/httpd.conf',
-expand => [
{ include => [ server_root => $dir ] }
];
$x = new Apache::Config::Preproc '/path/to/httpd.conf',
-expand => [
{ include => [ probe => [ '/usr/sbin/httpd' ] ] }
];
=head1 DESCRIPTION
Processes B<Include> and B<IncludeOptional> statements and replaces them
with the contents of the files supplied in their arguments. If the argument
is not an absolute file name, it is searched in the server root directory.
Keyword arguments:
lib/Apache/Config/Preproc/locus.pm view on Meta::CPAN
$self->{line} = 0;
}
sub context_pop {
my $self = shift;
if (my $ctx = pop @{$self->{context}}) {
($self->{filename}, $self->{line}) = @$ctx;
}
}
sub expand {
my ($self, $d, $repl) = @_;
# Prevent recursion
return 0 if $d->can('locus');
# Handle context switches due to include statements.
if ($d->type eq 'directive') {
if ($d->name eq '$PUSH$') {
if ($d->value =~ /^\"(.+)\"/) {
$self->context_push($1);
lib/Apache/Config/Preproc/locus.pm view on Meta::CPAN
1;
__END__
=head1 NAME
Apache::Config::Preproc::locus - attach file location to each parse node
=head1 SYNOPSIS
$x = new Apache::Config::Preproc '/path/to/httpd.conf',
-expand => [ qw(locus) ];
foreach ($x->select) {
print $_->locus
}
=head1 DESCRIPTION
B<Locus> attaches to each node in the parse tree a B<Text::Locus> object
which describes the location of the corresponding statement in the source
file. The location of a node can be accessed via the B<locus> method
lib/Apache/Config/Preproc/macro.pm view on Meta::CPAN
return $self->{macro}{$name};
}
sub install_macro {
my ($self, $defn) = @_;
return 0 if $self->{keep}{$defn->name};
$self->{macro}{$defn->name} = $defn;
return 1;
}
sub expand {
my ($self, $d, $repl) = @_;
if ($d->type eq 'section' && lc($d->name) eq 'macro') {
return $self->install_macro(Apache::Config::Preproc::macro::defn->new($d));
}
if ($d->type eq 'directive' && lc($d->name) eq 'use') {
my ($name,@args) = parse_line(qr/\s+/, 0, $d->value);
if (my $defn = $self->macro($name)) {
push @$repl, $defn->expand(@args);
return 1;
}
}
return 0;
}
package Apache::Config::Preproc::macro::defn;
use strict;
use warnings;
use Text::ParseWords;
lib/Apache/Config/Preproc/macro.pm view on Meta::CPAN
name => $name,
params => [ @params ],
code => [$d->select]
}, $class;
}
sub name { shift->{name} }
sub params { @{shift->{params}} }
sub code { @{shift->{code}} }
sub expand {
my ($self, @args) = @_;
my @rxlist = map {
my $r = shift @args // '';
my $q = quotemeta($_);
[ qr($q), $r ]
} $self->params;
map { $self->_node_expand($_->clone, @rxlist) } $self->code;
}
sub _node_expand {
my ($self, $d, @rxlist) = @_;
if ($d->type eq 'directive') {
$d->value($self->_repl($d->value, @rxlist));
} elsif ($d->type eq 'section') {
$d->value($self->_repl($d->value, @rxlist));
foreach my $st ($d->select) {
$self->_node_expand($st, @rxlist);
}
}
return $d;
}
sub _repl {
my ($self, $v, @rxlist) = @_;
foreach my $rx (@rxlist) {
$v =~ s{$rx->[0]}{$rx->[1]}g;
}
return $v
}
1;
__END__
=head1 NAME
Apache::Config::Preproc::macro - expand macro statements
=head1 SYNOPSIS
$x = new Apache::Config::Preproc '/path/to/httpd.conf',
-expand => [ qw(macro) ];
$x = new Apache::Config::Preproc '/path/to/httpd.conf',
-expand => [ { macro => [ keep => $listref ] } ];
=head1 DESCRIPTION
Processes B<Macro> and B<Use> statements (see B<mod_macro>) in the
Apache configuration parse tree.
B<Macro> statements are removed. Each B<Use> statement is replaced by the
expansion of the macro named in its argument.
The constructor accepts the following arguments:
=over 4
=item B<keep =E<gt>> I<$listref>
List of macro names to exclude from expanding. Each B<E<lt>MacroE<gt>> and
B<Use> statement with a name from I<$listref> as its first argument will be
retained in the parse tree.
As a syntactic sugar, I<$listref> can also be a scalar value. This is
convenient when a single macro name is to be retained.
=back
=head1 SEE ALSO
t/00compact.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
my $obj = new TestPreproc -expand => [qw(compact)];
ok($obj->dump_raw, $obj->dump_expect);
__DATA__
!>httpd.conf
# Main file
ServerName localhost
ServerRoot "$server_root"
# Comment 1
# Comment 2
!=
t/01include00.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
my $obj = new TestPreproc -expand => [qw(include)];
ok($obj->dump_raw, $obj->dump_expect);
__DATA__
!>httpd.conf
# Main file
ServerName localhost
ServerRoot "$server_root"
Include vhost.conf
PidFile logs/httpd.pid
!>vhost.conf
t/01include01.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
# Test include by globbing pattern
my $obj = new TestPreproc -expand => [qw(include)];
ok($obj->dump_raw, $obj->dump_expect);
__DATA__
!>httpd.conf
ServerType standalone
ServerRoot "$server_root"
Include conf.d/*.conf
PidFile logs/httpd.pid
!>conf.d/a.conf
Timeout 300
!>conf.d/b.conf
t/01include02.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
# Test nested includes
my $obj = new TestPreproc -expand => [qw(include)];
ok($obj->dump_raw, $obj->dump_expect);
__DATA__
!>httpd.conf
# Main configuration
ServerType standalone
ServerRoot "$server_root"
Include "level1.conf"
PidFile logs/httpd.pid
!>level1.conf
t/01include03.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 2;
use TestPreproc;
# Test recursive inclusion handling
ok(!new TestPreproc '-expect_fail', -expand => [qw(include)]);
ok($Apache::Admin::Config::ERROR, qr/level1.conf already included/);
__DATA__
!>httpd.conf
ServerType standalone
ServerRoot "$server_root"
Include level1.conf
!>level1.conf
Include level2.conf
!>level2.conf
Include level3.conf
t/01include04.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
# Test whether a file can be included non-recursively multiple times
my $obj = new TestPreproc -expand => [qw(include)];
ok($obj->dump_raw, $obj->dump_expect);
__DATA__
!>httpd.conf
ServerType standalone
ServerRoot "$server_root"
<VirtualHost *:80>
ServerName foo.bar.example.com
Include req.conf
</VirtualHost>
t/03ifmodule00.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
my $obj = new TestPreproc -expand => [qw(ifmodule)];
ok($obj->dump_raw, $obj->dump_expect);
__DATA__
!>httpd.conf
LoadModule mpm_prefork_module lib/httpd/modules/mod_mpm_prefork.so
LoadModule unixd_module lib/httpd/modules/mod_unixd.so
<IfModule !mpm_netware_module>
PidFile "/var/run/httpd.pid"
</IfModule>
t/03ifmodule01.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 4;
use TestPreproc;
my $obj = new TestPreproc -expand => [qw(ifmodule)];
ok($obj->dump_raw, $obj->dump_expect);
$obj = new TestPreproc -expand => [qw(ifmodule)];
ok($obj->dump_raw, $obj->dump_expect);
$obj = new TestPreproc -expand => [qw(ifmodule)];
ok($obj->dump_raw, $obj->dump_expect);
$obj = new TestPreproc -expand => [qw(ifmodule)];
ok($obj->dump_raw, $obj->dump_expect);
__DATA__
!>httpd.conf
LoadModule mpm_prefork_module lib/httpd/modules/mod_mpm_prefork.so
<IfModule log_config_module>
LogFormat "%a" combined
<IfModule logio_module>
LogFormat "%a %I %O" combinedio
</IfModule>
</IfModule>
t/04macro00.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
my $obj = new TestPreproc -expand => ['macro'];
ok($obj->dump_raw, $obj->dump_expect);
__DATA__
!>httpd.conf
ServerName localhost
<Macro vhost $name $port $dir>
<VirtualHost *:$port>
# Comment
ServerName $name
DocumentRoot $dir
t/04macro01.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
my $obj = new TestPreproc -expand => ['macro'];
ok($obj->dump_raw, $obj->dump_expect);
__DATA__
!>httpd.conf
ServerName localhost
<Macro SSL $domain>
SSLEngine on
SSLCertificateFile /etc/ssl/acme/$domain.pem
</Macro>
<Macro vhost $name $port $dir>
t/04macro02.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
my $obj = new TestPreproc -expand => [ { macro => [ keep => 'SSL' ] } ];
ok($obj->dump_raw, $obj->dump_expect);
__DATA__
!>httpd.conf
ServerName localhost
<Macro SSL $domain>
SSLEngine on
SSLCertificateFile /etc/ssl/acme/$domain.pem
</Macro>
<Macro vhost $name $port $dir>
<VirtualHost *:$port>
t/05ifdefine00.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 3;
use TestPreproc;
my $obj = new TestPreproc -expand => ['ifdefine'];
ok($obj->dump_raw, $obj->dump_expect);
$obj = new TestPreproc -expand => [ { ifdefine => [qw(VAR)] } ];
ok($obj->dump_raw, $obj->dump_expect);
$obj = new TestPreproc -expand => ['ifdefine'];
ok($obj->dump_raw, $obj->dump_expect);
__DATA__
!>httpd.conf
ServerAdmin foo
<IfDefine VAR>
ServerName localhost
</IfDefine>
!=
ServerAdmin foo
t/05ifdefine01.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
my $obj = new TestPreproc -expand => ['ifdefine'];
ok($obj->dump_raw, $obj->dump_expect);
__DATA__
!>httpd.conf
Define FOO
ServerName localhost
<IfDefine FOO>
ServerAlias remote
</IfDefine>
UnDefine FOO
t/05ifdefine02.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
my $obj = new TestPreproc -expand => ['ifdefine'];
ok($obj->dump_raw, $obj->dump_expect);
__DATA__
!>httpd.conf
<VirtualHost bar>
ServerName localhost
ServerAdmin root
Define FOO
</VirtualHost>
<IfDefine FOO>
t/06locus00.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
my $obj = new TestPreproc -expand => [qw(locus)];
ok($obj->dump_reformat_synclines, $obj->dump_expect)
__DATA__
!>httpd.conf
# Start of file
# Comment 1
# Comment 2
# Comment 3
t/06locus01.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
my $obj = new TestPreproc -expand => [qw(locus)],
'-no-comment-grouping' => 1,
'-no-blank-grouping' => 1;
ok($obj->dump_reformat_synclines, $obj->dump_expect)
__DATA__
!>httpd.conf
# Start of file
# Comment 1
# Comment 2
t/06locus02.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
my $obj = new TestPreproc -expand => [qw(locus)];
ok($obj->dump_reformat_synclines eq $obj->dump_expect);
__DATA__
!>httpd.conf
# Start of file
ServerName localhost
ServerAdmin foo@example.net
<VirtualHost *:80>
t/06locus03.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
my $obj = new TestPreproc -expand => [qw(locus include)];
ok($obj->dump_reformat_synclines,$obj->dump_expect);
__DATA__
!>httpd.conf
# Start of file
ServerRoot "$server_root"
ServerAdmin foo@example.net
Include vhost1.conf
Include vhost2.conf
PidFile logs/httpd.pid
t/06locus04.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
my $obj = new TestPreproc -expand => [qw(locus macro)];
ok($obj->dump_reformat_synclines,$obj->dump_expect);
__DATA__
!>httpd.conf
# Start of file
ServerRoot "$server_root"
<Macro X $arg>
Foo $arg
</Macro>
EndStatement true
t/06locus05.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 3;
use TestPreproc;
my $obj = new TestPreproc -expand => ['locus', 'ifdefine'];
ok($obj->dump_reformat_synclines, $obj->dump_expect);
$obj = new TestPreproc -expand => [ 'locus', { ifdefine => [qw(VAR)] } ];
ok($obj->dump_reformat_synclines, $obj->dump_expect);
$obj = new TestPreproc -expand => ['locus', 'ifdefine'];
ok($obj->dump_reformat_synclines, $obj->dump_expect);
__DATA__
!>httpd.conf
ServerAdmin foo
<IfDefine VAR>
ServerName localhost
</IfDefine>
!=
# $server_root/httpd.conf:1
t/06locus06.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
my $obj = new TestPreproc -expand => [qw(locus ifmodule)];
ok($obj->dump_reformat_synclines, $obj->dump_expect);
__DATA__
!>httpd.conf
LoadModule mpm_prefork_module lib/httpd/modules/mod_mpm_prefork.so
LoadModule unixd_module lib/httpd/modules/mod_unixd.so
<IfModule !mpm_netware_module>
PidFile "/var/run/httpd.pid"
</IfModule>
t/99all00.t view on Meta::CPAN
# -*- perl -*-
use lib qw(t lib);
use strict;
use Test;
plan test => 1;
use TestPreproc;
my $obj = new TestPreproc -expand => [qw(compact include ifmodule macro ifdefine)];
ok($obj->dump_raw, $obj->dump_expect);
__DATA__
!>httpd.conf
# Main file
ServerName localhost
ServerRoot "$server_root"
Include conf.d/*.conf
Include mpm.conf