.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Mason::Manual::Plugins 3pm" .TH Mason::Manual::Plugins 3pm "2012-05-02" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mason::Manual::Plugins \- Mason plugins .SH "DESCRIPTION" .IX Header "DESCRIPTION" A Mason plugin modifies behavior in one or more of Mason's main classes simultaneously, using Moose roles. Many Mason features, even some that might be considered \*(L"core\*(R", are implemented with plugins. .SH "FINDING PLUGINS" .IX Header "FINDING PLUGINS" By convention plugins live in the \*(L"Mason::Plugin::*\*(R" namespace, and plugin bundles live in the \*(L"Mason::PluginBundle::*\*(R" namespace. You can find both with this search: .PP .Vb 1 \& http://search.cpan.org/search?query=Mason%3A%3APlugin&mode=all .Ve .SH "USING PLUGINS" .IX Header "USING PLUGINS" Pass a list of plugin specs to the Mason constructor: .PP .Vb 9 \& Mason\->new(plugins => \& [ \& \*(AqOnePlugin\*(Aq, \& \*(AqAnotherPlugin\*(Aq, \& \*(Aq+My::Mason::Plugin::AThirdPlugin\*(Aq, \& \*(Aq@APluginBundle\*(Aq, \& \*(Aq+My::Mason::PluginBundle::AnotherBundle\*(Aq, \& \*(Aq\-PluginIDontLike\*(Aq, \& ]); .Ve .PP Each plugin spec can be one of the following; .IP "\(bu" 4 A simple name, which will have \*(L"Mason::Plugin::\*(R" prepended to it. .IP "\(bu" 4 A bundle name, prefixed with '@', which will have \*(L"Mason::PluginBundle::\*(R" prepended to it. .IP "\(bu" 4 A full plugin or bundle class name prefixed with '+'. .IP "\(bu" 4 Any spec prefixed with '\-', which means do not include these plugin(s) in the final list. .PP See Mason::t::Plugins::test_plugin_specs in the Mason distribution for some examples. .SH "DEFAULT PLUGINS" .IX Header "DEFAULT PLUGINS" Mason will always add the \f(CW@Default\fR bundle regardless of whether you pass your own list. You can remove individual default plugins that you don't like: .PP .Vb 1 \& plugins => [\*(Aq\-DollarDot\*(Aq, ...] .Ve .PP or the whole list: .PP .Vb 1 \& plugins => [\*(Aq\-@Default\*(Aq, ...] .Ve .SH "CREATING PLUGINS" .IX Header "CREATING PLUGINS" Note: If you want to modify behavior for a particular application only, it might be more convenient to create subclasses. .PP A plugin consists of the main plugin class and one or more roles. The main class currently looks like this: .PP .Vb 3 \& package Mason::Plugin::MyPlugin; \& use Moose; \& with \*(AqMason::Plugin\*(Aq; \& \& # Optional: declare other plugin dependencies \& method requires_plugins { qw(A @D) } \& \& 1; \& \& _\|_END_\|_ \& \& =pod \& \& =head1 NAME \& \& Mason::Plugin::MyPlugin \- My plugin \& \& .... .Ve .PP Its main responsibilities are to include the role 'Mason::Plugin' and document itself. It may also specify a \f(CW\*(C`requires_plugins\*(C'\fR that returns a list of dependencies with the same syntax as the \f(CW\*(C`plugins\*(C'\fR parameter to \f(CW\*(C`Mason\-\*(C'\fRnew>. .PP The real action is in the role classes, which live underneath, and each modify a single Mason class: .PP .Vb 2 \& package Mason::Plugin::MyPlugin::Interp; \& use Mason::PluginRole; \& \& # Modify Mason::Interp \& \& ... \& \& package Mason::Plugin::MyPlugin::Compilation; \& use Mason::PluginRole; \& \& # Modify Mason::Compilation \& \& ... .Ve .PP When a plugin is applied, each of its roles will be automatically applied to the appropriate Mason class. For example, in the example above \&\f(CW\*(C`Mason::Plugin::MyPlugin::Interp\*(C'\fR and \f(CW\*(C`Mason::Plugin::MyPlugin::Compilation\*(C'\fR will be applied to Mason::Interp and Mason::Compilation respectively. .SS "Pluggable Mason classes" .IX Subsection "Pluggable Mason classes" As of this writing the following Mason classes can be modified with plugins: .PP .Vb 9 \& Mason::CodeCache \& Mason::Compilation \& Mason::Component \& Mason::Component::ClassMeta \& Mason::Component::Import \& Mason::Component::Moose \& Mason::Interp \& Mason::Request \& Mason::Result .Ve .SS "Extra classes in plugin" .IX Subsection "Extra classes in plugin" If you have extra classes in your plugin that aren't automatically providing a role to a Mason class, put them in \f(CW\*(C`Extra.pm\*(C'\fR or the \f(CW\*(C`Extra\*(C'\fR subdirectory, e.g. .PP .Vb 2 \& package Mason::Plugin::MyPlugin::Extra::Utils; \& ... .Ve .PP That will ensure that your classname will not conflict with a future Mason class name. .SH "CREATING PLUGIN BUNDLES" .IX Header "CREATING PLUGIN BUNDLES" A plugin bundle just collects one or more plugins and/or other bundles. It looks like this: .PP .Vb 3 \& package Mason::PluginBundle::MyBundle \& use Moose; \& with \*(AqMason::PluginBundle\*(Aq; \& \& sub requires_plugins { \& return ( \& \*(AqA\*(Aq, \& \*(AqB\*(Aq, \& \*(Aq+My::Plugin::C\*(Aq, \& \*(Aq@D\*(Aq, \& \*(Aq+My::PluginBundle::E\*(Aq, \& ); \& } \& \& 1; \& \& _\|_END_\|_ \& \& =pod \& \& =head1 NAME \& \& Mason::PluginBundle::MyBundle \- My plugin bundle \& \& =head1 INCLUDED PLUGINS \& \& =over \& \& =item A \& =item B \& =item +My::Plugin::C \& =item @D \& =item +My::PluginBundle::E \& \& =back \& \& .... .Ve .PP The \f(CW\*(C`requires_plugins\*(C'\fR method returns a list of entries, with the same syntax as the \f(CW\*(C`plugins\*(C'\fR parameter to \f(CW\*(C`Mason\-\*(C'\fRnew>. .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" Thanks to Ricardo Signes for Dist::Zilla and Pod::Weaver, which got me thinking in plugins and lent the plugin and bundle name syntax. .SH "SEE ALSO" .IX Header "SEE ALSO" Mason .SH "AUTHOR" .IX Header "AUTHOR" Jonathan Swartz .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2011 by Jonathan Swartz. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.