[Bps-public-commit] r18292 - in Net-Google-Code/branches/write: .

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon Feb 9 06:55:37 EST 2009


Author: sunnavy
Date: Mon Feb  9 06:55:34 2009
New Revision: 18292

Modified:
   Net-Google-Code/branches/write/   (props changed)
   Net-Google-Code/branches/write/lib/Net/Google/Code/Role/Authentication.pm

Log:
 r19706 at sunnavys-mb:  sunnavy | 2009-02-09 17:42:45 +0800
 better detect sign in or out


Modified: Net-Google-Code/branches/write/lib/Net/Google/Code/Role/Authentication.pm
==============================================================================
--- Net-Google-Code/branches/write/lib/Net/Google/Code/Role/Authentication.pm	(original)
+++ Net-Google-Code/branches/write/lib/Net/Google/Code/Role/Authentication.pm	Mon Feb  9 06:55:34 2009
@@ -9,11 +9,10 @@
 );
 
 has 'password' => (
-    isa       => 'Str',
-    is        => 'rw',
+    isa => 'Str',
+    is  => 'rw',
 );
 
-
 sub signin {
     my $self = shift;
     return 1 if $self->signed_in;
@@ -41,7 +40,10 @@
 
     die 'signin failed to google code'
       unless ( $already_in_google && $self->mech->uri =~ /CheckCookie/ )
-      || ( !$already_in_google && $self->mech->content =~ /Sign Out/ );
+      || !$already_in_google && $self->html_contains(
+        look_down => [ id => 'gaia' ],
+        as_text   => qr/Sign out/,
+      );
 
     return 1;
 }
@@ -52,12 +54,15 @@
         url_regex => qr!^https?://www\.google\.com/accounts/Logout! )
       || $self->mech->get('https://www.google.com/accounts/Logout');
     die 'sign out failed to google code'
-      unless $self->mech->content =~ m!Sign In!;
+      unless $self->html_contains(
+        look_down => [ id => 'gaia' ],
+        as_text   => qr/Sign in/,
+      );
 
     return 1;
 }
 
-*sign_in = \&signin;
+*sign_in  = \&signin;
 *sign_out = \&signout;
 
 sub ask_password {
@@ -69,13 +74,14 @@
     }
 }
 
-
 sub signed_in {
     my $self = shift;
     return 1
       if $self->mech->content
-          && $self->mech->uri =~ m!https?://[-\w]+\.google\.com/!
-          && $self->mech->content =~ /Sign Out/;
+          && $self->html_contains(
+              look_down => [ id => 'gaia' ],
+              as_text   => qr/Sign out/,
+          );
     return;
 }
 



More information about the Bps-public-commit mailing list