| 1 | package ETLp::Plugin; | ||
| 2 | |||
| 3 | use MooseX::Declare; | ||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | ETLp::Plugin - The base class for ETLp plugins | ||
| 8 | |||
| 9 | =head1 DESCRIPTION | ||
| 10 | |||
| 11 | All Plugins should inherit from this class: | ||
| 12 | |||
| 13 | use MooseX::Declare; | ||
| 14 | class My::ETLp::Plugin::WebService extends ETLp::Plugin { | ||
| 15 | sub type { | ||
| 16 | return 'my_web_service'; | ||
| 17 | } | ||
| 18 | |||
| 19 | method run { | ||
| 20 | .... <<code>> .... | ||
| 21 | } | ||
| 22 | } | ||
| 23 | |||
| 24 | Any plugins must provide the following methods | ||
| 25 | |||
| 26 | =head2 type | ||
| 27 | |||
| 28 | This should simply return the item type that the plugin seeks to service. | ||
| 29 | Note that the MooseX::Declare "method" keyword should bot be used | ||
| 30 | |||
| 31 | =head2 run | ||
| 32 | |||
| 33 | This is the code that performs the functionality of the plugin. If it is | ||
| 34 | an iterative plugin, it must accept the name of a file: | ||
| 35 | |||
| 36 | method run(Str $filename) { | ||
| 37 | .... <<code>> .... | ||
| 38 | } | ||
| 39 | |||
| 40 | =cut | ||
| 41 | |||
| 42 | class ETLp::Plugin with ETLp::Role::Config { | ||
| 43 | use ETLp::Exception; | ||
| 44 | |||
| 45 | has 'config' => (is => 'ro', isa => 'HashRef', required => 1); | ||
| 46 | has 'item' => (is => 'ro', isa => 'HashRef', required => 1); | ||
| 47 | has 'original_item' => (is => 'ro', isa => 'HashRef', required => 1); | ||
| 48 | has 'env_conf' => (is => 'ro', isa => 'HashRef', required => 1); | ||
| 49 | |||
| 50 | sub type { | ||
| 51 | ETLpException->throw(error => "Abstract method 'type'"); | ||
| 52 | } | ||
| 53 | |||
| 54 | method run { | ||
| 55 | ETLpException->throw(error => "Abstract method 'run'"); | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | =head1 LICENSE AND COPYRIGHT | ||
| 60 | |||
| 61 | Copyright 2010 Redbone Systems Ltd | ||
| 62 | |||
| 63 | This program is free software; you can redistribute it and/or modify it | ||
| 64 | under the terms of either: the GNU General Public License as published | ||
| 65 | by the Free Software Foundation; or the Artistic License. | ||
| 66 | |||
| 67 | The terms are in the LICENSE file that accompanies this application | ||
| 68 | |||
| 69 | =cut | ||
| 70 |