Zucchini::Config::Create - write a sample configuration file


Zucchini documentation Contained in the Zucchini distribution.

Index


Code Index:

NAME

Top

Zucchini::Config::Create - write a sample configuration file

SYNOPSIS

Top

  # create a new object
  $zucchini_cfg_create = Zucchini::Config::Create->new();

  # write out a default config file
  $zucchini_cfg_create->write_default_config(
    file($ENV{HOME}, q{.zucchini})
  );

DESCRIPTION

Top

It's mean to expect people to pluck a configuration file out if thin air.

This module's sole purpose is to write out a default .zucchini file to give users a fighting chance.

METHODS

Top

new

Creates a new instance of the top-level Zucchini object:

  # create a new object
  $zucchini_cfg_create = Zucchini::Config::Create->new();

write_default_config

Given a filename, write out the default/sample configuration file. If the file already exists it will not be overwritten.

  # write out a default config file
  $zucchini_cfg_create->write_default_config(
    file($ENV{HOME}, q{.zucchini})
  );

SAMPLE CONFIGURATION FILE

Top

The sample configuration file is supposed to be a reasonable example of how a functioning configuration file should look.

You should be able to get up and running with Zucchini by creating the default file, and modifying the following variables: source_dir, includes_dir, output_dir.

You might also like to edit some of the values in the <tags> section.

SEE ALSO

Top

Zucchini, Zucchini::Config

AUTHOR

Top

Chisel Wright <chiselwright@users.berlios.de>

LICENSE

Top

Copyright 2008-2009 by Chisel Wright

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See <http://www.perl.com/perl/misc/Artistic.html>


Zucchini documentation Contained in the Zucchini distribution.

package Zucchini::Config::Create;
# vim: ts=8 sts=4 et sw=4 sr sta
use Moose; # automatically turns on strict and warnings

__PACKAGE__->meta->make_immutable;

use Zucchini::Version; our $VERSION = $Zucchini::VERSION;

use IO::File;

sub write_default_config {
    my $self        = shift;
    my $filename    = shift;

    if (-e $filename) {
        # TODO - copy file to file.TIMESTAMP and create new
        warn "$filename already exists\n";
        return;
    }

    # create a filehandle to write to
    my $fh = IO::File->new($filename, 'w');

    # loop through the __DATA__ for this module
    # and print it to the filehandle
    while (my $line = <DATA>) {
        print $fh <DATA>;
    }
    $fh->close;
    close DATA;
}

1;

__DATA__

default_site   default

<site>
    # a default site
    <default>
        source_dir          /path/to/tt_templates
        includes_dir        /path/to/tt_includes
        output_dir          /var/www/default_site/html

        template_files      \.html\z

        ignore_dirs         CVS
        ignore_dirs         .svn

        ignore_files        \.swp\z

        lint_check          1

        <tags>
            author          Joe Bloggs
            email           joe@localhost
            copyright       &copy; 2006-2008 Joe Bloggs. All rights reserved.
        </tags>

        <ftp>
            hostname        remote.ftp.site
            username        joe.bloggs
            password        sekrit
            passive         1
            path            /
        </ftp>
    </default>


    # a second site definition - to demonstrate how to define multiple sites
    <mysite>
        source_dir          /path/to/tt_templates
        includes_dir        /path/to/tt_includes
        output_dir          /var/www/default_site/html

        plugin_base         MyPrefix::Template::Plugin

        template_files      \.html\z

        ignore_dirs         CVS
        ignore_dirs         .svn

        ignore_files        \.swp\z

        lint_check          1

        <tags>
            author          Joe Bloggs
            email           joe@localhost
            copyright       &copy; 2000-2006 Joe Bloggs. All rights reserved.
        </tags>

        <rsync>
            hostname        remote.site
            path            /home/joe.bloggs
         </rsync>
    </mysite>
</site>