Changeset 1787

Show
Ignore:
Timestamp:
02/28/06 18:44:09
Author:
miyagawa
Message:

0.02; added resolved_count

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • HTML-ResolveLink/trunk/Changes

    r1785 r1787  
    11Revision history for Perl extension HTML::ResolveLink 
     2 
     30.02  2006-02-28T09:36:47Z 
     4        - Added resolved_count method 
    25 
    360.01  Tue Feb 28 07:09:08 2006 
  • HTML-ResolveLink/trunk/MANIFEST

    r1785 r1787  
    55t/00_compile.t 
    66t/01_resolve.t 
     7META.yml                                 Module meta-data (added by MakeMaker) 
  • HTML-ResolveLink/trunk/lib/HTML/ResolveLink.pm

    r1786 r1787  
    22 
    33use strict; 
    4 our $VERSION = '0.01'; 
     4our $VERSION = '0.02'; 
    55use base qw(HTML::Parser); 
    66 
     
    4848            $uri = $uri->abs($base); 
    4949            $attr->{$a} = $uri->as_string; 
     50            $self->{resolvelink_count}++; 
    5051        } 
    5152    } 
     
    8283    my($self, $html) = @_; 
    8384 
    84     $self->{resolvelink_html} = ''; # init 
     85    # init 
     86    $self->{resolvelink_html} = ''; 
     87    $self->{resolvelink_count} = 0; 
     88 
    8589    $self->parse($html); 
    8690    $self->eof; 
    8791 
    8892    $self->{resolvelink_html}; 
     93} 
     94 
     95sub resolved_count { 
     96    my $self = shift; 
     97    $self->{resolvelink_count}; 
    8998} 
    9099 
     
    104113  ); 
    105114  $html = $resolver->resolve($html); 
     115 
     116  if ($resolver->resolved_count) { 
     117      ... 
     118  } 
    106119 
    107120=head1 DESCRIPTION 
     
    142155string containing rewritten one. 
    143156 
     157=item resolved_count 
     158 
     159  $count = $resolver->resolved_count; 
     160 
     161Returns how many URIs are resolved during the previous I<resolve> 
     162method call. This should be called after the I<resolve>, otherwise 
     163returns undef. 
     164 
    144165=head1 AUTHOR 
    145166 
  • HTML-ResolveLink/trunk/t/01_resolve.t

    r1786 r1787  
    11use strict; 
    2 use Test::More tests => 2
     2use Test::More tests => 4
    33use HTML::ResolveLink; 
    44 
     
    2222HTML 
    2323 
     24is $resolver->resolved_count, 3; 
     25 
    2426$html = $resolver->resolve(<<'HTML'); 
    2527<base href="http://www.google.com/"> 
     
    3638HTML 
    3739    ; 
     40 
     41is $resolver->resolved_count, 2; 
     42