Dist::Zilla::Role::Stash::Plugins(3)

NAME
Dist::Zilla::Role::Stash::Plugins - A Stash that stores arguments for plugins

VERSION
version 1.006

SYNOPSIS
  # in Dist::Zilla::Stash::MyStash

  with 'Dist::Zilla::Role::Stash::Plugins';

DESCRIPTION
This is a role for a Stash that stores arguments for other plugins.

Stashes performing this role must define expand_package.

ATTRIBUTES

  argument_separator
A regular expression that will capture the package name in $1 and the attribute name in $2.

Defaults to "(.+?)\W+(\w+)" which means the package variable and the attribute will be separated by non-word characters (which assumes the attributes will be only word characters/valid perl identifiers).

You will need to set this attribute in your stash if you need to assign to an attribute in a package that contains non-word characters. This is an example (taken from the tests in t/ini-sep).

  # dist.ini
  [%Example]
  argument_separator = ([^|]+)\|([^|]+?)
  -PlugName|Attr::Name = oops
  +Mod::Name|!goo-ber = nuts

Note that the regexp should not be anchored as it actually becomes the middle of a larger regexp (see "separator" in Config::MVP::Slicer).

  _config
Contains the dynamic options.

Inherited from Dist::Zilla::Role::DynamicConfig.

Rather than accessing this directly, consider "get_stashed_config" or "merge_stashed_config".

  slicer
Instance of "Config::MVP::Slicer" which handles plugin configuration extraction.

METHODS

  get_stashed_config
Return a hashref of the config arguments for the plugin. This is a thin wrapper around "slice" in Config::MVP::Slicer.

  # with a stash of:
  # _config => {
  #   'APlug.attr1'   => 'value1',
  #   'APlug.second'  => '2nd',
  #   'OtherPlug.attr => '0'
  # }

  # from inside Dist::Zilla::Plugin::APlug

  if( my $stash = $self->zilla->stash_named('%Example') ){
    my $stashed = $stash->get_stashed_config($self);
  }

  # $stashed => {
  #   'attr1'   => 'value1',
  #   'second'  => '2nd'
  # }

  merge_stashed_config
  $stash->merge_stashed_config($plugin, \%opts);

Get the stashed config (see "get_stashed_config"), then attempt to merge it into the plugin.

This require the plugin's attributes to be writable ('rw').

This is a thin wrapper around "merge" in Config::MVP::Slicer.

Possible options:

•   stashed

    A hashref like that returned from "get_stashed_config". If not present, "get_stashed_config" will be called.

  separate_local_config
Removes any hash keys that are only word characters (valid perl identifiers (including "argument_separator")) because the dynamic keys intended for other plugins will all contain non-word characters.

Overwrite this if necessary.

SEE ALSO

•   Config::MVP::Slicer

SUPPORT

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

  perldoc Dist::Zilla::Role::Stash::Plugins

  Websites
The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources.

•   Search CPAN

    The default CPAN search engine, useful to view POD in HTML format.

    <http://search.cpan.org/dist/Dist-Zilla-Role-Stash-Plugins>

•   RT: CPAN's Bug Tracker

    The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.

    <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dist-Zilla-Role-Stash-Plugins>

•   CPAN Ratings

    The CPAN Ratings is a website that allows community ratings and reviews of Perl modules.

    <http://cpanratings.perl.org/d/Dist-Zilla-Role-Stash-Plugins>

•   CPAN Testers

    The CPAN Testers is a network of smokers who run automated tests on uploaded CPAN distributions.

    <http://www.cpantesters.org/distro/D/Dist-Zilla-Role-Stash-Plugins>

•   CPAN Testers Matrix

    The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.

    <http://matrix.cpantesters.org/?dist=Dist-Zilla-Role-Stash-Plugins>

•   CPAN Testers Dependencies

    The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.

    <http://deps.cpantesters.org/?module=Dist::Zilla::Role::Stash::Plugins>

  Bugs / Feature Requests
Please report any bugs or feature requests by email to "bug-dist-zilla-role-stash-plugins at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dist-Zilla-Role-Stash-Plugins>. You will be automatically notified of any progress on the request by the system.

  Source Code
<https://github.com/rwstauner/Dist-Zilla-Role-Stash-Plugins>

  git clone https://github.com/rwstauner/Dist-Zilla-Role-Stash-Plugins.git

AUTHOR
Randy Stauner <rwstauner@cpan.org>

COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Randy Stauner.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.