Changeset 5810
- Timestamp:
- 01/29/08 23:27:00 (5 years ago)
- Location:
- lang/perl/WWW-HatenaLogin/trunk
- Files:
-
- 4 modified
-
Changes (modified) (1 diff)
-
lib/WWW/HatenaLogin.pm (modified) (4 diffs)
-
t/90_01_login_with_pit.t (modified) (2 diffs)
-
t/97_podspell.t (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/WWW-HatenaLogin/trunk/Changes
r5807 r5810 1 1 Revision history for Perl extension WWW::HatenaLogin 2 3 0.02 4 - add login_uri and logout_uri method 5 - add username accessor 6 - WWW::HatenaDiary friendry 2 7 3 8 0.01 2008-01-29T22:28:09+09:00 -
lang/perl/WWW-HatenaLogin/trunk/lib/WWW/HatenaLogin.pm
r5807 r5810 64 64 sub is_loggedin { 65 65 my $self = shift; 66 $self->{mech}->get($self-> {uri}->{login});66 $self->{mech}->get($self->login_uri); 67 67 $self->has_metalink; 68 68 } 69 69 70 sub login_uri { shift->{uri}->{login} } 71 72 sub logout_uri { shift->{uri}->{logout} } 73 74 sub username { 75 my $self = shift; 76 $self->{username} = defined $_[0] ? $_[0] : $self->{username}; 77 } 78 70 79 sub login { 71 my $self = shift; 72 73 $self->{mech}->get($self->{uri}->{login}); 80 my($self, $args) = @_; 81 82 if ($args) { 83 if ($args->{username}) { 84 $self->{username} = $args->{username}; 85 } 86 if ($args->{password}) { 87 $self->{password} = $args->{password}; 88 } 89 } 90 91 $self->{mech}->get($self->login_uri); 74 92 $self->{mech}->submit_form( 75 93 fields => { … … 85 103 sub logout { 86 104 my $self = shift; 87 $self->{mech}->get($self-> {uri}->{logout});105 $self->{mech}->get($self->logout_uri); 88 106 $self->{logout_check} ? $self->{logout_check}->($self) : $self->has_metalink; 89 107 } … … 232 250 =back 233 251 234 =head2 login () 235 236 =over 4 237 238 $session->login; 239 240 Login to Hatena. 241 username and password which are passed into C<new> method above will be used. 242 252 =head2 login ( [I<\%args>] ) 253 254 =over 4 255 256 $diary->login({ 257 username => $username, 258 password => $password, 259 }); 260 261 Logs in to Hatena::Diary using C<username> and C<password>. If either 262 C<username> or C<password> isn't passed into this method, the values 263 which are passed into C<new> method above will be used. 264 243 265 =back 244 266 … … 285 307 =back 286 308 309 =head2 login_uri () 310 311 =over 4 312 313 $session->login_uri; 314 315 return to login uri. 316 317 =back 318 319 =head2 logout_uri () 320 321 =over 4 322 323 $session->logout_uri; 324 325 return to logout uri. 326 327 =back 328 329 =head2 username ('username') 330 331 =over 4 332 333 $session->username; 334 $session->username('new_username'); 335 336 username accessor 337 338 =back 339 287 340 =head1 AUTHOR 288 341 -
lang/perl/WWW-HatenaLogin/trunk/t/90_01_login_with_pit.t
r5807 r5810 11 11 use WWW::HatenaLogin; 12 12 13 my $ config = pit_get('hatena', require => {13 my $base_config = pit_get('hatena', require => { 14 14 username => 'your username on hatena', 15 15 password => 'your password on hatena' … … 30 30 31 31 ok $session->login; 32 ok $session->logout; 33 34 { 35 local $@; 36 eval { 37 $session->login({ 38 username => '___', 39 password => '___', 40 }); 41 }; 42 like $@, qr/Login failed. Please confirm your/; 43 } 44 ok !$session->logout; 45 { 46 local $@; 47 eval { 48 $session->login; 49 }; 50 like $@, qr/Login failed. Please confirm your/; 51 } 52 ok !$session->logout; 53 54 ok $session->login({ 55 username => $base_config->{username}, 56 password => $base_config->{password}, 57 }); 58 59 ok $session->logout; 60 ok $session->login; 32 61 33 62 ok $session->logout; 34 63 ok !$session->logout; 35 64 ok !$session->session_id; 65 66 ok $session->username, $base_config->{username}; 67 $session->username('username'); 68 ok $session->username, 'username'; 36 69 } 37 70 38 hatena { %{ $ config } };39 hatena { %{ $ config }, com => 1 };40 hatena { %{ $ config }, labo => 1 };71 hatena { %{ $base_config } }; 72 hatena { %{ $base_config }, com => 1 }; 73 hatena { %{ $base_config }, labo => 1 }; 41 74 42 75 my $session = WWW::HatenaLogin->new({ 43 %{ $ config },76 %{ $base_config }, 44 77 nologin => 1, 45 78 }); -
lang/perl/WWW-HatenaLogin/trunk/t/97_podspell.t
r5807 r5810 15 15 jp 16 16 rk 17 uri
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)