| 1 | package WWW::Link::Repair::Mapper; | ||
| 2 | $REVISION=q$Revision: 1.4 $ ; $VERSION = sprintf ( "%d.%02d", $REVISION =~ /(\d+).(\d+)/ ); | ||
| 3 | |||
| 4 | =head1 NAME | ||
| 5 | |||
| 6 | WWW::Link::Repair::Mapper - map urls to objects which can fix resources | ||
| 7 | |||
| 8 | =head1 SYNOPSIS | ||
| 9 | |||
| 10 | NOT IMPLEMENTED | ||
| 11 | |||
| 12 | =head1 DESCRIPTION | ||
| 13 | |||
| 14 | B<This module is not yet in use. It is a placeholder and I am not yet | ||
| 15 | convinced that it will be used, but it is likely that eventually I | ||
| 16 | will find reason for it.> | ||
| 17 | |||
| 18 | Mapper objects know about how to repair aned edit resources pointed to | ||
| 19 | by specific URLS. | ||
| 20 | |||
| 21 | They match regular expressions against the given URLs in string | ||
| 22 | format. They then apply a translation function if one is provided to | ||
| 23 | translate that url into a new URL. This is repeated until a non | ||
| 24 | remappable translation is found (if more than a maximum number of | ||
| 25 | translations has been carried out the translation dies to detect | ||
| 26 | problems). Finally they apply the functions registered against the | ||
| 27 | finaly translation and do the appropriate editing. | ||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | |||
| 32 | new { | ||
| 33 | my $class = shift; | ||
| 34 | my $self = bless {}, $class; | ||
| 35 | my $self->{"translations"}=[]; | ||
| 36 | } | ||
| 37 | |||
| 38 | add_translation ($) { | ||
| 39 | } | ||
| 40 | |||
| 41 | |||
| 42 | package WWW::Link::Repair::Mapper::Translation; | ||
| 43 | |||
| 44 | =head2 $trans->new() | ||
| 45 | |||
| 46 | We need a regexp, optionally followed by a list of functions that can | ||
| 47 | be applied. | ||
| 48 | |||
| 49 | convert_to_file | ||
| 50 | edit_file | ||
| 51 | convert_from_file | ||
| 52 | edit_in_place | ||
| 53 | |||
| 54 | =cut | ||
| 55 | |||
| 56 | sub new ($$@) { | ||
| 57 | my $class=shift; | ||
| 58 | my $self = bless {}, $class; | ||
| 59 | my $self->{"regexp"}=shift; | ||
| 60 | } | ||
| 61 | |||
| 62 | =head1 apply | ||
| 63 | |||
| 64 | This applies the translation by checking the given url against the | ||
| 65 | |||
| 66 | |||
| 67 | sub apply ($$) { | ||
| 68 | |||
| 69 | |||
| 70 | |||
| 71 |