Module::Setup::Plugin - Module::Setup Plugin


Module-Setup documentation Contained in the Module-Setup distribution.

Index


Code Index:

NAME

Top

Module::Setup::Plugin - Module::Setup Plugin

Trigger Point

Top

before_dump_config $config

config setup Module::Setup::Plugin::Config::Basic

after_setup_module_attribute

module attribute setup Module::Setup::Plugin::VC::SVN

after_setup_template_vars

template parameters setup

append_template_file

add module template file for new module Module::Setup::Plugin::VC::Git

template_process $options

for template process Module::Setup::Plugin::Template

replace_distribute_path $options

for distribute path rewrite phase

check_skeleton_directory

  for test L<Module::Setup::Plugin::Test::Makefile>

after_create_skeleton

after create_skeleton

finalize_create_skeleton

last trigger of run method on skeleton directory

finish_of_run

last hook of run method Module::Setup::Plugin::VC::SVK

Plugin Example

Top

~/.module-setup/flavor/myflavor/plugins/plugin.pm package MyFlavor::Plugin; use strict; use warnings; use base 'Module::Setup::Plugin';

  sub register {
      my($self, ) = @_;
      $self->add_trigger( check_skeleton_directory => \&check_skeleton_directory );
  }

  sub check_skeleton_directory {
      my $self = shift;
  }

~/.module-setup/flavor/myflavor/config.yaml

  config:
    plugins:
      - Config::Basic
      - VC::SVN
      - Template
      - Test::Makefile
      - +MyFlavor::Plugin

or command option

  $ module-setup --plugin=+MyFlavor::Plugin New::Module


Module-Setup documentation Contained in the Module-Setup distribution.

package Module::Setup::Plugin;
use strict;
use warnings;

use Scalar::Util qw(weaken);

use Module::Setup::Flavor;
use Module::Setup::Path::Dir;

sub new {
    my($class, %args) = @_;
    my $self = bless { %args }, $class;
    weaken $self->{context};
    $self->register;
    $self;
}

sub register {}

sub add_trigger {
    my($self, @args) = @_;
    $self->{context}->add_trigger(@args);
}

sub append_template_file {
    my($self, $context, $caller) = @_;
    $caller = caller unless $caller;
    my @template = Module::Setup::Flavor::loader($caller);

    for my $tmpl (@template) {
        if (exists $tmpl->{dir}) {
            Module::Setup::Path::Dir->new($context->distribute->dist_path, split('/', $tmpl->{dir}))->mkpath;
            next;
        } elsif (!exists $tmpl->{file}) {
            next;
        }
        my $options = {
            dist_path => $context->distribute->dist_path->file(split('/', $tmpl->{file})),
            template  => $tmpl->{template},
            vars      => $context->distribute->template_vars,
            content   => undef,
        };
        $options->{chmod} = $tmpl->{chmod} if $tmpl->{chmod};
        $context->distribute->write_template($context, $options);
    }
}

1;

__END__