r62611 - in /branches/upstream/libwww-mechanize-perl/current: Changes META.yml Makefile.PL bin/mech-dump lib/WWW/Mechanize.pm t/autocheck.t t/local/failure.t

periapt-guest at users.alioth.debian.org periapt-guest at users.alioth.debian.org
Wed Sep 15 20:25:30 UTC 2010


Author: periapt-guest
Date: Wed Sep 15 20:23:16 2010
New Revision: 62611

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=62611
Log:
[svn-upgrade] new version libwww-mechanize-perl (1.66)

Modified:
    branches/upstream/libwww-mechanize-perl/current/Changes
    branches/upstream/libwww-mechanize-perl/current/META.yml
    branches/upstream/libwww-mechanize-perl/current/Makefile.PL
    branches/upstream/libwww-mechanize-perl/current/bin/mech-dump
    branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize.pm
    branches/upstream/libwww-mechanize-perl/current/t/autocheck.t
    branches/upstream/libwww-mechanize-perl/current/t/local/failure.t

Modified: branches/upstream/libwww-mechanize-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libwww-mechanize-perl/current/Changes?rev=62611&op=diff
==============================================================================
--- branches/upstream/libwww-mechanize-perl/current/Changes (original)
+++ branches/upstream/libwww-mechanize-perl/current/Changes Wed Sep 15 20:23:16 2010
@@ -7,6 +7,27 @@
 
 Mech now has its own mailing list at Google Groups:
 http://groups.google.com/group/www-mechanize-users
+
+
+1.66        Fri Sep 10 16:25:44 CDT 2010
+========================================
+[FIXED]
+Fixed prerequisites on HTTP::Server::Simple on Windows.
+
+DNS checks in t/autocheck.t and t/local/failure.t improved.  Thanks,
+Schwern.
+
+[ENHANCEMENTS]
+New $mech->text method returns the text from your HTML page.  The
+exact rendering of this text is simply removing all the HTML
+tags, but this will change. It's pretty ugly.  If anyone wants to
+work on a better-looking text dump, I'd love to see it.
+
+Added mech-dump --text.
+
+[DOCUMENTATION]
+Improvements to the docs explaining explicitly about the subclassed
+methods we inherit from LWP::UserAgent.  Thanks, Lyle Hopkins!
 
 
 1.64        Thu Jul  1 10:41:00 CDT 2010
@@ -26,7 +47,7 @@
 page to find it.
 
 mech-dump now takes a --cookie-file parameter for keeping cookies
-between calls.
+between calls.  Thanks, Damien Clark.
 
 
 [DOCUMENTATION]

Modified: branches/upstream/libwww-mechanize-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libwww-mechanize-perl/current/META.yml?rev=62611&op=diff
==============================================================================
--- branches/upstream/libwww-mechanize-perl/current/META.yml (original)
+++ branches/upstream/libwww-mechanize-perl/current/META.yml Wed Sep 15 20:23:16 2010
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               WWW-Mechanize
-version:            1.64
+version:            1.66
 abstract:           Handy web browsing in a Perl object
 author:
     - Andy Lester <andy at petdance.com>

Modified: branches/upstream/libwww-mechanize-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libwww-mechanize-perl/current/Makefile.PL?rev=62611&op=diff
==============================================================================
--- branches/upstream/libwww-mechanize-perl/current/Makefile.PL (original)
+++ branches/upstream/libwww-mechanize-perl/current/Makefile.PL Wed Sep 15 20:23:16 2010
@@ -39,6 +39,8 @@
         'HTML::TokeParser'          => 2.28,
         'HTTP::Daemon'              => 0,
         'HTTP::Request'             => 1.30,
+        'HTTP::Server::Simple'      => 0.35,
+        'HTTP::Server::Simple::CGI' => 0,
         'HTTP::Status'              => 0,
         'LWP'                       => 5.829,
         'LWP::UserAgent'            => 5.829,
