Module::Generate - Assisting with module generation.
Version 0.15
use Module::Generate; Module::Generate->dist('Planes') ->author('LNATION') ->email('email@lnation.org') ->version('0.01') ->class('Planes') ->abstract('Over my head.') ->our('$type') ->begin(sub { $type = 'boeing'; }) ->new ->pod('Instantiate a new plane.') ->example('my $plane = Planes->new') ->accessor('airline') ->sub('type') ->code(sub { $type }) ->pod('Returns the type of plane.') ->example('$plane->type') ->sub('altitude') ->code(sub { $_[1] / $_[2]; ... }) ->pod('Discover the altitude of the plane.') ->example('$plane->altitude(100, 100)') ->generate; ... Module::Generate->dist('Holiday') ->author('LNATION') ->email('email@lnation.org') ->version('0.01') ->class('Feed::Data') ->use('Data::LnArray') ->our('$holiday') ->begin(sub { $holiday = Data::LnArray->new; }) ->sub('parse') ->sub('write') ->sub('render') ->sub('generate') ->sub('_raw') ->sub('_text') ->sub('_json') ->generate;
Provide a name for the distribution.
my $dist = Module::Generate->dist('Planes');
Provide a path where the generated files will be compiled.
my $module = Module::Generate->lib('./path/to/lib');
The author of the distribution/module.
my $module = Module::Generate->author('LNATION');
The authors email of the distribution/module.
my $module = Module::Generate->email('email@lnation.org');
The version number of the distribution/module.
my $version = Module::Generate->version('0.01');
Start a new class/package/module..
my $class = Module::Generate->class('Planes');
Provide abstract text for the class.
$class->abstract('Over my head.');
Provide a synopsis for the class.
$class->synopsis('...');
Declare modules that should be included in the class.
$class->use(qw/Moo MooX::LazierAttributes/);
Establish an ISA relationship with base classes at compile time.
Unless you are using the fields pragma, consider this discouraged in favor of the lighter-weight parent.
$class->base(qw/Foo Bar/);
$class->parent(qw/Foo Bar/);
Require library files to be included if they have not already been included.
$class->require(qw/Foo Bar/);
Declare variable of the same name in the current package for use within the lexical scope.
$class->our(qw/$one $two/);
Define a code block is executed as soon as possible.
$class->begin(sub { ... });
Define a code block that is executed just after the unit which defined them has been compiled.
$class->unitcheck(sub { ... });
Define a code block that is executed just after the initial Perl compile phase ends and before the run time begins.
$class->check(sub { ... });
Define a code block that is executed just before the Perl runtime begins execution.
$class->init(sub { ... });
Define a code block is executed as late as possible.
$class->end(sub { ... });
Define an object constructor.
$class->new;
equivalent to:
sub new { my ($cls, %args) = (shift, scalar @_ == 1 ? %{$_[0]} : @_); bless \%args, $cls; }
optionally you can pass your own sub routine.
$class->new(sub { ... });
Define a accessor.
$class->accessor('test');
sub test { my ($self, $value) = @_; if ($value) { $self->{$sub} = $value; } return $self->{$sub} }";
Define a sub routine/method.
my $sub = $class->sub('name');
Define the code that will be run for the sub.
$sub->code(sub { return 'Robert'; });
Provide pod text that describes the sub.
$sub->pod('What is my name?');
Provide a code example which will be suffixed to the pod definition.
$sub->example('$foo->name');
Compile the code.
$sub->build(%args);
LNATION, <email at lnation.org>
<email at lnation.org>
Please report any bugs or feature requests to bug-module-generate at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Generate. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-module-generate at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Module::Generate
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=Module-Generate
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Module-Generate
CPAN Ratings
https://cpanratings.perl.org/d/Module-Generate
Search CPAN
https://metacpan.org/release/Module-Generate
This software is Copyright (c) 2020 by LNATION.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Module::Generate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Module::Generate
CPAN shell
perl -MCPAN -e shell install Module::Generate
For more information on module installation, please visit the detailed CPAN module installation guide.