File Coverage

blib/lib/HTML/LinkChanger/Absolutizer.pm
Criterion Covered Total %
statement 19 19 100.0
branch 2 2 100.0
condition n/a
subroutine 4 4 100.0
pod 0 2 0.0
total 25 27 92.5


line stmt bran cond sub pod time code
1             package HTML::LinkChanger::Absolutizer;
2              
3             # Version: $Id: Absolutizer.pm 4 2007-10-05 15:51:37Z sergey.chernyshev $
4              
5 1     1   838 use strict;
  1         2  
  1         44  
6 1     1   6 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
  1         2  
  1         348  
7              
8             require Exporter;
9             require HTML::LinkChanger::URLFilter;
10             require URI;
11             require HTML::LinkChanger;
12              
13             @ISA = qw(Exporter AutoLoader HTML::LinkChanger::URLFilter);
14             # Items to export into callers namespace by default. Note: do not export
15             # names by default without a very good reason. Use EXPORT_OK instead.
16             # Do not simply export all your public functions/methods/constants.
17             @EXPORT = qw(
18            
19             );
20             $VERSION = sprintf("2.%d", q$Rev: 4 $ =~ /(\d+)/);
21              
22             # Preloaded methods go here.
23              
24             # Autoload methods go after =cut, and are processed by the autosplit program.
25              
26             sub new
27             {
28 2     2 0 197 my $class = shift;
29 2         8 my %args = @_;
30              
31 2 100       21 die "Must specify base URL" unless $args{base_url};
32              
33 1         17 my $self = $class->SUPER::new();
34              
35 1         10 $self->{_absolutizer_base} = URI->new($args{base_url});
36              
37 1         11274 $self;
38             }
39              
40             sub url_filter
41             {
42 3     3 0 4 my $self = shift;
43 3         13 my %args = @_;
44              
45 3         6 my $url = $args{url}; # url of the link
46 3         6 my $tag = $args{tag}; # tag containing a link to change
47 3         4 my $attr = $args{attr}; # attribute containing a link to change
48            
49 3         4 my $base = $self->{_absolutizer_base};
50              
51 3         15 return URI->new($url, $base)->abs($base);
52             }
53              
54             1;
55             __END__