@@ -54,8 +56,6 @@
 };
 
 if ( $^O !~ /Win32/ ) {
-    $parms->{PREREQ_PM}->{'HTTP::Server::Simple'} = 0.35;
-    $parms->{PREREQ_PM}->{'HTTP::Server::Simple::CGI'} = 0;
 }
 
 if ( $ExtUtils::MakeMaker::VERSION ge '6.45_01' ) {

Modified: branches/upstream/libwww-mechanize-perl/current/bin/mech-dump
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libwww-mechanize-perl/current/bin/mech-dump?rev=62611&op=diff
==============================================================================
--- branches/upstream/libwww-mechanize-perl/current/bin/mech-dump (original)
+++ branches/upstream/libwww-mechanize-perl/current/bin/mech-dump Wed Sep 15 20:23:16 2010
@@ -25,11 +25,12 @@
 GetOptions(
     'user=s'        => \$user,
     'password=s'    => \$pass,
-    headers         => sub { push( @actions, \&dump_headers ); },
-    forms           => sub { push( @actions, \&dump_forms ); },
-    links           => sub { push( @actions, \&dump_links ); },
-    images          => sub { push( @actions, \&dump_images ); },
-    all             => sub { push( @actions, \&dump_headers, \&dump_forms, \&dump_links, \&dump_images ); },
+    headers         => sub { push( @actions, \&dump_headers ) },
+    forms           => sub { push( @actions, \&dump_forms ) },
+    links           => sub { push( @actions, \&dump_links ) },
+    images          => sub { push( @actions, \&dump_images ) },
+    all             => sub { push( @actions, \&dump_headers, \&dump_forms, \&dump_links, \&dump_images ) },
+    text            => sub { push( @actions, \&dump_text ) },
     absolute        => \$absolute,
     'agent=s'       => \$agent,
     'agent-alias=s' => \$agent_alias,
@@ -48,6 +49,8 @@
     --links                Dump table of links
     --images               Dump table of images
     --all                  Dump all four of the above, in that order
+
+    --text                 Dumps the textual part of the web page
 
     --user=user            Set the username
     --password=pass        Set the password
@@ -138,6 +141,12 @@
     return;
 }
 
+sub dump_text {
+    my $mech = shift;
+    $mech->dump_text();
+    return;
+}
+
 =head1 SEE ALSO
 
 L<WWW::Mechanize>

Modified: branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize.pm?rev=62611&op=diff
==============================================================================
--- branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize.pm (original)
+++ branches/upstream/libwww-mechanize-perl/current/lib/WWW/Mechanize.pm Wed Sep 15 20:23:16 2010
@@ -6,11 +6,11 @@
 
 =head1 VERSION
 
-Version 1.64
-
-=cut
-
-our $VERSION = '1.64';
+Version 1.66
+
+=cut
+
+our $VERSION = '1.66';
 
 =head1 SYNOPSIS
 
@@ -630,7 +630,12 @@
         }
 
         if ( my $format = delete $parms{format} ) {
-            $content = $self->_format_content( $format, $content );
+            if ( $format eq 'text' ) {
+                $content = $self->text;
+            }
+            else {
+                $self->die( qq{Unknown "format" parameter "$format"} );
+            }
         }
 
         $self->_check_unhandled_parms( %parms );
@@ -639,32 +644,31 @@
     return $content;
 }
 
-sub _format_content {
-    my $self = shift;
-    my $format = shift;
-    my $content = shift;
-
-    if ( $format eq 'text' ) {
-        return $self->_content_as_text($content);
-    }
-    else {
-        $self->die( qq{Unknown "format" parameter "$format"} );
-    }
-}
-
-sub _content_as_text {
-    my $self = shift;
-    my $content = shift;
-
-    require HTML::TreeBuilder;
-    my $tree = HTML::TreeBuilder->new();
-    $tree->parse($content);
-    $tree->eof();
-    $tree->elementify(); # just for safety
-    my $formatted_content = $tree->as_text();
-    $tree->delete;
-
-    return $formatted_content;
+=head2 $mech->text()
+
+Returns the text of the current HTML content.  If the content isn't
+HTML, $mech will die.
+
+The text is extracted by parsing the content, and then the extracted
+text is cached, so don't worry about performance of calling this
+repeatedly.
+
+=cut
+
+sub text {
+    my $self = shift;
+
+    if ( not defined $self->{text} ) {
+        require HTML::TreeBuilder;
+        my $tree = HTML::TreeBuilder->new();
+        $tree->parse( $self->content );
+        $tree->eof();
+        $tree->elementify(); # just for safety
+        $self->{text} = $tree->as_text();
+        $tree->delete;
+    }
+
+    return $self->{text};
 }
 
 sub _check_unhandled_parms {
@@ -955,6 +959,8 @@
             }
         }
     } # for keys %parms
