NAME

Module::Generate - Assisting with module generation.

VERSION

Version 0.16

SYNOPSIS

        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;

SUBROUTINES/METHODS

dist

Provide a name for the distribution.

        my $dist = Module::Generate->dist('Planes');

lib

Provide a path where the generated files will be compiled.

        my $module = Module::Generate->lib('./path/to/lib');

author

The author of the distribution/module.

        my $module = Module::Generate->author('LNATION');

email

The authors email of the distribution/module.

        my $module = Module::Generate->email('email@lnation.org');

version

The version number of the distribution/module.

        my $version = Module::Generate->version('0.01');

class

Start a new class/package/module..

        my $class = Module::Generate->class('Planes');

abstract

Provide abstract text for the class.

        $class->abstract('Over my head.');

synopsis

Provide a synopsis for the class.

        $class->synopsis('...');

use

Declare modules that should be included in the class.

        $class->use(qw/Moo MooX::LazierAttributes/);

base

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/);

paarent

Establish an ISA relationship with base classes at compile time.

        $class->parent(qw/Foo Bar/);

require

Require library files to be included if they have not already been included.

        $class->require(qw/Foo Bar/);

our

Declare variable of the same name in the current package for use within the lexical scope.

        $class->our(qw/$one $two/);

begin

Define a code block is executed as soon as possible.

        $class->begin(sub {
                ...
        });

unitcheck

Define a code block that is executed just after the unit which defined them has been compiled.

        $class->unitcheck(sub {
                ...
        });

check

Define a code block that is executed just after the initial Perl compile phase ends and before the run time begins.

        $class->check(sub {
                ...
        });

init

Define a code block that is executed just before the Perl runtime begins execution.

        $class->init(sub {
                ...
        });

end

Define a code block is executed as late as possible.

        $class->end(sub {
                ...
        });

new

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 { ... });

accessor

Define a accessor.

        $class->accessor('test');

equivalent to:

        sub test {      
                my ($self, $value) = @_;
                if ($value) {
                        $self->{$sub} = $value;
                }
                return $self->{$sub}
        }";

sub

Define a sub routine/method.

        my $sub = $class->sub('name');

code

Define the code that will be run for the sub.

        $sub->code(sub {
                return 'Robert';
        });

pod

Provide pod text that describes the sub.

        $sub->pod('What is my name?');

example

Provide a code example which will be suffixed to the pod definition.

        $sub->example('$foo->name');

build

Compile the code.

        $sub->build(%args);

AUTHOR

LNATION, <email at lnation.org>

BUGS

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.

SUPPORT

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

    perldoc Module::Generate

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2020 by LNATION.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)