NAME

Module::Cooker - Module starter kit based on Template

VERSION

Version v0.1.4

SYNOPSIS

use Module::Cooker;
 
my $mc = Module::Cooker->new( %params );
$mc->cook();
 

DESCRIPTION

You are probably more interested in the command line interface to this module: modcooker

CONSTRUCTOR

new

Here are the default vaues for the attributes:

my $defaults = {
    minperl   => '',
    author    => 'A. Uthor',
    email     => 'author@example.com',
    profile   => 'default',
    package   => 'My::MC::Module',
    version   => 'v0.1_1',
    extravars => {},
    localdirs => [],
    nosubs    => 0,
};
 
package

A string representing the name of the package/module. I.e. My::New::Module

minperl

A string representing the minimum version of Perl require to use the module. I.e. 'v5.8.8' or '5.8.8' or even '5.008008'. Default: '' (empty string)

author

A string with the author's name. Default: '' (empty string);

email

A string with the author's email. Default: '' (empty string);

profile

The profile from which the module should be built from. Default: 'default'

version

A string representing the version of the new module. Default: 'v0.1_1'

extravars

This option creates a hash ref that is eventually passed as part of the data structure that Template will use as substitution variables. Any element in the hash ref can be accessed as extra.element_name in a template file.

localdirs

The directory (or directories if specified multiple times) to search in addition to the standard distrubution profile directory for the profile named by the '--profile' parameter. This is built as an array ref. Default: []

nosubs

Boolean flag indicating that subdirectories in the profile should NOT be searched for template files. (Will probably be removed in the next release.) Default: 0

ACCESSORS

There is a read-only accessor provided for each of the parameters accepted by new.

You can also obtain a hash (or hashref) with the values for each parameter by using the "summary" method described below.

METHODS

cook

This is the method that does the real work of the module. Based upon the parameters used to construct the object, it will search the profile directory(ies) for the specified profile. It will then build a list of files in the profile to be processed by Template.

The processed files will be placed under a distribution directory created in the current directly. A MANIFEST will be built at the completion of this processing.

An exception will be thrown if the distribution directory already exists.

dist_name

print $mc->dist_name . "\n";   # prints My-MC-Module
 

Read-only method that returns the name of the distrubution as derived from the package name. This is the name that is used to create the top-level directory for the distrubution. '::' sequences are transformed to '-' in accordance with normal CPAN practice.

module_name

print $mc->module_name . "\n";   # prints Module.pm
 

Read-only method that returns the name of main module in the distrubution. This is derived by taking the final element of the package name and appending '.pm' to it.

profile_dirs

Read-only method that returns a list of directories that contain a sub-directory with the same name as the requested profile.

The method will return either an array or array reference depending upon the calling context.

template_data

my $template_data = $mc->template_data;
my %template_data = $mc->template_data;
 
print Dumper($template_data);
 
$VAR1 = {
  'author' => {
    'name'  => 'A. Uthor'
    'email' => 'author@example.com',
  },
  'modcooker' => {
    'version' => '0.01'
    'perlver' => '5.010001',
  },
  'package' => {
    'name'       => 'My::MC::Module',
    'dist_name'  => 'My-MC-Module',
    'version'    => 'v0.1_1',
    'minperl'    => '',
    'libpath'    => 'lib/My/MC',
    'module'     => 'Module.pm'
    'modulepath' => 'lib/My/MC/Module.pm',
    'timestamp'  => '2013-11-28 16:40:23',
    'year'       => '2013'
  }
};
 

Read-only method that returns a copy of the data that will be passed to Template to be used for variable substitution. It should be noted that this is a copy and changes made to the returned structure will not affect what is actually passed on.

The method will return either a hash or hash reference depending upon the calling context.

basename_dir

Read-only method that returns the absolute path to where the module is located in the @INC search path with the name of this module (Cooker) appended. This is used to located the module's standard template directories.

std_profiles_dir

Read-only method that returns the absolute path to where the standard profiles are located in the distribution.

summary

my $summary = $mc->summary;
my %summary = $mc->summary;
 
print Dumper($summary);
 
$VAR1 = {
  'nosubs'    => 0,
  'profile'   => 'default',
  'localdirs' => [],
  'version'   => 'v0.1_1',
  'author'    => 'A. Uthor',
  'extravars' => {},
  'package'   => 'My::MC::Module',
  'minperl'   => '',
  'email'     => 'author@example.com'
};
 

Read-only method that returns a copy of the data stored in the internal attributes after object construction. It should be noted that this is a copy and changes made to the structure will not affect the object itself.

The method will return either a hash or hash reference depending upon the calling context.

AUTHOR

Jim Bacon, <jim at nortx.com>

BUGS

Please report any bugs or feature requests to bug-module-cooker at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Cooker. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

You can also submit an issue via the GitHub repository listed below.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Module::Cooker

You can also look for information at:

ACKNOWLEDGEMENTS

This module draws heavily upon ideas found in Distribution::Cooker, ExtUtils::ModuleMaker and Module::Starter.

Special thanks goes to Perl Monk tobyink for the module name regex pattern and the Perl Monks who assisted with peer review of the code, test suite, and documentation.

SEE ALSO

Template, Jose's Guide for Creating Perl modules

LICENSE AND COPYRIGHT

Copyright 2013 Jim Bacon.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.