+
+    return;
 } # _clean_keys()
 
 
@@ -1850,6 +1856,11 @@
 
 If I<button> is not passed, then the C<L</submit()>> method is used instead.
 
+If you want to submit a file and get its content from a scalar rather
+than a file in the filesystem, you can use:
+
+    $mech->submit_form(with_fields => { logfile => [ [ undef, 'whatever', Content => $content ], 1 ] } );
+
 Returns an L<HTTP::Response> object.
 
 =cut
@@ -2115,23 +2126,19 @@
     return;
 }
 
-=head2 $mech->dump_all( [[$fh], $absolute] )
-
-Prints a dump of all links, images and forms on the current page to
-I<$fh>.  If I<$fh> is not specified or is undef, it dumps to STDOUT.
-
-If I<$absolute> is true, links displayed are absolute, not relative.
-
-=cut
-
-sub dump_all {
+=head2 $mech->dump_text( [$fh] )
+
+Prints a dump of the text on the current page to I<$fh>.  If I<$fh>
+is not specified or is undef, it dumps to STDOUT.
+
+=cut
+
+sub dump_text {
     my $self = shift;
     my $fh = shift || \*STDOUT;
     my $absolute = shift;
 
-    $self->dump_links( $fh, $absolute );
-    $self->dump_images( $fh, $absolute );
-    $self->dump_forms( $fh, $absolute );
+    print {$fh} $self->text, "\n";
 
     return;
 }
@@ -2203,9 +2210,7 @@
         $self->_push_page_stack();
     }
 
-    $self->_update_page($request, $self->_make_request( $request, @_ ));
-
-    # XXX This should definitively return something.
+    return $self->_update_page($request, $self->_make_request( $request, @_ ));
 }
 
 =head2 $mech->update_html( $html )
@@ -2253,8 +2258,6 @@
     $self->{ct} = 'text/html';
     $self->{content} = $html;
 
-    $self->_reset_page();
-
     return;
 }
 
@@ -2306,6 +2309,44 @@
     my $self = shift;
     delete @$self{qw( __username __password )};
 }
+
+=head1 INHERITED UNCHANGED LWP::UserAgent METHODS
+
+As a sublass of L<LWP::UserAgent>, WWW::Mechanize inherits all of
+L<LWP::UserAgent>'s methods.  Many of which are overridden or
+extended. The following methods are inherited unchanged. View the
+L<LWP::UserAgent> documentation for their implementation descriptions.
+
+This is not meant to be an inclusive list.  LWP::UA may have added
+others.
+
+=head2 $mech->head()
+
+Inherited from L<LWP::UserAgent>.
+
+=head2 $mech->post()
+
+Inherited from L<LWP::UserAgent>.
+
+=head2 $mech->mirror()
+
+Inherited from L<LWP::UserAgent>.
+
+=head2 $mech->simple_request()
+
+Inherited from L<LWP::UserAgent>.
+
+=head2 $mech->is_protocol_supported()
+
+Inherited from L<LWP::UserAgent>.
+
+=head2 $mech->prepare_request()
+
+Inherited from L<LWP::UserAgent>.
+
+=head2 $mech->progress()
+
+Inherited from L<LWP::UserAgent>.
 
 =head1 INTERNAL-ONLY METHODS
 
@@ -2472,6 +2513,7 @@
     $self->{forms}        = undef;
     $self->{current_form} = undef;
     $self->{title}        = undef;
+    $self->{text}         = undef;
 
     return;
 }
@@ -2874,6 +2916,8 @@
 Thanks to the numerous people who have helped out on WWW::Mechanize in
 one way or another, including
 Kirrily Robert for the original C<WWW::Automate>,
+Lyle Hopkins,
+Damien Clark,
 Ansgar Burchardt,
 Gisle Aas,
 Jeremy Ary,

Modified: branches/upstream/libwww-mechanize-perl/current/t/autocheck.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libwww-mechanize-perl/current/t/autocheck.t?rev=62611&op=diff
==============================================================================
--- branches/upstream/libwww-mechanize-perl/current/t/autocheck.t (original)
+++ branches/upstream/libwww-mechanize-perl/current/t/autocheck.t Wed Sep 15 20:23:16 2010
@@ -4,31 +4,32 @@
 use strict;
 use Test::More;
 
-use constant NONEXISTENT => 'http://blahblablah.xx-nonexistent.';
 
