[Bps-public-commit] r11959 - in HTML-RewriteAttributes: . lib/HTML

sartak at bestpractical.com sartak at bestpractical.com
Tue Apr 29 17:10:36 EDT 2008


Author: sartak
Date: Tue Apr 29 17:10:36 2008
New Revision: 11959

Modified:
   HTML-RewriteAttributes/   (props changed)
   HTML-RewriteAttributes/lib/HTML/RewriteAttributes.pm
   HTML-RewriteAttributes/t/000-synopsis.t

Log:
 r54655 at onn:  sartak | 2008-04-29 16:50:43 -0400
 Channel HTML::LinkExtor in the synopsis


Modified: HTML-RewriteAttributes/lib/HTML/RewriteAttributes.pm
==============================================================================
--- HTML-RewriteAttributes/lib/HTML/RewriteAttributes.pm	(original)
+++ HTML-RewriteAttributes/lib/HTML/RewriteAttributes.pm	Tue Apr 29 17:10:36 2008
@@ -121,6 +121,12 @@
     use HTML::RewriteAttributes::Links;
     $html = HTML::RewriteAttributes::Links->rewrite($html, "http://search.cpan.org");
 
+    HTML::RewriteAttributes::Links->rewrite($html, sub {
+        my ($tag, $attr, $value) = @_;
+        push @links, $value;
+        $value;
+    });
+
 =cut
 
 1;

Modified: HTML-RewriteAttributes/t/000-synopsis.t
==============================================================================
--- HTML-RewriteAttributes/t/000-synopsis.t	(original)
+++ HTML-RewriteAttributes/t/000-synopsis.t	Tue Apr 29 17:10:36 2008
@@ -1,7 +1,7 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 3;
+use Test::More tests => 4;
 
 # RewriteAttributes {{{
 my $html = << "END";
@@ -86,6 +86,22 @@
 END
 
 use HTML::RewriteAttributes::Links;
+my @links;
+HTML::RewriteAttributes::Links->rewrite($html, sub {
+    my ($tag, $attr, $value) = @_;
+    push @links, $value;
+    $value
+});
+
+is_deeply(\@links, [
+    "baroque.jpg",
+    "http://en.wikipedia.org/wiki/COBOL",
+    "http://en.wikipedia.org/wiki/FORTRAN",
+    "http://example.com/img/COBOL.bmp",
+    "http://example.com/img/FORTRAN.bmp",
+]);
+
+
 $html = HTML::RewriteAttributes::Links->rewrite($html, "http://search.cpan.org");
 
 is($html, << "END", "rewrote the html correctly");



More information about the Bps-public-commit mailing list