r54067 - in /branches/upstream/libnet-twitter-perl/current: ./ lib/Net/ lib/Net/Twitter/ lib/Net/Twitter/Role/ lib/Net/Twitter/Role/API/ src/ t/

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Thu Mar 11 02:28:30 UTC 2010


Author: jawnsy-guest
Date: Thu Mar 11 02:28:24 2010
New Revision: 54067

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=54067
Log:
[svn-upgrade] Integrating new upstream version, libnet-twitter-perl (3.11009)

Added:
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/RetryOnError.pm
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/SimulateCursors.pm
    branches/upstream/libnet-twitter-perl/current/t/retry.t
Modified:
    branches/upstream/libnet-twitter-perl/current/Changes
    branches/upstream/libnet-twitter-perl/current/MANIFEST
    branches/upstream/libnet-twitter-perl/current/META.yml
    branches/upstream/libnet-twitter-perl/current/README
    branches/upstream/libnet-twitter-perl/current/lib/Net/Identica.pm
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pm
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pod
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/API.pm
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Core.pm
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth.pm
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/Lists.pm
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/REST.pm
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/OAuth.pm
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Search.pm
    branches/upstream/libnet-twitter-perl/current/src/net-twitter-pod.tt2

Modified: branches/upstream/libnet-twitter-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/Changes?rev=54067&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/Changes (original)
+++ branches/upstream/libnet-twitter-perl/current/Changes Thu Mar 11 02:28:24 2010
@@ -1,3 +1,9 @@
+3.11009 2010-03-10
+    - Added RetryOnError trait (see perldoc Net::Twitter::Role::RetryOnError)
+    - Import Sclar::Util::blessed in the POD Synopsis to make it clear callers need to do so (RT#55283)
+    - Use newly documented "preferred" oauth endpoints: http://api.twitter.com/oauth/*
+    - Added SimulateCursors trait for Identi.ca compatibility
+
 3.11008 2010-03-02
     - Added support for new api methods: reverse_geocode, geo_id
     - Updated method "update" with new parameters: place_id, display_coordinates

Modified: branches/upstream/libnet-twitter-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/MANIFEST?rev=54067&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/MANIFEST (original)
+++ branches/upstream/libnet-twitter-perl/current/MANIFEST Thu Mar 11 02:28:24 2010
@@ -30,6 +30,8 @@
 lib/Net/Twitter/Role/Legacy.pm
 lib/Net/Twitter/Role/OAuth.pm
 lib/Net/Twitter/Role/RateLimit.pm
+lib/Net/Twitter/Role/RetryOnError.pm
+lib/Net/Twitter/Role/SimulateCursors.pm
 lib/Net/Twitter/Role/WrapError.pm
 lib/Net/Twitter/Search.pm
 Makefile.PL
@@ -62,4 +64,5 @@
 t/99-pod_syntax.t
 t/geo.t
 t/lib/TestUA.pm
+t/retry.t
 t/unicode.t

Modified: branches/upstream/libnet-twitter-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/META.yml?rev=54067&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/META.yml (original)
+++ branches/upstream/libnet-twitter-perl/current/META.yml Thu Mar 11 02:28:24 2010
@@ -50,4 +50,4 @@
   homepage: http://github.com/semifor/Net-Twitter
   license: http://dev.perl.org/licenses/
   repository: git://github.com/semifor/Net-Twitter.git
-version: 3.11008
+version: 3.11009

Modified: branches/upstream/libnet-twitter-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/README?rev=54067&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/README (original)
+++ branches/upstream/libnet-twitter-perl/current/README Thu Mar 11 02:28:24 2010
@@ -2,10 +2,11 @@
     Net::Twitter - A perl interface to the Twitter API
 
 VERSION
-    This document describes Net::Twitter version 3.11008
+    This document describes Net::Twitter version 3.11009
 
 SYNOPSIS
       use Net::Twitter;
+      use Scalar::Util 'blessed';
 
       my $nt = Net::Twitter->new(
           traits   => [qw/API::REST/],

Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Identica.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Identica.pm?rev=54067&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Identica.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Identica.pm Thu Mar 11 02:28:24 2010
@@ -2,7 +2,7 @@
 use Moose;
 
 # use *all* digits for fBSD ports
-our $VERSION = '3.11008';
+our $VERSION = '3.11009';
 $VERSION     = eval $VERSION; # numify for warning-free dev releases
 
 extends 'Net::Twitter::Core';

Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pm?rev=54067&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pm Thu Mar 11 02:28:24 2010
@@ -11,7 +11,7 @@
 );
 
 # use *all* digits for fBSD ports
-our $VERSION = '3.11008';
+our $VERSION = '3.11009';
 
 $VERSION = eval $VERSION; # numify for warning-free dev releases
 

Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pod?rev=54067&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pod (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pod Thu Mar 11 02:28:24 2010
@@ -4,11 +4,12 @@
 
 =head1 VERSION
 
-This document describes Net::Twitter version 3.11008
+This document describes Net::Twitter version 3.11009
 
 =head1 SYNOPSIS
 
   use Net::Twitter;
+  use Scalar::Util 'blessed';
 
   my $nt = Net::Twitter->new(
       traits   => [qw/API::REST/],

Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/API.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/API.pm?rev=54067&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/API.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/API.pm Thu Mar 11 02:28:24 2010
@@ -80,8 +80,11 @@
         
         my $uri = URI->new($caller->_base_url($self) . "/$local_path.json");
 
-        return $self->_parse_result(
-            $self->_authenticated_request($options{method}, $uri, $args, $authenticate),
+        return $self->_json_request(
+            $options{method},
+            $uri,
+            $args,
+            $authenticate,
             $synthetic_args,
             $options{datetime_parser},
         );

Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Core.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Core.pm?rev=54067&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Core.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Core.pm Thu Mar 11 02:28:24 2010
@@ -17,7 +17,7 @@
 use namespace::autoclean;
 
 # use *all* digits for fBSD ports
-our $VERSION = '3.11008';
+our $VERSION = '3.11009';
 
 $VERSION = eval $VERSION; # numify for warning-free dev releases
 
@@ -113,6 +113,16 @@
     return { map { utf8::upgrade($_) unless ref($_); $_ } %$args };
 }
 
+sub _json_request { 
+    my ($self, $http_method, $uri, $args, $authenticate, $synthetic_args, $dt_parser) = @_;
+    
+    return $self->_parse_result(
+        $self->_authenticated_request($http_method, $uri, $args, $authenticate),
+        $synthetic_args,
+        $dt_parser,
+    );
+}
+
 # Basic Auth, overridden by Role::OAuth, if included
 sub _authenticated_request {
     my ($self, $http_method, $uri, $args, $authenticate) = @_;
@@ -142,8 +152,10 @@
     $msg->headers->authorization_basic($self->username, $self->password)
         if $authenticate && $self->has_username && $self->has_password;
 
-    return $self->ua->request($msg);
-}
+    return $self->_send_request($msg);
+}
+
+sub _send_request { shift->ua->request(shift) }
 
 # Twitter returns HTML encoded entities in the "text" field of status messages.
 # Decode them.

Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth.pm?rev=54067&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth.pm Thu Mar 11 02:28:24 2010
@@ -2,7 +2,7 @@
 use Moose;
 
 # use *all* digits for fBSD ports
-our $VERSION = '3.11008';
+our $VERSION = '3.11009';
 $VERSION = eval $VERSION; # numify for warning-free dev releases
 
 extends  'Net::Twitter::Core';

Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/Lists.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/Lists.pm?rev=54067&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/Lists.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/Lists.pm Thu Mar 11 02:28:24 2010
@@ -5,6 +5,8 @@
 use URI::Escape();
 use Try::Tiny;
 
+requires qw/_json_request/;
+
 =head1 NAME
 
 Net::Twitter::Role::API::Lists - Twitter Lists API support for Net::Twitter
@@ -173,9 +175,14 @@
 
     my $synthetic_args = $self->_extract_synthetic_args($args);
     my $authenticate = exists $synthetic_args->{authenticate} ? $synthetic_args->{authenticate} : 1;
-    my $res = $self->_authenticated_request($http_method, $uri, $args, $authenticate);
-
-    return $self->_parse_result($res, $synthetic_args, $self->_lists_dt_parser);
+    return $self->_json_request(
+        $http_method,
+        $uri,
+        $args,
+        $authenticate,
+        $synthetic_args,
+        $self->_lists_dt_parser,
+    );
 }
 
 sub _make_id_positional {

Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/REST.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/REST.pm?rev=54067&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/REST.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/REST.pm Thu Mar 11 02:28:24 2010
@@ -23,7 +23,8 @@
 around BUILDARGS => sub {
     my $next    = shift;
     my $class   = shift;
-    my %options = @_;
+
+    my %options = @_ == 1 ? %{$_[0]} : @_;
 
     if ( delete $options{identica} ) {
         %options = (
@@ -33,7 +34,7 @@
         );
     }
 
-    return $next->($class, %options);
+    return $next->($class, \%options);
 };
 
 after credentials => sub {

Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/OAuth.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/OAuth.pm?rev=54067&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/OAuth.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/OAuth.pm Thu Mar 11 02:28:24 2010
@@ -20,11 +20,11 @@
 
     my $args = $class->$orig(@_);
     my $oauth_urls = delete $args->{oauth_urls} || {
-        request_token_url  => "http://twitter.com/oauth/request_token",
-        authentication_url => "http://twitter.com/oauth/authenticate",
-        authorization_url  => "http://twitter.com/oauth/authorize",
-        access_token_url   => "http://twitter.com/oauth/access_token",
-        xauth_url          => "https://twitter.com/oauth/access_token",
+        request_token_url  => "http://api.twitter.com/oauth/request_token",
+        authentication_url => "http://api.twitter.com/oauth/authenticate",
+        authorization_url  => "http://api.twitter.com/oauth/authorize",
+        access_token_url   => "http://api.twitter.com/oauth/access_token",
+        xauth_url          => "https://api.twitter.com/oauth/access_token",
     };
 
     return { %$oauth_urls, %$args };
@@ -203,7 +203,7 @@
         croak "unexpected http_method: $http_method";
     }
 
-    return $self->ua->request($msg);
+    return $self->_send_request($msg);
 };
 
 sub xauth {

Added: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/RetryOnError.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/RetryOnError.pm?rev=54067&op=file
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/RetryOnError.pm (added)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/RetryOnError.pm Thu Mar 11 02:28:24 2010
@@ -1,0 +1,144 @@
+package Net::Twitter::Role::RetryOnError;
+use Moose::Role;
+use namespace::autoclean;
+
+requires '_send_request';
+
+=head1 NAME
+
+Net::Twitter::Role::RetryOnError - Retry Twitter API calls on error
+
+=head1 SYNOPSIS
+
+    use Net::Twitter;
+    $nt = Net::Twitter->new(
+        traits      => ['API::REST', 'RetryOnError']
+        max_retries => 3,
+    );
+
+=head1 DESCRIPTION
+
+Temporary errors are not uncommon when calling the Twitter API.  When applied
+to L<Net::Twitter> this role will provide automatic retries of API calls in a very
+configurable way.
+
+It only retries when the response status code is E<gt>= 500.  Other error codes
+indicate a permanent error.  If the maximum number of retries is reached,
+without success, an exception is thrown, as usual.
+
+
+=head1 OPTIONS
+
+This role adds the following options to C<new>:
+
+=over 4
+
+=item initial_retry_delay
+
+A floating point number specifying the initial delay, after an error, before
+retrying.  Default: 0.25 (250 milliseconds).
+
+=cut
+
+has initial_retry_delay => (
+    is      => 'rw',
+    isa     => 'Num',
+    default => 0.250, # 250 milliseconds
+);
+
+=item max_retry_delay
+
+A floating point number specifying the maximum delay between retries.  Default: 4.0
+
+=cut
+
+has max_retry_delay => (
+    is      => 'rw',
+    isa     => 'Num',
+    default => 4.0,   # 4 seconds
+);
+
+=item retry_delay_multiplier
+
+On the second and subsequent retries, a new delay is calculated by multiplying the previous
+delay by C<retry_delay_multiplier>. Default: 2.0
+
+=cut
+
+has retry_delay_multiplier => (
+    is      => 'rw',
+    isa     => 'Num',
+    default => 2,     # double the prior delay
+);
+
+=item max_retries
+
+The maximum number of consecutive retries before giving up and throwing an exception.
+If set to 0, it the API call will be retried indefinitely. Default 5.
+
+=cut
+
+has max_retries => (
+    is        => 'rw',
+    isa       => 'Int',
+    default   => 5,   # 0 = try forever
+);
+
+=item retry_delay_code
+
+A code reference that will be called to handle the delay.  It is passed a
+single argument: a floating point number specifying the number of seconds to
+delay.  By default, L<Time::HiRes/sleep> is called.
+
+If you're using a non-blocking user agent, like L<Coro::LWP>, you should use
+this option to provide a non-blocking delay.
+
+=cut
+
+has retry_delay_code => (
+    is      => 'rw',
+    isa     => 'CodeRef',
+    default => sub {
+        require Time::HiRes;
+        sub { Time::HiRes::sleep(shift) };
+    },
+);
+
+=back
+
+=cut
+
+around _send_request => sub {
+    my ( $orig, $self, $msg ) = @_;
+
+    my $delay = $self->initial_retry_delay;
+    my $retries = $self->max_retries;
+    while () {
+        my $res = $orig->($self, $msg);
+
+        return $res if $res->is_success || $retries-- == 0 || $res->code < 500;
+
+        $self->retry_delay_code->($delay);
+        $delay *= $self->retry_delay_multiplier;
+        $delay  = $self->max_retry_delay if $delay > $self->max_retry_delay;
+    }
+};
+
+
+1;
+
+__END__
+
+=head1 AUTHOR
+
+Marc Mims <marc at questright.com>
+
+=head1 COPYRIGHT
+
+Copyright (c) 2010 Marc Mims
+
+=head1 LICENSE
+
+This library is free software and may be distributed under the same terms as perl itself.
+
+=cut

Added: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/SimulateCursors.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/SimulateCursors.pm?rev=54067&op=file
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/SimulateCursors.pm (added)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/SimulateCursors.pm Thu Mar 11 02:28:24 2010
@@ -1,0 +1,79 @@
+package Net::Twitter::Role::SimulateCursors;
+use Moose::Role;
+use namespace::autoclean;
+
+requires qw/_json_request/;
+
+around _json_request => sub {
+    my $orig = shift;
+    my $self = shift;
+    my ($http_method, $uri, $args, $authenticate) = @_;
+
+    if ( defined(my $cursor = delete $args->{cursor}) ) {
+        my $page = $cursor == -1 ? 1 : $cursor;
+        my $r = $self->$orig($http_method, $uri, { %$args, page => $page }, $authenticate);
+
+        my $key = $uri =~ qr`/ids\.` ? 'ids' : 'users';
+
+        my $next_cursor     = @$r ? $page + 1 : 0;
+        my $previous_cursor = $page == 1 ? 0 : $page - 1;
+
+        return {
+            next_cursor         => $next_cursor,
+            next_cursor_str     => "$next_cursor",
+            previous_cursor     => $previous_cursor,
+            previous_cursor_str => "$previous_cursor",
+            $key                => $r,
+        };
+    }
+
+    return $self->$orig(@_);
+};
+
+1;
+
+__END__
+
+=head1 NAME
+
+Net::Twitter::Role::SimulateCursors - Make paging work like cursoring
+
+=head1 SYNOPSIS
+
+  use Net::Twitter;
+
+  my $nt = Net::Twitter->new(
+      traits          => ['API::REST', 'SimulateCursors'],
+  );
+
+
+=head1 DESCRIPTION
+
+This role simulates the cursoring method used by some Twitter API methods.  It's useful
+for providing compatibility with Identi.ca, for instance, that does not support cursoring
+and requires paging, instead.
+
+
+=head1 METHODS
+
+=over 4
+
+
+=back
+
+=head1 AUTHOR
+
+Marc Mims E<lt>marc at questright.comE<gt>
+
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+L<Net::Twitter>
+
+=cut
+

Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Search.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Search.pm?rev=54067&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Search.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Search.pm Thu Mar 11 02:28:24 2010
@@ -2,7 +2,7 @@
 use Moose;
 
 # use *all* digits for fBSD ports
-our $VERSION = '3.11008';
+our $VERSION = '3.11009';
 $VERSION = eval $VERSION; # numify for warning-free dev releases
 
 extends 'Net::Twitter::Core';

Modified: branches/upstream/libnet-twitter-perl/current/src/net-twitter-pod.tt2
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/src/net-twitter-pod.tt2?rev=54067&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/src/net-twitter-pod.tt2 (original)
+++ branches/upstream/libnet-twitter-perl/current/src/net-twitter-pod.tt2 Thu Mar 11 02:28:24 2010
@@ -9,6 +9,7 @@
 =head1 SYNOPSIS
 
   use Net::Twitter;
+  use Scalar::Util 'blessed';
 
   my $nt = Net::Twitter->new(
       traits   => [qw/API::REST/],

Added: branches/upstream/libnet-twitter-perl/current/t/retry.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/t/retry.t?rev=54067&op=file
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/t/retry.t (added)
+++ branches/upstream/libnet-twitter-perl/current/t/retry.t Thu Mar 11 02:28:24 2010
@@ -1,0 +1,38 @@
+#!perl
+use warnings;
+use strict;
+use Try::Tiny;
+use Test::More tests => 1;
+use Net::Twitter;
+
+eval "use LWP::UserAgent 5.819";
+plan skip_all => 'LWP::UserAgent >= 5.819 required' if $@;
+
+my $req;
+my $ua = LWP::UserAgent->new;
+$ua->add_handler(request_send => sub {
+    $req = shift;
+    my $res = HTTP::Response->new(500, 'Uh-oh!');
+    $res->content('{"test":"OK"}');
+    return $res;
+});
+
+sub params {
+    my $uri = URI->new;
+    $uri->query($req->content);
+    my %params = $uri->query_form;
+    return \%params;
+}
+
+my $retry_count = 0;
+my $nt = Net::Twitter->new(
+    traits   => [qw/API::REST RetryOnError/],
+    username => 'fred',
+    password => 'secret',
+    ua       => $ua,
+    max_retries => 5,
+    retry_delay_code => sub { ++$retry_count },
+);
+
+try { $nt->verify_credentials };
+is $retry_count, 5, 'retried 5 times';




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