NAME

Distribution::Cooker - Create a module directory from your own templates

SYNOPSIS

use Distribution::Cooker;

Distribution::Cooker->run( ... );

# most of this should go through the dist_cooker sketch

DESCRIPTION

run( [ MODULE_NAME, [ DESCRIPTION ] ] )

Calls pre-run, collects information about the module you want to create, cooks the templates, and calls post-run.

If you don't specify the module name, it prompts you. If you don't specify a description, it prompts you.

new

Create the bare object. There's nothing fancy here, but if you need something more powerful you can create a subclass.

init

Initialize the object. There's nothing fancy here, but if you need something more powerful you can create a subclass.

pre_run

Method to call before run() starts its work. run() will call this for you. By default this is a no-op, but you can redefine it or override it in a subclass.

run() calls this method immediately after it creates the object but before it initializes it.

post_run

Method to call after run() ends its work. run() calls this for you. By default this is a no-op, but you can redefine it or override it in a subclass.

cook

Take the templates and cook them. This version uses Template Toolkit, but you can make a subclass to override it.

I assume my own favorite values, and haven't made these customizable yet.

ttree (from Template) is in /usr/local/bin/ttree
Your distribution template directory is ~/.templates/dist_cooker
Your module template name is lib/Foo.pm

When cook processes the templates, it provides definitions for these template variables:

description => the module description
module => the package name (Foo::Bar)
module_dist => the distribution name (Foo-Bar)
module_file => module file name (Bar.pm)
module_path => module path under lib/ (Foo/Bar.pm)
repo_name => lowercase module with hyphens (foo-bar)
year => the current year

While processing the templates, cook ignores .git, .svn, and CVS directories.

ttree_command

Returns the name for the ttree command from template, and croaks if that path does not exist or is not executable.

The default path is /usr/local/bin/ttree. You can override this in a subclass.

distribution_template_dir

Returns the name of the directory that contains the distribution templates.

The default path is ~/.templates/modules. You can override this in a subclass.

description

Returns the description of the module.

The default name is TODO: describe this module. You can override this in a subclass.

module_template_basename

Returns the name of the file that is the module.

The default name is Foo.pm. You can override this in a subclass.

module( [ MODULE_NAME ] )

Return the module name. With an argument, set the module name.

module_path()

Return the module path under lib/. You must have set module already.

dist( [ DIST_NAME ] )

Return the dist name. With an argument, set the module name.

module_to_distname( MODULE_NAME )

Take a module name, such as Foo::Bar, and turn it into a distribution name, such as Foo-Bar.

prompt( MESSAGE )

Show the user MESSAGE, grap a line from STDIN, and return it.

TO DO

Right now, Distribution::Cooker uses the defaults that I like, but that should come from a configuration file.

SEE ALSO

Other modules, such as Module:Starter, do a similar job but don't give you as much flexibility with your templates.

SOURCE AVAILABILITY

This module is in Github:

http://github.com/briandfoy/distribution-cooker/

AUTHOR

brian d foy, <bdfoy@cpan.org>

COPYRIGHT AND LICENSE

Copyright © 2008-2018, brian d foy <bdfoy@cpan.org>. All rights reserved.

You may redistribute this under the same terms as Perl itself.