Distribution::Cooker - Create a module directory from your own templates
use Distribution::Cooker; Distribution::Cooker->run( ... ); # most of this should go through the dist_cooker sketch
- 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.
Create the bare object. There's nothing fancy here, but if you need something more powerful you can create a subclass.
Initialize the object. There's nothing fancy here, but if you need something more powerful you can create a subclass.
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.
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.
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
- Your distribution template directory is ~/.templates/dist_cooker
- Your module template name is lib/Foo.pm
cookprocesses 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,
cookignores .git, .svn, and CVS directories.
- ttree (from Template) is in
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.
Returns the name of the directory that contains the distribution templates.
The default path is ~/.templates/modules. You can override this in a subclass.
Returns the description of the module.
The default name is
TODO: describe this module. You can override this in a subclass.
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.
Return the module path under lib/. You must have set
- 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
- prompt( MESSAGE )
Show the user MESSAGE, grap a line from STDIN, and return it.
Distribution::Cooker uses the defaults that I like, but that should come from a configuration file.
Other modules, such as
Module:Starter, do a similar job but don't give you as much flexibility with your templates.
This module is in Github:
brian d foy,
Copyright © 2008-2018, brian d foy <email@example.com>. All rights reserved.
You may redistribute this under the same terms as Perl itself.