Compare commits

...

2 Commits

Author SHA1 Message Date
Zane C. B-H bac0f2d9c0 remote a .empty file 2021-10-31 23:07:21 -05:00
Zane C. B-H 0d643f2a90 more misc work done 2021-10-31 23:06:59 -05:00
5 changed files with 305 additions and 42 deletions

View File

@ -2,44 +2,52 @@ use 5.006;
use strict;
use warnings;
use ExtUtils::MakeMaker;
use File::ShareDir::Install;
my %WriteMakefileArgs = (
NAME => 'Server::Toaster',
AUTHOR => q{Zane C. Bowers-Hadley <vvelox@vvelox.net>},
VERSION_FROM => 'lib/Server/Toaster.pm',
ABSTRACT_FROM => 'lib/Server/Toaster.pm',
LICENSE => 'artistic_2',
MIN_PERL_VERSION => '5.006',
CONFIGURE_REQUIRES => {
'ExtUtils::MakeMaker' => '0',
},
TEST_REQUIRES => {
'Test::More' => '0',
},
PREREQ_PM => {
#'ABC' => '1.6',
#'Foo::Bar::Module' => '5.0401',
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Server-Toaster-*' },
NAME => 'Server::Toaster',
AUTHOR => q{Zane C. Bowers-Hadley <vvelox@vvelox.net>},
VERSION_FROM => 'lib/Server/Toaster.pm',
ABSTRACT_FROM => 'lib/Server/Toaster.pm',
LICENSE => 'artistic_2',
MIN_PERL_VERSION => '5.006',
CONFIGURE_REQUIRES => {
'ExtUtils::MakeMaker' => '0',
'File::ShareDir::Install' => '0',
},
TEST_REQUIRES => {
'Test::More' => '0',
},
PREREQ_PM => {
'Template' => '3.009',
'Template::Plugin::JSON' => '0.08',
'File::ShareDir' => '0',
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Server-Toaster-*' },
);
# Compatibility with old versions of ExtUtils::MakeMaker
unless (eval { ExtUtils::MakeMaker->VERSION('6.64'); 1 }) {
my $test_requires = delete $WriteMakefileArgs{TEST_REQUIRES} || {};
@{$WriteMakefileArgs{PREREQ_PM}}{keys %$test_requires} = values %$test_requires;
unless ( eval { ExtUtils::MakeMaker->VERSION('6.64'); 1 } ) {
my $test_requires = delete $WriteMakefileArgs{TEST_REQUIRES} || {};
@{ $WriteMakefileArgs{PREREQ_PM} }{ keys %$test_requires } = values %$test_requires;
}
unless (eval { ExtUtils::MakeMaker->VERSION('6.55_03'); 1 }) {
my $build_requires = delete $WriteMakefileArgs{BUILD_REQUIRES} || {};
@{$WriteMakefileArgs{PREREQ_PM}}{keys %$build_requires} = values %$build_requires;
unless ( eval { ExtUtils::MakeMaker->VERSION('6.55_03'); 1 } ) {
my $build_requires = delete $WriteMakefileArgs{BUILD_REQUIRES} || {};
@{ $WriteMakefileArgs{PREREQ_PM} }{ keys %$build_requires } = values %$build_requires;
}
delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
unless eval { ExtUtils::MakeMaker->VERSION('6.52'); 1 };
unless eval { ExtUtils::MakeMaker->VERSION('6.52'); 1 };
delete $WriteMakefileArgs{MIN_PERL_VERSION}
unless eval { ExtUtils::MakeMaker->VERSION('6.48'); 1 };
unless eval { ExtUtils::MakeMaker->VERSION('6.48'); 1 };
delete $WriteMakefileArgs{LICENSE}
unless eval { ExtUtils::MakeMaker->VERSION('6.31'); 1 };
unless eval { ExtUtils::MakeMaker->VERSION('6.31'); 1 };
install_share 'share';
WriteMakefile(%WriteMakefileArgs);
package MY;
use File::ShareDir::Install qw( postamble );

View File

@ -3,19 +3,20 @@ package Server::Toaster;
use 5.006;
use strict;
use warnings;
use Template;
use File::ShareDir ':ALL';
=head1 NAME
Server::Toaster - The great new Server::Toaster!
Server::Toaster - Helper for generating templated config files for servers.
=head1 VERSION
Version 0.01
Version 0.0.1
=cut
our $VERSION = '0.01';
our $VERSION = '0.0.1';
=head1 SYNOPSIS
@ -24,29 +25,109 @@ Quick summary of what the module does.
Perhaps a little code snippet.
use Server::Toaster;
my $st = Server::Toaster->new();
my $foo = Server::Toaster->new();
...
=head1 METHODS
=head1 EXPORT
=head2 new
A list of functions that can be exported. You can delete this section
if you don't export anything, such as for a purely object-oriented module.
This initiates the module.
=head1 SUBROUTINES/METHODS
dir - The base dir to use. If not spoecified,
'stoaster' is ued.
output - The output dir to use. If not specified,
$dir.'/output' is used.
templates - The template dir to use. If not specified,
$dir.'/templates' is used.
$templates and $output will be created as needed, but $dir must
exist upon module init or it will die.
=head2 function1
=cut
sub function1 {
sub new {
my ( $blank, %opts ) = @_;
# set the default dir if non is specified
if ( !defined( $opts{dir} ) ) {
$opts{dir} = 'stoaster';
}
# die if the base dir is not a directory or does not exist
if ( !-d $opts{dir} ) {
die '"' . $opts{dir} . '" does not exist or is not a directory';
}
# set the default output dir if non is specified
if ( !defined( $opts{output} ) ) {
$opts{output} = $opts{dir} . '/output';
}
# set the default template dir if non is specified
if ( !defined( $opts{templates} ) ) {
$opts{templates} = $opts{dir} . '/templates';
}
# init the object
my $self = {
dir => $opts{dir},
output => $opts{output},
templates => $opts{templates},
share => dist_dir('Server-Toaster'),
};
bless $self;
return $self;
}
=head2 function2
=head2 fill_in
=cut
sub function2 {
sub fill_in {
my ( $blank, $module, $hostname, $info ) = @_;
}
=head2 get_files
Fetches a list of templates a module uses.
As long as the specified module exists, this should never die.
The returned value is a hash with the keys being the template names
and the value being the full path to the file.
One value is required and that is the name of the module, relevant to
Sever::Toaster::Modules. So 'Sever::Toaster::Modules::Apache' becomes
'Apache';
=cut
sub get_files {
my ( $blank, $module ) = @_;
# make sure we have a module defined
if ( !defined($module) ) {
die 'No module specified';
}
my %returned;
my $to_eval
= 'use Server::Toaster::Modules::'
. $module
. '; %returned=Server::Toaster::Modules::'
. $module
. '->get_files;';
eval( $to_eval );
return %returned;
}
=head1 AUTHOR
@ -102,4 +183,4 @@ This is free software, licensed under:
=cut
1; # End of Server::Toaster
1; # End of Server::Toaster

View File

@ -0,0 +1,174 @@
package Server::Toaster::Modules::Apache;
use 5.006;
use strict;
use warnings;
use Template;
use File::ShareDir ':ALL';
=head1 NAME
Server::Toaster::Modules::Apache - Apache helper for Server::Toaster
=head1 VERSION
Version 0.0.1
=cut
our $VERSION = '0.0.1';
=head1 SYNOPSIS
Quick summary of what the module does.
Perhaps a little code snippet.
use Server::Toaster::Modules::Apache;
my $st = Server::Toaster->new();
=head1 METHODS
=head2 new
This initiates the module.
dir - The base dir to use. If not spoecified,
'stoaster' is ued.
output - The output dir to use. If not specified,
$dir.'/output' is used.
templates - The template dir to use. If not specified,
$dir.'/templates' is used.
$templates and $output will be created as needed, but $dir must
exist upon module init or it will die.
=cut
sub new {
my ( $blank, %opts ) = @_;
# set the default dir if non is specified
if ( !defined( $opts{dir} ) ) {
$opts{dir} = 'stoaster';
}
# die if the base dir is not a directory or does not exist
if ( !-d $opts{dir} ) {
die '"' . $opts{dir} . '" does not exist or is not a directory';
}
# set the default output dir if non is specified
if ( !defined( $opts{output} ) ) {
$opts{output} = $opts{dir} . '/output';
}
# set the default template dir if non is specified
if ( !defined( $opts{templates} ) ) {
$opts{templates} = $opts{dir} . '/templates';
}
# init the object
my $self = {
dir => $opts{dir},
output => $opts{output},
templates => $opts{templates},
share => dist_dir('Server-Toaster'),
};
bless $self;
return $self;
}
=head2 fill_in
=cut
sub fill_in {
my ( $blank, $module, $hostname, $info ) = @_;
}
=head2 get_files
Fetches a list of templates a module uses.
The returned value is a hash with the keys being the template names
and the value being the full path to the file.
=cut
sub get_files {
my ( $self ) = @_;
my $dir=dist_dir('Server-Toaster');
my %returned=(
'Apache/domain.tt'=>$dir.'/Apache/domain.tt',
'Apache/httpd.conf.tt'=>$dir.'/Apache/httpd.conf.tt',
);
return %returned;
}
=head1 AUTHOR
Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >>
=head1 BUGS
Please report any bugs or feature requests to C<bug-server-toaster at rt.cpan.org>, or through
the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Server-Toaster>. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Server::Toaster
You can also look for information at:
=over 4
=item * RT: CPAN's request tracker (report bugs here)
L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Server-Toaster>
=item * CPAN Ratings
L<https://cpanratings.perl.org/d/Server-Toaster>
=item * Search CPAN
L<https://metacpan.org/release/Server-Toaster>
=back
=head1 ACKNOWLEDGEMENTS
=head1 LICENSE AND COPYRIGHT
This software is Copyright (c) 2021 by Zane C. Bowers-Hadley.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
=cut
1; # End of Server::Toaster

0
share/Apache/domain.tt Normal file
View File

View File