Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

tokuhirom (7396)

tokuhirom
  (email not shown publicly)
http://d.hatena.ne.jp/tokuhirom/

Journal of tokuhirom (7396)

Thursday May 29, 2008
09:32 PM

MooseX::Plaggerize

[ #36547 ]
### DESCRIPTION

I want to use Plagger style plugins architecture with Moose.Therefore, I created MooseX::Plaggerize!

svn repos is here: http://svn.coderepos.org/share/lang/perl/MooseX-Plaggerize/trunk/

### SYNOPSIS

    # in main

    my $c = Your::Context->new;
    $c->load_config('config.yaml'); # feature of MooseX::Plaggerize::ConfigLoader
    $c->load_plugin('HTMLFilter::StickyTime');
    $c->load_plugin({module => 'HTMLFilter::DocRoot', config => { root => '/mobirc/' }});
    $c->run();

    package Your::Context;
    use Moose;
    with 'MooseX::Plaggerize', 'MooseX::Plaggerize::ConfigLoader';

    sub run {
        my $self = shift;

        $self->run_hook('response_filter' => $args);
    }

    package Your::Plugin::HTMLFilter::StickyTime;
    use strict;
    use MooseX::Plaggerize::Plugin;

    hook 'response_filter' => sub {
        my ($self, $context, $args) = @_;
    };

### CONCEPT

* Plugin architecture like Plagger
* Each plugin has own instance
* Each plugin can have own configuration

### What's difference with MooseX::Object::Pluggable?

yeah, I know MooseX::Object::Pluggable, ofcource.

MooseX::Object::Pluggable stands on Moose::Role and method modifiers.This is cool architecture.

But, this approach cannot use configuration like Plagger :(

therefore, I wrote MooseX::Plaggerize :)

### ...

We would like to hear from you
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • There is a MooseX::Object::Pluggable [cpan.org] on CPAN which the synopsis suggests does almost exactly the same thing as your module – and as a bonus, it has a much better name. For config loading there are already MooseX::ConfigFromFile [cpan.org] and MooseX::SimpleConfig [cpan.org]. Do none of these do what you need/want?

    • "MooseX::Plaggerize instanciates each plugins, and each plugin has own configuration" is core concept of MooseX::Plaggerize.MooseX::Object::Pluggable is not matched to this use case.

      and, configuration file loader is not a key feature, that is trivial :)
      • hmm... please read source.
      • Ah, I see, OK.

        You still need a better name though – even someone who knows what Plagger is would have no idea what “Plaggerize” means until you tell them. It’s pretty much as if you had called the module MooseX::FooBaz.

        How about MooseX::Hookable? That seems to describe the functionality you want to offer.

  • Sometimes, when I realize I can reuse something I liked in more places, I get too excited and act like everyone should like what I've done. So maybe you should ignore this.

    I recently uploaded Config::INI::MVP::Reader, which I use in a few things to initialize plugins based on configuration. You might find it useful for doing some similar, simple things with Plaggerize.

    Every time I see Plaggerize in the RSS feed, I think "plagarize." :-)
    --
    rjbs