-BEGIN {
-    if (gethostbyname('blahblahblah.xx-nonexistent.')) {
-        plan skip_all => 'Found an A record for the non-existent domain';
-    }
-}
-
+BEGIN { delete @ENV{ qw( http_proxy HTTP_PROXY ) }; }
 BEGIN {
     eval 'use Test::Exception';
     plan skip_all => 'Test::Exception required to test autocheck' if $@;
-    plan tests => 5;
 }
 
-BEGIN { delete @ENV{ qw( http_proxy HTTP_PROXY ) }; }
-BEGIN {
-    use_ok( 'WWW::Mechanize' );
+
+my $NONEXISTENT = 'blahblablah.xx-nonexistent.foo';
+my @results = gethostbyname( $NONEXISTENT );
+if ( @results ) {
+    my ($name,$aliases,$addrtype,$length, at addrs) = @results;
+    my $ip = join( '.', unpack('W4',$addrs[0]) );
+    plan skip_all => "Your ISP is overly helpful and returns $ip for non-existent domain $NONEXISTENT. This test cannot be run.";
 }
+my $bad_url = "http://$NONEXISTENT/";
+
+plan tests => 5;
+require_ok( 'WWW::Mechanize' );
 
 AUTOCHECK_OFF: {
     my $mech = WWW::Mechanize->new( autocheck => 0 );
     isa_ok( $mech, 'WWW::Mechanize' );
 
-    $mech->get( NONEXISTENT );
-    ok( !$mech->success, q{Didn't fetch, but didn't die, either} );
+    $mech->get( $bad_url );
+    ok( !$mech->success, qq{Didn't fetch $bad_url, but didn't die, either} );
 }
 
 AUTOCHECK_ON: {
@@ -36,6 +37,6 @@
     isa_ok( $mech, 'WWW::Mechanize' );
 
     dies_ok {
-        $mech->get( NONEXISTENT );
-    } 'Mech would die 4 u';
+        $mech->get( $bad_url );
+    } qq{Couldn't fetch $bad_url, and died as a result};
 }

Modified: branches/upstream/libwww-mechanize-perl/current/t/local/failure.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libwww-mechanize-perl/current/t/local/failure.t?rev=62611&op=diff
==============================================================================
--- branches/upstream/libwww-mechanize-perl/current/t/local/failure.t (original)
+++ branches/upstream/libwww-mechanize-perl/current/t/local/failure.t Wed Sep 15 20:23:16 2010
@@ -7,22 +7,25 @@
 use lib 't/local';
 use LocalServer;
 
-BEGIN {
-    if (gethostbyname('blahblahblah.xx-only-testing.')) {
-        plan skip_all => 'Found an A record for the non-existent domain';
-    }
-    plan tests => 15;
-}
 
 BEGIN {
     delete @ENV{ grep { lc eq 'http_proxy' } keys %ENV };
     delete @ENV{ qw( IFS CDPATH ENV BASH_ENV ) };
-    use_ok( 'WWW::Mechanize' );
 }
 
+my $NONEXISTENT = 'blahblahblah.xx-only-testing.foo';
+my @results = gethostbyname( $NONEXISTENT );
+if ( @results ) {
+    my ($name,$aliases,$addrtype,$length, at addrs) = @results;
+    my $ip = join( '.', unpack('W4',$addrs[0]) );
+    plan skip_all => "Your ISP is overly helpful and returns $ip for non-existent domain $NONEXISTENT. This test cannot be run.";
+}
+my $bad_url = "http://$NONEXISTENT/";
+
+plan tests => 15;
+require_ok( 'WWW::Mechanize' );
 my $server = LocalServer->spawn;
 isa_ok( $server, 'LocalServer' );
-
 
 my $mech = WWW::Mechanize->new( autocheck => 0 );
 isa_ok( $mech, 'WWW::Mechanize', 'Created object' );
@@ -42,8 +45,8 @@
 }
 
 BAD_PAGE: {
-    my $badurl = "http://blahblahblah.xx-only-testing.";
-    $mech->get( $badurl );
+    my $bad_url = "http://$NONEXISTENT/";
+    $mech->get( $bad_url );
 
     ok( !$mech->success, 'Failed the fetch' );
     ok( !$mech->is_html, "Isn't HTML" );




More information about the Pkg-perl-cvs-commits mailing list